atg.integrations.cybercash
Class CyberCashConnection

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.integrations.cybercash.CyberCashConnection
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, CreditCardProcessor, atg.payment.creditcard.DecreaseCreditCardAuthorizationProcessor, java.util.EventListener

public class CyberCashConnection
extends GenericService
implements CreditCardProcessor, atg.payment.creditcard.DecreaseCreditCardAuthorizationProcessor

This class manages the communications to a CyberCash payment server.

Currently only credit card transactions are supported, no cybercash coins, checks or Microsoft Wallet support.

All information on the CyberCash communication protocol was acquired from: CashRegister Service -- Merchant Connection Kit Guide version 3.2 CashRegister Service -- Development Guide version 1.1


Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String CMD_AUTH_CAPTURE
          Authorize and charge a credit card.
static java.lang.String CMD_AUTHORIZE
          Authorize a credit card, does not charge.
static java.lang.String CMD_CAPTURE
          Charge a credit card that has been authorized.
static java.lang.String CMD_QUERY
          Check the local state of an order, this is only useful to see if/how a transaction completed.
static java.lang.String CMD_RETRY
          Retry a transaction that is in the pending state, as indeicated in query.
static java.lang.String CMD_RETURN
          Return money to a card holder that has been charged.
static java.lang.String CMD_VOID
          Void any transaction.
static java.lang.String CURRENCY_US_DOLLARS
          United States Dollars.
static int INITIAL_REQUEST_SIZE
          A guess at how big a request buffer needs to be, reduces StringBuffers resizings, hopefully.
static java.lang.String KEY_AVS_CODE
          The key for the avs status code
static java.lang.String KEY_CASH_AMOUNT
          The key for the amount of money to apply this transaction to.
static java.lang.String KEY_CC_ACT_CODE
          The key for the credit card action code.
static java.lang.String KEY_CC_ADDRESS
          The key for the address on the credit card, everything not city, state, zip, country, or name.
static java.lang.String KEY_CC_AMOUNT
          The amount to apply to the transaction, be it authorize,return...
static java.lang.String KEY_CC_AUTH_CODE
          The key for the credit card authorization code.
static java.lang.String KEY_CC_CITY
          The key for the city on the credit card billing address.
static java.lang.String KEY_CC_COUNTRY
          The key for the country on the credit card billing address.
static java.lang.String KEY_CC_EXPIRE
          The key for the credit card expiration date, MM/YY.
static java.lang.String KEY_CC_NAME
          The key for the name on the credit card billing address.
static java.lang.String KEY_CC_NUMBER
          The key for the credit card number.
static java.lang.String KEY_CC_STATE
          The key for the state on the credit card billing address.
static java.lang.String KEY_CC_TYPE
          The key for the credit card type.
static java.lang.String KEY_CC_ZIP
          The key for the zip on the credit card billing address.
static java.lang.String KEY_ERROR_CODE
          The key for error code.
static java.lang.String KEY_ERROR_MSG
          The key for error message.
static java.lang.String KEY_ERROR_MSG_PROC
          The key for our processing error message.
static java.lang.String KEY_LOCATION
          The key for raw error location data.
static java.lang.String KEY_ORDER_ID
          The key for the order id that the command is applied to.
static java.lang.String KEY_REF_CODE
          The key for the Retrieval reference number.
static java.lang.String KEY_STATUS
          The key for raw status data.
static java.lang.String KEY_TOTAL
           
static java.lang.String KEY_TRANS_TYPE
          The key for the type of transaction.
static java.lang.String KEY_TRANSACTION_ID
          The key for the transaction id from the CyberCash gateway.
 java.lang.String mCc3ConfigFile
          Configuration file containing name=value pair info
static java.lang.String mResourceBundle
           
 atg.payment.Message msg
           
static java.lang.String TRANSACTION_CAPTURE
          A value for KEY_TRANS_TYPE.
static java.lang.String TRANSACTION_MARKED
          A value for KEY_TRANS_TYPE; for terminal capture
static java.lang.String TRANSACTION_MARKRET
          A value for KEY_TRANS_TYPE; for terminal capture
static java.lang.String TRANSACTION_RETURN
          A value for KEY_TRANS_TYPE; for host capture
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
CyberCashConnection()
          Constructs a null CyberCashConnection.
 
Method Summary
 CreditCardStatus authorize(CreditCardInfo ccinfo)
          Authorize the amount on the credit card
 float convertToUSD(float pAmount, java.lang.String pCurrency)
          This function is used to convert from non USD currency to USD currency.
 CreditCardStatus credit(CreditCardInfo ccinfo)
          Credit when no previous debit exists (a new order)
 CreditCardStatus credit(CreditCardInfo ccinfo, CreditCardStatus pStatus)
          Credit after the capture (debit) was processed
 CreditCardStatus debit(CreditCardInfo ccinfo, CreditCardStatus pStatus)
          Capture the amount after the authorization was processed
 CreditCardStatus decreaseAuthorization(CreditCardInfo pCreditCardInfo, PaymentStatus pAuthStatus)
          Decreases the authorized amount for the credit card.
 void doStartService()
          Initialize data structures when service is started.
 java.lang.String getCc3ConfigFile()
          Gets configuration file name.
static void main(java.lang.String[] args)
           
 CreditCardStatus performAuthORCredit(CreditCardInfo ccinfo, java.lang.String pCommand)
          Implements the functionality to CreditCardProcessor Interface This wraps a call to sendCommand with an authorize or credit command.
 CreditCardStatus performDebitORCredit(CreditCardInfo ccinfo, java.lang.String pCommand)
          Implements the functionality to CreditCardProcessor Interface This wraps a call to sendCommand with a capture or return.
 CyberCashStatus processError(java.lang.String pKey, java.lang.String pMessage, double totald)
           
protected  CreditCardStatus sendCommand(java.lang.String pCommand, java.util.Dictionary pParams, double totald)
          This is the primary interface to CyberCash CashRegister.
 void setCc3ConfigFile(java.lang.String pCc3ConfigFile)
          Sets configuration file name.
 java.lang.String toString()
           
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values

KEY_STATUS

public static final java.lang.String KEY_STATUS
The key for raw status data.

See Also:
Constant Field Values

KEY_LOCATION

public static final java.lang.String KEY_LOCATION
The key for raw error location data.

See Also:
Constant Field Values

KEY_ERROR_MSG

public static final java.lang.String KEY_ERROR_MSG
The key for error message.

See Also:
Constant Field Values

KEY_ERROR_MSG_PROC

public static final java.lang.String KEY_ERROR_MSG_PROC
The key for our processing error message.

See Also:
Constant Field Values

KEY_ERROR_CODE

public static final java.lang.String KEY_ERROR_CODE
The key for error code.

See Also:
Constant Field Values

KEY_TRANSACTION_ID

public static final java.lang.String KEY_TRANSACTION_ID
The key for the transaction id from the CyberCash gateway.

See Also:
Constant Field Values

KEY_AVS_CODE

public static final java.lang.String KEY_AVS_CODE
The key for the avs status code

See Also:
Constant Field Values

KEY_TOTAL

public static final java.lang.String KEY_TOTAL
See Also:
Constant Field Values

KEY_ORDER_ID

public static final java.lang.String KEY_ORDER_ID
The key for the order id that the command is applied to.

See Also:
Constant Field Values

KEY_CC_TYPE

public static final java.lang.String KEY_CC_TYPE
The key for the credit card type.

See Also:
Constant Field Values

KEY_CC_NUMBER

public static final java.lang.String KEY_CC_NUMBER
The key for the credit card number.

See Also:
Constant Field Values

KEY_CC_EXPIRE

public static final java.lang.String KEY_CC_EXPIRE
The key for the credit card expiration date, MM/YY.

See Also:
Constant Field Values

KEY_CC_AMOUNT

public static final java.lang.String KEY_CC_AMOUNT
The amount to apply to the transaction, be it authorize,return... This is of the format ' #####.##'; e.g. 'usd 145.00' is 145 us dollars.

See Also:
Constant Field Values

KEY_CC_NAME

public static final java.lang.String KEY_CC_NAME
The key for the name on the credit card billing address.

See Also:
Constant Field Values

KEY_CC_ADDRESS

public static final java.lang.String KEY_CC_ADDRESS
The key for the address on the credit card, everything not city, state, zip, country, or name.

See Also:
Constant Field Values

KEY_CC_CITY

public static final java.lang.String KEY_CC_CITY
The key for the city on the credit card billing address.

See Also:
Constant Field Values

KEY_CC_ZIP

public static final java.lang.String KEY_CC_ZIP
The key for the zip on the credit card billing address.

See Also:
Constant Field Values

KEY_CC_STATE

public static final java.lang.String KEY_CC_STATE
The key for the state on the credit card billing address.

See Also:
Constant Field Values

KEY_CC_COUNTRY

public static final java.lang.String KEY_CC_COUNTRY
The key for the country on the credit card billing address.

See Also:
Constant Field Values

KEY_CC_AUTH_CODE

public static final java.lang.String KEY_CC_AUTH_CODE
The key for the credit card authorization code.

See Also:
Constant Field Values

KEY_CC_ACT_CODE

public static final java.lang.String KEY_CC_ACT_CODE
The key for the credit card action code.

See Also:
Constant Field Values

KEY_REF_CODE

public static final java.lang.String KEY_REF_CODE
The key for the Retrieval reference number.

See Also:
Constant Field Values

KEY_CASH_AMOUNT

public static final java.lang.String KEY_CASH_AMOUNT
The key for the amount of money to apply this transaction to.

See Also:
Constant Field Values

KEY_TRANS_TYPE

public static final java.lang.String KEY_TRANS_TYPE
The key for the type of transaction. This is used with void and query since order-id may not be enough to uniquly id a transaction.

See Also:
Constant Field Values

TRANSACTION_CAPTURE

public static final java.lang.String TRANSACTION_CAPTURE
A value for KEY_TRANS_TYPE.

See Also:
Constant Field Values

TRANSACTION_MARKED

public static final java.lang.String TRANSACTION_MARKED
A value for KEY_TRANS_TYPE; for terminal capture

See Also:
Constant Field Values

TRANSACTION_RETURN

public static final java.lang.String TRANSACTION_RETURN
A value for KEY_TRANS_TYPE; for host capture

See Also:
Constant Field Values

TRANSACTION_MARKRET

public static final java.lang.String TRANSACTION_MARKRET
A value for KEY_TRANS_TYPE; for terminal capture

See Also:
Constant Field Values

CMD_AUTHORIZE

public static final java.lang.String CMD_AUTHORIZE
Authorize a credit card, does not charge.

See Also:
Constant Field Values

CMD_AUTH_CAPTURE

public static final java.lang.String CMD_AUTH_CAPTURE
Authorize and charge a credit card.

See Also:
Constant Field Values

CMD_CAPTURE

public static final java.lang.String CMD_CAPTURE
Charge a credit card that has been authorized.

See Also:
Constant Field Values

CMD_VOID

public static final java.lang.String CMD_VOID
Void any transaction.

See Also:
Constant Field Values

CMD_RETURN

public static final java.lang.String CMD_RETURN
Return money to a card holder that has been charged.

See Also:
Constant Field Values

CMD_QUERY

public static final java.lang.String CMD_QUERY
Check the local state of an order, this is only useful to see if/how a transaction completed.

See Also:
Constant Field Values

CMD_RETRY

public static final java.lang.String CMD_RETRY
Retry a transaction that is in the pending state, as indeicated in query.

See Also:
Constant Field Values

CURRENCY_US_DOLLARS

public static final java.lang.String CURRENCY_US_DOLLARS
United States Dollars.

See Also:
Constant Field Values

INITIAL_REQUEST_SIZE

public static final int INITIAL_REQUEST_SIZE
A guess at how big a request buffer needs to be, reduces StringBuffers resizings, hopefully.

See Also:
Constant Field Values

mResourceBundle

public static java.lang.String mResourceBundle

msg

public atg.payment.Message msg

mCc3ConfigFile

public java.lang.String mCc3ConfigFile
Configuration file containing name=value pair info

Constructor Detail

CyberCashConnection

public CyberCashConnection()
Constructs a null CyberCashConnection.

Method Detail

setCc3ConfigFile

public void setCc3ConfigFile(java.lang.String pCc3ConfigFile)
Sets configuration file name. Configuration file comes from a successful installation of CyberCash 3 Merchant Connection Kit. It contains all information pertaining to communicating with CyberCash CashRegister.


getCc3ConfigFile

public java.lang.String getCc3ConfigFile()
Gets configuration file name.


convertToUSD

public float convertToUSD(float pAmount,
                          java.lang.String pCurrency)
This function is used to convert from non USD currency to USD currency. This is needed if DCS is running in a non-USD currency and using a non-USD locale.

Parameters:
pAmount - The amount of the order.
pCurrency - The currency code of the order.
Returns:
The amount converted to USD representation. This currently returns what was passed in.

This currently is a dummy call, which returns what is passed in. The user needs to override this.


credit

public CreditCardStatus credit(CreditCardInfo ccinfo,
                               CreditCardStatus pStatus)
Credit after the capture (debit) was processed

Specified by:
credit in interface CreditCardProcessor
Parameters:
ccinfo - The credit card data and customer information
pStatus - The status object from a previous billing call
Returns:
The status object with the results of this request

credit

public CreditCardStatus credit(CreditCardInfo ccinfo)
Credit when no previous debit exists (a new order)

Specified by:
credit in interface CreditCardProcessor
Parameters:
ccinfo - The credit card data and customer information
Returns:
The status object with the results of this request

debit

public CreditCardStatus debit(CreditCardInfo ccinfo,
                              CreditCardStatus pStatus)
Capture the amount after the authorization was processed

Specified by:
debit in interface CreditCardProcessor
Parameters:
ccinfo - The credit card data and customer information
pStatus - The status object from a previous authorization call
Returns:
The status object with the results of this request

authorize

public CreditCardStatus authorize(CreditCardInfo ccinfo)
Authorize the amount on the credit card

Specified by:
authorize in interface CreditCardProcessor
Parameters:
ccinfo - The credit card data and customer information
Returns:
The status object with the results of this request

performAuthORCredit

public CreditCardStatus performAuthORCredit(CreditCardInfo ccinfo,
                                            java.lang.String pCommand)
                                     throws CyberCashException
Implements the functionality to CreditCardProcessor Interface This wraps a call to sendCommand with an authorize or credit command. This differs from credit below in that the orderID cannot exist and a new order is created for the return. Use this to credit someone if their order is no longer in the DB. All the below parameters extracted from the CreditCardInfo object

Parameters:
pPaymentId - Arbitrary string associated with order.(REQUIRED)
pAmount - Amount of money to authorize or credit(REQUIRED)
pCardNumber - Credit card to operate on.(REQUIRED)
pExpires - When card expires, time and day are ignored.(REQUIRED)
pCurrency - Type of currency, currently usd | cad | frf.(REQUIRED)
pName - Name on CC.(OPTIONAL)
pAddress - Billing address.(OPTIONAL)
pCity - Billing city.(OPTIONAL)
pState - Billing state.(OPTIONAL)
pZip - Billing zip.(OPTIONAL)
pCountry - Billing country(OPTIONAL)
Returns:
A CyberCashStatus object filled with a response status
Throws:
CyberCashException

performDebitORCredit

public CreditCardStatus performDebitORCredit(CreditCardInfo ccinfo,
                                             java.lang.String pCommand)
                                      throws CyberCashException
Implements the functionality to CreditCardProcessor Interface This wraps a call to sendCommand with a capture or return. This return differs from credit above in that an order with the orderID must exist in the DB on the payment server for this to succeed.

NOTE: The entire amount of the charge does not need to be returned.

Parameters:
pPaymentId - The orderid of the order this is a return or debit for.(REQUIRED)
pAmount - Amount of money to debit or credit.(REQUIRED)
pCurrency - Type of currency, currently usd | cad | frf.(REQUIRED)
Returns:
A CyberCashStatus object filled with status returned from the server
Throws:
CyberCashException

sendCommand

protected CreditCardStatus sendCommand(java.lang.String pCommand,
                                       java.util.Dictionary pParams,
                                       double totald)
                                throws CyberCashException
This is the primary interface to CyberCash CashRegister. It is synchronized because it involves JNI calls to CyberCash APIs that are not thread-safe.

Parameters:
pCommand - The CyberCash command to be sent to CashRegister.
pParams - The parameter set to be sent along with the CyberCash command.
Returns:
A set of name-value pairs in a Dictionary object.
Throws:
CyberCashException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a String representation of this object

doStartService

public void doStartService()
                    throws ServiceException
Initialize data structures when service is started.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if something went wrong

processError

public CyberCashStatus processError(java.lang.String pKey,
                                    java.lang.String pMessage,
                                    double totald)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

decreaseAuthorization

public CreditCardStatus decreaseAuthorization(CreditCardInfo pCreditCardInfo,
                                              PaymentStatus pAuthStatus)
Decreases the authorized amount for the credit card.

This implementation does nothing but return a successful CreditCardStatus object.

Extend this method to do any cyber cash credit card specific processing.

Specified by:
decreaseAuthorization in interface atg.payment.creditcard.DecreaseCreditCardAuthorizationProcessor
Parameters:
pCreditCardInfo - the CreditCardInfo reference which contains all the credit data
Returns:
a CreditCardStatus object detailing the results of the decrease