org.starhope.appius.mb
Class PaymentGateway

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.sql.SQLPeerDatum
          extended by org.starhope.appius.mb.PaymentGateway
All Implemented Interfaces:
PaymentGatewayReal

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

Field Summary
private  String code
           
private  PaymentGatewayReal implementation
           
private  String implementor
          The class implementing the actual functionality, e.g.
private  String managementURL
           
private static long serialVersionUID
           
private  String title
           
private  Person user
           
 
Constructor Summary
PaymentGateway()
           
 
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()
           
 Person 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 implementor)
           
 void setManagementURL(String newManagementURL)
           
 void setTitle(String newTitle)
           
 void setUser(Parent byID)
           
 void setUser(Person newUser)
           
 void startEnrolment(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, findInCache, get, prepare, prepare, saveInCache
 
Methods inherited from class org.starhope.appius.util.ManagedReferenceHolder
deref, setRef
 
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

implementation

private PaymentGatewayReal implementation

implementor

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


managementURL

private String managementURL

title

private String title

user

private Person user
Constructor Detail

PaymentGateway

public PaymentGateway()
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
Throws:
IllegalAccessException - if the class specified is protected from this one
InstantiationException - if the class couldn't be constructed for some reason

alterEnrolment

public void alterEnrolment(Payment payment,
                           UserEnrolment newForm)
                    throws UnsupportedCurrencyException,
                           NotFoundException,
                           UnsupportedCredentialException,
                           IOException,
                           RetryPaymentException,
                           GameLogicException
Specified by:
alterEnrolment in interface PaymentGatewayReal
Throws:
UnsupportedCurrencyException
NotFoundException
UnsupportedCredentialException
IOException
RetryPaymentException
GameLogicException
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
Throws:
UnsupportedCurrencyException
NotFoundException
UnsupportedCredentialException
IOException
RetryPaymentException
GameLogicException
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 Person 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
See Also:
CastsToJSON.set(org.json.JSONObject)

set

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

Specified by:
set in class SQLPeerDatum
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 implementor)
Parameters:
implementor - 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(Parent byID)
Parameters:
byID -
See Also:
org.starhope.appius.pay.util.PaymentGatewayReal#setUser(org.starhope.appius.user.Parent)

setUser

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

startEnrolment

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

toJSON

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

Overrides:
toJSON in class SQLPeerDatum
Returns:
See Also:
SQLPeerDatum.toJSON()

transactPayment

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