org.starhope.appius.pay
Class AuthorizeNetGateway

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

public class AuthorizeNetGateway
extends PaymentGateway

Author:
brpocock@star-hope.org, twheys@gmail.com
See Also:
Serialized Form

Field Summary
private  UserAddress address
           
private  String buyerCompany
           
private  String buyerFamilyName
           
private  String buyerGivenName
           
private static long serialVersionUID
          WRITEME: Document this field.
 
Constructor Summary
AuthorizeNetGateway()
           
 
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.
private  ARBAPI getARBAPI()
           
 Payment getPayment(BigDecimal id)
          This is an overriding method.
 Payment getPayment(String gatewayTransactionCode)
           
 boolean isAvailable()
          Submits a known-good test transaction.
 void setUser(GeneralUser possibleUser)
          Deprecated. 
 void startEnrolment(Payment payment)
          Start an Authorize.Net subscription through their (now-beautiful!! WTF?) Automated Recurring Billing engine.
 void startTransaction(Payment payment)
           
 void transactPayment(Payment payment)
           
 
Methods inherited from class org.starhope.appius.mb.PaymentGateway
flush, get, get, getByClass, getCacheUniqueID, getCode, getImplementor, getManagementURL, getTitle, getUser, set, set, setCode, setImplementor, setManagementURL, setTitle, setUser, setUser, toJSON
 
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
WRITEME: Document this field. twheys@gmail.com Feb 2, 2010

See Also:
Constant Field Values

address

private UserAddress address

buyerCompany

private String buyerCompany

buyerFamilyName

private String buyerFamilyName

buyerGivenName

private String buyerGivenName
Constructor Detail

AuthorizeNetGateway

public AuthorizeNetGateway()
Method Detail

alterEnrolment

public void alterEnrolment(Payment payment,
                           UserEnrolment newForm)
                    throws UnsupportedCurrencyException,
                           NotFoundException,
                           UnsupportedCredentialException,
                           IOException,
                           RetryPaymentException,
                           GameLogicException
Specified by:
alterEnrolment in interface PaymentGatewayReal
Overrides:
alterEnrolment in class PaymentGateway
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 IllegalStateException,
                         NotFoundException
Specified by:
endEnrolment in interface PaymentGatewayReal
Overrides:
endEnrolment in class PaymentGateway
Parameters:
payment - WRITEME
Throws:
NotFoundException - WRITEME
IllegalStateException
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
Overrides:
enumerateCredentialTypes in class PaymentGateway
Returns:
all supported CredentialType:s
See Also:
PaymentGatewayReal.enumerateCredentialTypes()

getARBAPI

private ARBAPI getARBAPI()
Returns:
a valid ARBAPI object, properly configured

getPayment

public Payment getPayment(BigDecimal id)
This is an overriding method.

Specified by:
getPayment in interface PaymentGatewayReal
Overrides:
getPayment in class PaymentGateway
Parameters:
id - 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)

getPayment

public Payment getPayment(String gatewayTransactionCode)
Parameters:
gatewayTransactionCode - The transaction code of the payment in question
Returns:
As much information as possible about the past transaction

isAvailable

public boolean isAvailable()
Submits a known-good test transaction.

Specified by:
isAvailable in interface PaymentGatewayReal
Overrides:
isAvailable in class PaymentGateway
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()

setUser

@Deprecated
public void setUser(GeneralUser possibleUser)
Deprecated. 

Sets the user for this transaction to either the given user, or (if the given user is not an adult), his/her parent.

This method does not work right now.

Parameters:
possibleUser - The user or child of the user to be set

startEnrolment

public void startEnrolment(Payment payment)
                    throws UnsupportedCurrencyException,
                           NotFoundException,
                           UnsupportedCredentialException,
                           IOException,
                           RetryPaymentException,
                           GameLogicException,
                           AlreadyUsedException
Start an Authorize.Net subscription through their (now-beautiful!! WTF?) Automated Recurring Billing engine.

Specified by:
startEnrolment in interface PaymentGatewayReal
Overrides:
startEnrolment in class PaymentGateway
Parameters:
payment - WRITEME
Throws:
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
GameLogicException - WRITEME
AlreadyUsedException - 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
Overrides:
startTransaction in class PaymentGateway
Parameters:
payment - WRITEME
Throws:
UnsupportedCurrencyException - WRITEME
NotFoundException - WRITEME
UnsupportedCredentialException - WRITEME
IOException - WRITEME
RetryPaymentException - WRITEME
GameLogicException - WRITEME
AlreadyUsedException - WRITEME
DataException - WRITEME
See Also:
PaymentGatewayReal.startTransaction(org.starhope.appius.mb.Payment)

transactPayment

public void transactPayment(Payment payment)
                     throws UnsupportedCurrencyException,
                            NotFoundException,
                            UnsupportedCredentialException,
                            IOException,
                            RetryPaymentException,
                            GameLogicException,
                            AlreadyUsedException,
                            DataException
Specified by:
transactPayment in interface PaymentGatewayReal
Overrides:
transactPayment in class PaymentGateway
Parameters:
payment - payment
Throws:
UnsupportedCurrencyException - if the payment is not expressed in USD or if the scale is less than 1¢. We re-throw an ArithmeticException from BigDecimal.setScale(int, java.math.RoundingMode) (q.v. for remarks) if setting the scale to "2" (thus, 1¢ increments) would induce rounding.
NotFoundException - if the buyer or address aren't found or mismatch in some exciting way
UnsupportedCredentialException - if a type of payment credentials are presented which we don't support. This shouldn't happen, since we enumerate supported types in enumerateCredentialTypes specifically to prevent that.
IOException - if a connection to Authorize.Net can't be established due to a network failure or similar problem.
RetryPaymentException - if the payment can't be processed right now, but we should retry after a few minutes.
GameLogicException - if the payment has already been completed
AlreadyUsedException - if the Payment object is already closed (used)
DataException - if Authorize.Net rejects the payment
See Also:
PaymentGatewayReal.transactPayment(Payment)