atg.integrations.cybersource
Class CyberSourceCreditCard

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

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

This class manages the communications to a CyberSource payment server.

Currently only credit card transactions are supported, no CyberSource coins or checks.

All information on the CyberSource API was aquired from 19991112_ICS2_DG.pdf version 2.


Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String CMD_AUTHORIZE
           
static java.lang.String CMD_CAPTURE
           
static java.lang.String CMD_RETURN
           
 CyberSourceConnection mCsCon
           
 
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
CyberSourceCreditCard()
           
 
Method Summary
protected  void addAmount(com.cybersource.ics.client.message.ICSClientRequest pRequest, com.cybersource.ics.client.message.ICSClientOffer pOffer, CreditCardInfo pInfo)
          Copy the amount to authorize, debit, or credit from the credit card info into the CyberSource client offer, then add the offer to the request.
protected  void addBillingAddress(com.cybersource.ics.client.message.ICSClientRequest pRequest, CreditCardInfo pInfo)
          Copy the billing address information from the credit card info into the CyberSource client request.
protected  void addContactInfo(com.cybersource.ics.client.message.ICSClientRequest pRequest, CreditCardInfo pInfo)
          Copy the user's first and last name, phone number, and email address from the credit card info's billing address to the CyberSource client request.
protected  void addCreditCardInfo(com.cybersource.ics.client.message.ICSClientRequest pRequest, CreditCardInfo pInfo)
          Copy the credit card number and expiration date from the credit card info info the CyberSource client request.
protected  void addCurrencyCode(com.cybersource.ics.client.message.ICSClientRequest pRequest, CreditCardInfo pInfo)
          Copy the currencyCode from the credit card info into the CyberSource client request.
protected  void addExtendedInfo(com.cybersource.ics.client.message.ICSClientRequest pRequest, com.cybersource.ics.client.message.ICSClientOffer pOffer, CreditCardInfo pInfo, java.lang.String pCommand)
          Copy any additional information required from the credit card info into the CyberSource request or the CyberSource client offer.
protected  void addMerchantId(com.cybersource.ics.client.message.ICSClientRequest pRequest, CreditCardInfo pInfo)
          Copy the merchantId from the CyberSource connection into the client request.
protected  void addPaymentId(com.cybersource.ics.client.message.ICSClientRequest pRequest, CreditCardInfo pInfo)
          Copy the paymentId property from the CreditCardInfo into the client request.
protected  boolean addressRequiresPostalCode(CreditCardInfo pInfo)
          Return true if the billing address in pInfo requires a non-null value for postalCode property.
protected  boolean addressRequiresState(CreditCardInfo pInfo)
          Return true if the billing address in pInfo requires a non-null value for state property.
 CreditCardStatus authorize(CreditCardInfo ccinfo)
          Authorize the amount on the credit card
 CreditCardStatus credit(CreditCardInfo ccinfo)
          Credit the amount on the credit card as a new order
 CreditCardStatus credit(CreditCardInfo ccinfo, CreditCardStatus pStatus)
          Credit the amount on the credit card after debiting.
 CreditCardStatus debit(CreditCardInfo ccinfo, CreditCardStatus pStatus)
          Debit the amount on the credit card after authorization
 CreditCardStatus decreaseAuthorization(CreditCardInfo pCreditCardInfo, PaymentStatus pAuthStatus)
          Decreases the authorized amount for the credit card.
 void doStartService()
          Verify that the Cybersource connection is non-null
 CyberSourceConnection getCsCon()
           
 CreditCardStatus performAuthORCredit(CreditCardInfo ccinfo, java.lang.String pCommand)
          This either authorizes an amount on a credit card which is a required operation before billing or credits an amount on a card as a new order (no record of a previous billing) The following list of properties of the CreditCardInfo are required.
 CreditCardStatus performDebitORCredit(CreditCardInfo ccinfo, java.lang.String pTransId, java.lang.String pCommand)
          Deprecated. Please use performDebitORCredit(CreditCardInfo ccinfo, String pTransId, String pRequestToken, String pCommand) instead.
 CreditCardStatus performDebitORCredit(CreditCardInfo ccinfo, java.lang.String pTransId, java.lang.String pRequestToken, java.lang.String pCommand)
          This performs either billing following an authorize, actually charging a credit card or credit a card following an already issued billing operation
 void setCsCon(CyberSourceConnection pCsCon)
           
 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, 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 java.lang.String CLASS_VERSION

CMD_AUTHORIZE

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

CMD_RETURN

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

CMD_CAPTURE

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

mCsCon

public CyberSourceConnection mCsCon
Constructor Detail

CyberSourceCreditCard

public CyberSourceCreditCard()
Method Detail

setCsCon

public void setCsCon(CyberSourceConnection pCsCon)

getCsCon

public CyberSourceConnection getCsCon()

credit

public CreditCardStatus credit(CreditCardInfo ccinfo,
                               CreditCardStatus pStatus)
Description copied from interface: CreditCardProcessor
Credit the amount on the credit card after debiting.

Specified by:
credit in interface CreditCardProcessor
Parameters:
ccinfo - the CreditCardInfo reference which contains all the credit data
pStatus - the CreditCardStatus object which contains information about the transaction. This should be the object which was returned from debit().
Returns:
a CreditCardStatus object detailing the results of the credit

credit

public CreditCardStatus credit(CreditCardInfo ccinfo)
Description copied from interface: CreditCardProcessor
Credit the amount on the credit card as a new order

Specified by:
credit in interface CreditCardProcessor
Parameters:
ccinfo - the CreditCardInfo reference which contains all the credit data
Returns:
a CreditCardStatus object detailing the results of the credit

debit

public CreditCardStatus debit(CreditCardInfo ccinfo,
                              CreditCardStatus pStatus)
Description copied from interface: CreditCardProcessor
Debit the amount on the credit card after authorization

Specified by:
debit in interface CreditCardProcessor
Parameters:
ccinfo - the CreditCardInfo reference which contains all the debit data
pStatus - the CreditCardStatus object which contains information about the transaction. This should be the object which was returned from authorize().
Returns:
a CreditCardStatus object detailing the results of the debit

authorize

public CreditCardStatus authorize(CreditCardInfo ccinfo)
Description copied from interface: CreditCardProcessor
Authorize the amount on the credit card

Specified by:
authorize in interface CreditCardProcessor
Parameters:
ccinfo - the CreditCardInfo reference which contains all the authorization data
Returns:
a CreditCardStatus object detailing the results of the authorization

performDebitORCredit

public CreditCardStatus performDebitORCredit(CreditCardInfo ccinfo,
                                             java.lang.String pTransId,
                                             java.lang.String pCommand)
                                      throws com.cybersource.ics.base.exception.ICSException
Deprecated. Please use performDebitORCredit(CreditCardInfo ccinfo, String pTransId, String pRequestToken, String pCommand) instead.

This performs either billing following an authorize, actually charging a credit card or credit a card following an already issued billing operation

The below paramaters come from CreditCardInfo

Parameters:
pPaymentId - The orderid of the order this is a return or debit for.(REQUIRED)
pMerchantId - The id that identifies the merchant (comes from the props file)
pAmount - Amount of money to return or debit (REQUIRED)
pCurrency - Type of currency, currently usd | cad | frf.(REQUIRED)
pTransId - The transaction id returned from auth or debit, to be used for debit or credit
Returns:
A CyberSourceResponse object containing results of the call
Throws:
com.cybersource.ics.base.exception.ICSException

performDebitORCredit

public CreditCardStatus performDebitORCredit(CreditCardInfo ccinfo,
                                             java.lang.String pTransId,
                                             java.lang.String pRequestToken,
                                             java.lang.String pCommand)
                                      throws com.cybersource.ics.base.exception.ICSException
This performs either billing following an authorize, actually charging a credit card or credit a card following an already issued billing operation

The below paramaters come from CreditCardInfo

Parameters:
pPaymentId - The orderid of the order this is a return or debit for.(REQUIRED)
pMerchantId - The id that identifies the merchant (comes from the props file)
pAmount - Amount of money to return or debit (REQUIRED)
pCurrency - Type of currency, currently usd | cad | frf.(REQUIRED)
pTransId - The transaction id returned from auth or debit, to be used for debit or credit
pRequestToken - The request token returned from auth or debit, to be used for debit or credit
Returns:
A CyberSourceResponse object containing results of the call
Throws:
com.cybersource.ics.base.exception.ICSException

performAuthORCredit

public CreditCardStatus performAuthORCredit(CreditCardInfo ccinfo,
                                            java.lang.String pCommand)
                                     throws com.cybersource.ics.base.exception.ICSException
This either authorizes an amount on a credit card which is a required operation before billing or credits an amount on a card as a new order (no record of a previous billing) The following list of properties of the CreditCardInfo are required. From the billingAddress object the following properties are required.

Returns:
A CyberSourceResponse.
Throws:
com.cybersource.ics.base.exception.ICSException

doStartService

public void doStartService()
                    throws ServiceException
Verify that the Cybersource connection is non-null

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

toString

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

addPaymentId

protected void addPaymentId(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                            CreditCardInfo pInfo)
                     throws CyberSourceException
Copy the paymentId property from the CreditCardInfo into the client request.

Throws:
CyberSourceException

addMerchantId

protected void addMerchantId(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                             CreditCardInfo pInfo)
                      throws CyberSourceException
Copy the merchantId from the CyberSource connection into the client request. The credit card info is not used by the default implementation of this method, but it is provided as an argument in case subclasses wish to make use of it somehow.

Throws:
CyberSourceException

addCurrencyCode

protected void addCurrencyCode(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                               CreditCardInfo pInfo)
                        throws CyberSourceException
Copy the currencyCode from the credit card info into the CyberSource client request.

Throws:
CyberSourceException

addBillingAddress

protected void addBillingAddress(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                                 CreditCardInfo pInfo)
                          throws CyberSourceException
Copy the billing address information from the credit card info into the CyberSource client request. This method assumes that if the billing country is not specified a default value of "US" should be used. It also checks to see whether the billing address in the credit card info requires a state and postal code to be specified. The logic for determining this can be changed by subclassing this class and overriding the addressRequiresState and addressRequiresPostalCode methods in the subclass.

Throws:
CyberSourceException

addContactInfo

protected void addContactInfo(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                              CreditCardInfo pInfo)
                       throws CyberSourceException
Copy the user's first and last name, phone number, and email address from the credit card info's billing address to the CyberSource client request. The phone number and email address are copied only if the billing address is an instance of ContactInfo rather than a simple Address.

Throws:
CyberSourceException

addCreditCardInfo

protected void addCreditCardInfo(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                                 CreditCardInfo pInfo)
                          throws CyberSourceException
Copy the credit card number and expiration date from the credit card info info the CyberSource client request.

Throws:
CyberSourceException

addAmount

protected void addAmount(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                         com.cybersource.ics.client.message.ICSClientOffer pOffer,
                         CreditCardInfo pInfo)
                  throws CyberSourceException
Copy the amount to authorize, debit, or credit from the credit card info into the CyberSource client offer, then add the offer to the request.

Throws:
CyberSourceException

addExtendedInfo

protected void addExtendedInfo(com.cybersource.ics.client.message.ICSClientRequest pRequest,
                               com.cybersource.ics.client.message.ICSClientOffer pOffer,
                               CreditCardInfo pInfo,
                               java.lang.String pCommand)
                        throws CyberSourceException
Copy any additional information required from the credit card info into the CyberSource request or the CyberSource client offer. By default this method does nothing. Subclasses that need to propagate additional information from ATG Commerce to CyberSource can override this method to augment the request or offer objects before the request is sent to CyberSource.

pCommand> will be set to CMD_AUTHORIZE, CMD_CAPTURE, or CMD_RETURN depending on the operation being performed. Subclasses can test this value if they have to add different extended information to the request for different operations.

Throws:
CyberSourceException

addressRequiresState

protected boolean addressRequiresState(CreditCardInfo pInfo)
Return true if the billing address in pInfo requires a non-null value for state property. By default this returns true if the billing address's country is US or CA, and false otherwise.


addressRequiresPostalCode

protected boolean addressRequiresPostalCode(CreditCardInfo pInfo)
Return true if the billing address in pInfo requires a non-null value for postalCode property. By default this returns true if the billing address's country is US or CA, and false otherwise.


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 source 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