org.starhope.appius.mb
Class PaymentGateway

java.lang.Object
  extended by org.starhope.appius.sql.SQLPeerDatum
      extended by org.starhope.appius.mb.PaymentGateway
All Implemented Interfaces:
Serializable, Comparable<Object>, PaymentGatewayReal
Direct Known Subclasses:
AuthorizeNetGateway

public class PaymentGateway
extends SQLPeerDatum
implements PaymentGatewayReal

A payment gateway is a transaction broker for payments. E.G. Res Interactive/Tootsville is using Authorize.Net. Alternative providers might include other credit-card or cheque processing companies, or other electronic transfer means such as Paypal or micro-currency systems used in other online gaming sites/communities. Gift card transactions are also processed through a special payment gateway.

Author:
brpocock@star-hope.org
See Also:
Serialized Form

Field Summary
private  String code
          WRITEME
private  PaymentGatewayReal implementation
          WRITEME
private  String implementor
          The class implementing the actual functionality, e.g.
private  String managementURL
          WRITEME
private static long serialVersionUID
           
private  String title
          WRITEME
private  AbstractPerson user
          WRITEME
 
Constructor Summary
PaymentGateway()
          WRITEME
 
Method Summary
 void alterEnrolment(Payment payment, UserEnrolment newForm)
           
 void endEnrolment(Payment payment)
           
 List<CredentialType> enumerateCredentialTypes()
          Provides a list of all credential types supported by the given payment gateway.
 void flush()
          This is an overriding method.
static PaymentGateway get(org.json.JSONObject object)
           
static Class<? extends PaymentGatewayReal> get(String id)
           
static PaymentGatewayReal getByClass(Class<? extends PaymentGatewayReal> klass)
           
protected  String getCacheUniqueID()
          This is an overriding method.
 String getCode()
           
private  PaymentGatewayReal getImplementation()
           
 String getImplementor()
           
 String getManagementURL()
           
 Payment getPayment(BigDecimal bigDecimal)
          This is an overriding method.
 String getTitle()
           
 AbstractPerson getUser()
          Get the user account associated with the payment gateway.
 boolean isAvailable()
           
 void set(org.json.JSONObject o)
           
protected  void set(ResultSet rs)
          This is an overriding method.
 void setCode(String newCode)
           
 void setImplementor(String implementor1)
           
 void setManagementURL(String newManagementURL)
           
 void setTitle(String newTitle)
           
 void setUser(AbstractPerson newUser)
           
 void setUser(Parent byID)
           
 void startEnrolment(Payment payment)
           
 void startTransaction(Payment payment)
           
 org.json.JSONObject toJSON()
          This is an overriding method.
 void transactPayment(Payment p)
           
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, compareTo, findInCache, get, saveInCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

code

private String code
WRITEME


implementation

private PaymentGatewayReal implementation
WRITEME


implementor

private String implementor
The class implementing the actual functionality, e.g. org.starhope.appius.pay.AuthorizeNetGateway


managementURL

private String managementURL
WRITEME


title

private String title
WRITEME


user

private AbstractPerson user
WRITEME

Constructor Detail

PaymentGateway

public PaymentGateway()
WRITEME

Method Detail

get

public static PaymentGateway get(org.json.JSONObject object)
                          throws RuntimeException,
                                 NotFoundException,
                                 org.json.JSONException
Parameters:
object - The JSON object containing the description of the gateway we want ot get
Returns:
a payment gateway
Throws:
org.json.JSONException - if the JSON object is busted
NotFoundException - if the payment gateway can't be found
RuntimeException - if, I dunno, something bad happens? (TODO: what??)

get

public static Class<? extends PaymentGatewayReal> get(String id)
                                               throws NotFoundException
Parameters:
id - The 4-char authorization code for the payment gateway. (Used as the order_source part of the order ID), in lower-case letters.
  • auth = Authorize.net
  • ppal = PayPal
  • goog = Google Checkout
  • card = Giftcard (Not used)
  • ibcc = iBC Prepaid Card
Returns:
the Class specified, which can then be instantiated.
Throws:
NotFoundException - if the payment gateway type does not exist or is unimplemented.

getByClass

public static PaymentGatewayReal getByClass(Class<? extends PaymentGatewayReal> klass)
Parameters:
klass - A class implementing PaymentGatewayReal
Returns:
the PaymentGateway database object associated therewith

alterEnrolment

public void alterEnrolment(Payment payment,
                           UserEnrolment newForm)
                    throws UnsupportedCurrencyException,
                           NotFoundException,
                           UnsupportedCredentialException,
                           IOException,
                           RetryPaymentException,
                           GameLogicException
Specified by:
alterEnrolment in interface PaymentGatewayReal
Parameters:
payment - WRITEME
newForm - WRITEME
Throws:
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
GameLogicException - WRITEME
See Also:
PaymentGatewayReal.alterEnrolment(org.starhope.appius.mb.Payment, org.starhope.appius.mb.UserEnrolment)

endEnrolment

public void endEnrolment(Payment payment)
                  throws UnsupportedCurrencyException,
                         NotFoundException,
                         UnsupportedCredentialException,
                         IOException,
                         RetryPaymentException,
                         GameLogicException
Specified by:
endEnrolment in interface PaymentGatewayReal
Parameters:
payment - WRITEME
Throws:
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
GameLogicException - WRITEME
See Also:
PaymentGatewayReal.endEnrolment(org.starhope.appius.mb.Payment)

enumerateCredentialTypes

public List<CredentialType> enumerateCredentialTypes()
Description copied from interface: PaymentGatewayReal
Provides a list of all credential types supported by the given payment gateway.

Specified by:
enumerateCredentialTypes in interface PaymentGatewayReal
Returns:
all supported CredentialType:s
See Also:
PaymentGatewayReal.enumerateCredentialTypes()

flush

public void flush()
This is an overriding method.

Specified by:
flush in class SQLPeerDatum
See Also:
SQLPeerDatum.flush()

getCacheUniqueID

protected String getCacheUniqueID()
This is an overriding method.

Specified by:
getCacheUniqueID in class SQLPeerDatum
Returns:
The local (Stringified) version of an unique ID; usually the database ID column
See Also:
SQLPeerDatum.getCacheUniqueID()

getCode

public String getCode()
Returns:
WRITEME

getImplementation

private PaymentGatewayReal getImplementation()
                                      throws Exception
Returns:
an actual PaymentGatewayReal implementation
Throws:
Exception - of many kinds, because this is funky mojo

getImplementor

public String getImplementor()
Returns:
WRITEME

getManagementURL

public String getManagementURL()
Returns:
WRITEME

getPayment

public Payment getPayment(BigDecimal bigDecimal)
This is an overriding method. It also passes the buck to the implementor.

Specified by:
getPayment in interface PaymentGatewayReal
Parameters:
bigDecimal - The identifier used by the implementing payment gateway to uniquely identify the transaction in question.
Returns:
the results information available about that transaction
See Also:
PaymentGatewayReal.getPayment(java.math.BigDecimal)

getTitle

public String getTitle()
Returns:
Get the title of this Payment Gateway (end-user-visible)

getUser

public AbstractPerson getUser()
Get the user account associated with the payment gateway. (Each payment gateway has a user account in the system, which should have an age bracket of 'X')

Returns:
the system user account used for this payment gateway's moderator actions

isAvailable

public boolean isAvailable()
Specified by:
isAvailable in interface PaymentGatewayReal
Returns:
true, if the payment gateway appears to be online and functioning (or was known to be online and functioning recently enough)
See Also:
PaymentGatewayReal.isAvailable()

set

public void set(org.json.JSONObject o)
Overrides:
set in class SQLPeerDatum
Parameters:
o - The JSON data to be used to set the value of this object
See Also:
org.starhope.appius.util.CastsToJSON#set(org.json.JSONObject)

set

protected void set(ResultSet rs)
            throws SQLException
This is an overriding method.

Specified by:
set in class SQLPeerDatum
Parameters:
rs - The result of an SQL query, with the cursor already pointed at the row describing this specific instance of the object.
Throws:
SQLException - if the database fails somehow
See Also:
SQLPeerDatum.set(java.sql.ResultSet)

setCode

public void setCode(String newCode)
Parameters:
newCode - The new code for this payment gateway

setImplementor

public void setImplementor(String implementor1)
Parameters:
implementor1 - Set the actual Payment Gateway implementation to be used (String)

setManagementURL

public void setManagementURL(String newManagementURL)
Parameters:
newManagementURL - the management URL for accessing this payment gateway's settings (outside of our systems)

setTitle

public void setTitle(String newTitle)
Parameters:
newTitle - the (user-visible) title

setUser

public void setUser(AbstractPerson newUser)
Parameters:
newUser - the user account

setUser

public void setUser(Parent byID)
Parameters:
byID - WRITEME

startEnrolment

public void startEnrolment(Payment payment)
                    throws UnsupportedCurrencyException,
                           NotFoundException,
                           UnsupportedCredentialException,
                           IOException,
                           RetryPaymentException,
                           GameLogicException,
                           AlreadyUsedException
Specified by:
startEnrolment in interface PaymentGatewayReal
Parameters:
payment - WRITEME
Throws:
AlreadyUsedException - WRITEME
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
GameLogicException - WRITEME
See Also:
PaymentGatewayReal.startEnrolment(org.starhope.appius.mb.Payment)

startTransaction

public void startTransaction(Payment payment)
                      throws UnsupportedCurrencyException,
                             NotFoundException,
                             UnsupportedCredentialException,
                             IOException,
                             RetryPaymentException,
                             GameLogicException,
                             AlreadyUsedException,
                             DataException
Specified by:
startTransaction in interface PaymentGatewayReal
Parameters:
payment - WRITEME
Throws:
DataException - WRITEME
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
GameLogicException - WRITEME
AlreadyUsedException - WRITEME
See Also:
PaymentGatewayReal.startTransaction(org.starhope.appius.mb.Payment)

toJSON

public org.json.JSONObject toJSON()
This is an overriding method.

Overrides:
toJSON in class SQLPeerDatum
Returns:
This object's data, serialized into JSON form.
See Also:
SQLPeerDatum.toJSON()

transactPayment

public void transactPayment(Payment p)
                     throws UnsupportedCurrencyException,
                            NotFoundException,
                            UnsupportedCredentialException,
                            IOException,
                            RetryPaymentException,
                            GameLogicException,
                            AlreadyUsedException,
                            DataException
Specified by:
transactPayment in interface PaymentGatewayReal
Parameters:
p - WRITEME
Throws:
DataException - WRITEME
AlreadyUsedException - WRITEME
GameLogicException - WRITEME
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
See Also:
PaymentGatewayReal.transactPayment(Payment)