atg.commerce.payment
Class PaymentManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.payment.PaymentManager
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class PaymentManager
extends GenericService

This class provides a set of methods for dealing with operations on PaymentGroups. All PaymentGroups have three types of operations which can be executed on them, authorize, debit, and credit. This class provides three methods that do each of these operations on any class which implements PaymentGroup. That is, there are authorize, credit and debit methods in this class. This class uses a pluggable configuration to allow for the ability to easily add new PaymentGroup types. There is a map that is maintained that maps between PaymentGroups and pipeline chain names. When any of the authorize, credit or debit methods are called a pipeline chain is obtained for the particular PaymentGroup and executed. So, to add a new PaymentGroup type all that should have to happen is to create a new PipelineChain where the processors of the pipelinechain know how to perform an authorize, credit or debit. Then, make an entry for this PaymentGroup to chainName mapping in the PaymentGroupToChainNameMap property. This class should not have to be overriden to add new PaymentGroup types. The methods which take a List of PaymentGroups do not need to be overridden because they just iterate over the list calling the same method as itself passing each PaymentGroup object.


Field Summary
protected static int AUTH
           
static java.lang.String CLASS_VERSION
           
protected static int CREDIT
           
protected static int DEBIT
           
protected static int DECREASE_AUTH
           
 
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
PaymentManager()
           
 
Method Summary
 java.util.List authorize(Order pOrder, java.util.List pPaymentGroups)
          This method authorizes payment for the given PaymentGroups.
 void authorize(Order pOrder, PaymentGroup pPaymentGroup)
          This method authorizes payment of the whole PaymentGroup.
 void authorize(Order pOrder, PaymentGroup pPaymentGroup, double pAmount)
          This method performs three steps.
protected  PaymentStatus authorizeCreditCard(Order pOrder, CreditCard pPaymentGroup, double pAmount)
          Deprecated. use pipeline based authorization instead of methods directly in this class
protected  PaymentStatus authorizeGiftCertificate(Order pOrder, GiftCertificate pPaymentGroup, double pAmount)
          Deprecated. use pipeline based authorization instead of methods directly in this class
protected  PaymentStatus authorizeStoreCredit(Order pOrder, StoreCredit pPaymentGroup, double pAmount)
          Deprecated. use pipeline based authorization instead of methods directly in this class
protected  void createErrorPaymentStatus(int pListType, PaymentGroup pPaymentGroup, double pAmount, java.lang.String pErrorMessage)
          This method creates a PaymentStatusImpl object and adds it to the appropriate status list within the given PaymentGroup.
protected  void createIgnorePaymentStatus(int pListType, PaymentGroup pPaymentGroup, double pAmount)
          This method creates a PaymentStatusImpl object and adds it to the appropriate status list within the given PaymentGroup.
 java.util.List credit(Order pOrder, java.util.List pPaymentGroups)
          This method credits payment for the given PaymentGroups.
 void credit(Order pOrder, PaymentGroup pPaymentGroup)
          This method credits payment of the whole PaymentGroup.
 void credit(Order pOrder, PaymentGroup pPaymentGroup, double pAmount)
          This method performs three steps.
 CreditCardStatus creditCreditCard(CreditCardInfo pCreditCardInfo)
          Deprecated. use pipeline based debit instead of methods directly in this class
protected  PaymentStatus creditCreditCard(Order pOrder, CreditCard pPaymentGroup, double pAmount)
          Deprecated. use pipeline based credit instead of methods directly in this class
 GiftCertificateStatus creditGiftCertificate(GiftCertificateInfo pGiftCertificateInfo)
          Deprecated. use pipeline based credit instead of methods directly in this class
protected  PaymentStatus creditGiftCertificate(Order pOrder, GiftCertificate pPaymentGroup, double pAmount)
          Deprecated. use pipeline based credit instead of methods directly in this class
protected  PaymentStatus creditStoreCredit(Order pOrder, StoreCredit pPaymentGroup, double pAmount)
          Deprecated. use pipeline based credit instead of methods directly in this class
 StoreCreditStatus creditStoreCredit(StoreCreditInfo pStoreCreditInfo)
          Deprecated. use pipeline based credit instead of methods directly in this class
 java.util.List debit(Order pOrder, java.util.List pPaymentGroups)
          This method debits payment for the given PaymentGroups.
 PipelineResult debit(Order pOrder, PaymentGroup pPaymentGroup)
          This method debits the entire amount of the pPaymentGroup.
 PipelineResult debit(Order pOrder, PaymentGroup pPaymentGroup, double pAmount)
          This method performs three steps.
protected  PaymentStatus debitCreditCard(Order pOrder, CreditCard pPaymentGroup, double pAmount)
          Deprecated. use pipeline based debit instead of methods directly in this class
protected  PaymentStatus debitGiftCertificate(Order pOrder, GiftCertificate pPaymentGroup, double pAmount)
          Deprecated. use pipeline based debit instead of methods directly in this class
protected  PaymentStatus debitStoreCredit(Order pOrder, StoreCredit pPaymentGroup, double pAmount)
          Deprecated. use pipeline based debit instead of methods directly in this class
 void decreaseAuthorization(Order pOrder, PaymentGroup pPaymentGroup, double pDecreaseAmount)
           
 void expireGiftCertificateAuthorization(Order pOrder, GiftCertificate pPaymentGroup, double pAmount)
          This method expires authorization for a given gift certificate PaymentGroup for the amount that is passed in.
 void expireStoreCreditAuthorization(Order pOrder, StoreCredit pPaymentGroup, double pAmount)
          This method expires authorization for a given StoreCredit PaymentGroup for the amount that is passed in.
protected  java.lang.String getAuthorizationChainName(PaymentGroup pPaymentGroup)
          Obtain a pipeline chain that can authorize the pPaymentGroup.
protected  java.lang.String getChainName(PaymentGroup pPaymentGroup)
          This method provides a mechanism by which to obtain a PipelineChain name from a given payment group.
 CreditCardProcessor getCreditCardProcessor()
          Returns the creditCardProcessor
protected  java.lang.String getCreditChainName(PaymentGroup pPaymentGroup)
          Obtain a pipeline chain that can credit the pPaymentGroup.
protected  java.lang.String getDebitChainName(PaymentGroup pPaymentGroup)
          Obtain a pipeline chain that can debit the pPaymentGroup.
protected  java.lang.String getDecreaseAuthorizationChainName(PaymentGroup pPaymentGroup)
          Obtain a pipeline chain that can decrease the authroization amount on the pPaymentGroup.
 GiftCertificateProcessor getGiftCertificateProcessor()
          Returns the GiftCertificateProcessor
 boolean getIgnoreTransactionsWithZeroAmount()
          Returns property ignoreTransactionsWithZeroAmount
 PaymentStatus getLastAuthorizationStatus(PaymentGroup pPaymentGroup)
          This method returns the last PaymentStatus object in the authorizationStatus list of the given PaymentGroup
 PaymentStatus getLastDebitStatus(PaymentGroup pPaymentGroup)
          This method returns the last PaymentStatus object in the debitStatus list of the given PaymentGroup
 OrderManager getOrderManager()
          Returns the orderManager
 java.util.Properties getPaymentGroupToChainNameMap()
          Return the PaymentGroupToChainNameMap property.
 PipelineManager getPipelineManager()
          Return the PipelineManager property.
 PricingTools getPricingTools()
          PricingTools is used to round amounts during comparisons.
 StoreCreditProcessor getStoreCreditProcessor()
          Returns property StoreCreditProcessor
 boolean isAmountTooHigh(double pAmountSoFar, double pNewAmount, PaymentGroup pPaymentGroup)
          This method will add pAmountSoFar and pNewAmount.
protected  void postProcessAuthorize(PaymentGroup pPaymentGroup, PaymentStatus pStatus, double pAmount)
          This method executes post processing after an authorize() call to a payment processor.
protected  void postProcessCredit(PaymentGroup pPaymentGroup, PaymentStatus pStatus, double pAmount)
          This method executes post processing after a credit() call to a payment processor.
protected  void postProcessDebit(PaymentGroup pPaymentGroup, PaymentStatus pStatus, double pAmount)
          This method executes post processing after a debit() call to a payment processor.
protected  void postProcessDecreaseAuthorization(PaymentGroup pPaymentGroup, PaymentStatus pStatus, double pDecreaseAmount)
          This method executes post processing after an decreateAuthorize() call to a payment processor.
protected  void preProcessAuthorize(Order pOrder, PaymentGroup pPaymentGroup, double pAmount)
          This method executes pre processing before an authorize() call to a payment processor.
protected  void preProcessCredit(Order pOrder, PaymentGroup pPaymentGroup, double pAmount)
          This method executes pre processing before a credit() call to a payment processor.
protected  void preProcessDebit(Order pOrder, PaymentGroup pPaymentGroup, double pAmount)
          This method executes pre processing before a debit() call to a payment processor.
protected  void preProcessDecreaseAuthorization(Order pOrder, PaymentGroup pPaymentGroup, double pDecreaseAmount)
          This method executes pre processing before an decreaseAuthorization() call to a payment processor.
protected  PipelineResult runProcessorChain(java.lang.String pChainName, PaymentManagerPipelineArgs pParameters)
          Utility method to run a pipeline chain.
 void setCreditCardProcessor(CreditCardProcessor pCreditCardProcessor)
          Sets the creditCardProcessor
 void setGiftCertificateProcessor(GiftCertificateProcessor pGiftCertificateProcessor)
          Sets the GiftCertificateProcessor
 void setIgnoreTransactionsWithZeroAmount(boolean pIgnoreTransactionsWithZeroAmount)
          Sets property ignoreTransactionsWithZeroAmount
 void setOrderManager(OrderManager pOrderManager)
          Sets the orderManager
 void setPaymentGroupToChainNameMap(java.util.Properties pPaymentGroupToChainNameMap)
          Set the PaymentGroupToChainNameMap property.
 void setPipelineManager(PipelineManager pPipelineManager)
          Set the PipelineManager property.
 void setPricingTools(PricingTools pPricingTools)
           
 void setStoreCreditProcessor(StoreCreditProcessor pStoreCreditProcessor)
          Sets property StoreCreditProcessor
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, 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, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

AUTH

protected static final int AUTH
See Also:
Constant Field Values

DEBIT

protected static final int DEBIT
See Also:
Constant Field Values

CREDIT

protected static final int CREDIT
See Also:
Constant Field Values

DECREASE_AUTH

protected static final int DECREASE_AUTH
See Also:
Constant Field Values
Constructor Detail

PaymentManager

public PaymentManager()
Method Detail

getPipelineManager

public PipelineManager getPipelineManager()
Return the PipelineManager property.

Returns:
the PipelineManager

setPipelineManager

public void setPipelineManager(PipelineManager pPipelineManager)
Set the PipelineManager property.

Parameters:
pPipelineManager -

getPaymentGroupToChainNameMap

public java.util.Properties getPaymentGroupToChainNameMap()
Return the PaymentGroupToChainNameMap property.

Returns:
the PaymentGroupToChainNameMap

setPaymentGroupToChainNameMap

public void setPaymentGroupToChainNameMap(java.util.Properties pPaymentGroupToChainNameMap)
Set the PaymentGroupToChainNameMap property.

Parameters:
pPaymentGroupToChainNameMap -

getCreditCardProcessor

public CreditCardProcessor getCreditCardProcessor()
Returns the creditCardProcessor

Returns:
the creditCardProcessor

setCreditCardProcessor

public void setCreditCardProcessor(CreditCardProcessor pCreditCardProcessor)
Sets the creditCardProcessor

Parameters:
pCreditCardProcessor - the creditCardProcessor to set

getGiftCertificateProcessor

public GiftCertificateProcessor getGiftCertificateProcessor()
Returns the GiftCertificateProcessor

Returns:
returns the GiftCertificateProcessor

setGiftCertificateProcessor

public void setGiftCertificateProcessor(GiftCertificateProcessor pGiftCertificateProcessor)
Sets the GiftCertificateProcessor

Parameters:
pGiftCertificateProcessor - the GiftCertificateProcessor to set

getStoreCreditProcessor

public StoreCreditProcessor getStoreCreditProcessor()
Returns property StoreCreditProcessor

Returns:
returns property StoreCreditProcessor

setStoreCreditProcessor

public void setStoreCreditProcessor(StoreCreditProcessor pStoreCreditProcessor)
Sets property StoreCreditProcessor

Parameters:
pStoreCreditProcessor - the value to set for property StoreCreditProcessor

getOrderManager

public OrderManager getOrderManager()
Returns the orderManager

Returns:
returns the orderManager

setOrderManager

public void setOrderManager(OrderManager pOrderManager)
Sets the orderManager

Parameters:
pOrderManager - the OrderManager to set

getIgnoreTransactionsWithZeroAmount

public boolean getIgnoreTransactionsWithZeroAmount()
Returns property ignoreTransactionsWithZeroAmount

Returns:
returns property ignoreTransactionsWithZeroAmount

setIgnoreTransactionsWithZeroAmount

public void setIgnoreTransactionsWithZeroAmount(boolean pIgnoreTransactionsWithZeroAmount)
Sets property ignoreTransactionsWithZeroAmount

Parameters:
pIgnoreTransactionsWithZeroAmount - the value to set for property ignoreTransactionsWithZeroAmount

setPricingTools

public void setPricingTools(PricingTools pPricingTools)

getPricingTools

public PricingTools getPricingTools()
PricingTools is used to round amounts during comparisons.


createErrorPaymentStatus

protected void createErrorPaymentStatus(int pListType,
                                        PaymentGroup pPaymentGroup,
                                        double pAmount,
                                        java.lang.String pErrorMessage)
This method creates a PaymentStatusImpl object and adds it to the appropriate status list within the given PaymentGroup. This is a convenience method for creating status objects when an error occurs.

Parameters:
pPaymentGroup - the PaymentGroup to authorize
Throws:
PaymentException - if an error occured while authorizing or pPaymentGroup is neither a CreditCard or GiftCertificate
See Also:
CreditCardProcessor, GiftCertificateProcessor

createIgnorePaymentStatus

protected void createIgnorePaymentStatus(int pListType,
                                         PaymentGroup pPaymentGroup,
                                         double pAmount)
This method creates a PaymentStatusImpl object and adds it to the appropriate status list within the given PaymentGroup. This is a convenience method for creating status objects when a PaymentGroup is ignored.

Parameters:
pPaymentGroup - the PaymentGroup to authorize
Throws:
PaymentException - if an error occured while authorizing or pPaymentGroup is neither a CreditCard or GiftCertificate
See Also:
CreditCardProcessor, GiftCertificateProcessor

preProcessDecreaseAuthorization

protected void preProcessDecreaseAuthorization(Order pOrder,
                                               PaymentGroup pPaymentGroup,
                                               double pDecreaseAmount)
                                        throws CommerceException
This method executes pre processing before an decreaseAuthorization() call to a payment processor.

Parameters:
pOrder - the Order that the PaymentGroup exists in
pPaymentGroup - the PaymentGroup to be decreased in authorization
pDecreaseAmount - the amount by which the amount is decreasing
Throws:
CommerceException

decreaseAuthorization

public void decreaseAuthorization(Order pOrder,
                                  PaymentGroup pPaymentGroup,
                                  double pDecreaseAmount)
                           throws CommerceException
Throws:
CommerceException

postProcessDecreaseAuthorization

protected void postProcessDecreaseAuthorization(PaymentGroup pPaymentGroup,
                                                PaymentStatus pStatus,
                                                double pDecreaseAmount)
                                         throws CommerceException
This method executes post processing after an decreateAuthorize() call to a payment processor.

Parameters:
pPaymentGroup - the PaymentGroup which was decreased in authroization.
pStatus - the PaymentStatus object returned from the call of the payment processor
pDecreaseAmount - the amount by which the authorization amount is decreasing
Throws:
CommerceException

authorize

public void authorize(Order pOrder,
                      PaymentGroup pPaymentGroup)
               throws CommerceException
This method authorizes payment of the whole PaymentGroup. If pPaymentGroup is a CreditCard, then the authorize method in the creditCardProcessor object which is set is called, if pPaymentGroup is a GiftCertificate, then the authorize method in the giftCertificateProcessor object which is set is called, if pPaymentGroup is a StoreCredit, then the authorize method in the storeCreditProcessor object which is set is called. Override this method to handle other types of PaymentGroups. To determine if the authorization succeeded or failed, retrieve the last PaymentStatus object in the authorizationStatus List property of the PaymentGroup and check the transactionSuccess and errorMessage properties.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup to authorize
Throws:
PaymentException - if an error occured while authorizing or pPaymentGroup is neither a CreditCard or GiftCertificate
CommerceException
See Also:
CreditCardProcessor, GiftCertificateProcessor, StoreCreditProcessor

authorize

public void authorize(Order pOrder,
                      PaymentGroup pPaymentGroup,
                      double pAmount)
               throws CommerceException
This method performs three steps. It first calls the preProcessAuthorize method to perform any pre-processing. Next, it actually performs an authorization by calling a pipeline chain. The name of the chain to execute is determined by calling the getAuthorizationChainName method. The following entries are added to the Map of parameters handed to the pipeline chain Finally, the postProcessAuthorize method is called.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup to authorize
pAmount - the amount to authorize
Throws:
PaymentException - if an error occured while authorizing
CommerceException
See Also:
CreditCardProcessor, GiftCertificateProcessor, StoreCreditProcessor

authorize

public java.util.List authorize(Order pOrder,
                                java.util.List pPaymentGroups)
                         throws CommerceException
This method authorizes payment for the given PaymentGroups. It iterates over the List calling the authorize(PaymentGroup) method in this class. The caller needs to check whether the returned List contains any ids which specify the PaymentGroups which failed authorization. Details of the failure can be found in authorizationStatus property of the PaymentGroup object.

Parameters:
pOrder - the Order which contains the PaymentGroups
pPaymentGroups - a list of PaymentGroups to authorize
Returns:
the list of PaymentGroup ids which failed to be authorized or an empty List if there were no failures
Throws:
InvalidParameterException - if pPaymentGroups is null
CommerceException
See Also:
authorize(Order, PaymentGroup)

debit

public PipelineResult debit(Order pOrder,
                            PaymentGroup pPaymentGroup)
                     throws CommerceException
This method debits the entire amount of the pPaymentGroup. This is done by calling the debit method that takes an additional amount parameter and handing it pPaymentGroup.getAmount(). To determine if the debit succeeded or failed, retrieve the last PaymentStatus object in the debitStatus List property of the PaymentGroup and check the transactionSuccess and errorMessage properties.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup to debit
Throws:
PaymentException - if an error occured while debiting or pPaymentGroup is neither a CreditCard or GiftCertificate
CommerceException
See Also:
CreditCardProcessor, GiftCertificateProcessor, StoreCreditProcessor

debit

public PipelineResult debit(Order pOrder,
                            PaymentGroup pPaymentGroup,
                            double pAmount)
                     throws CommerceException
This method performs three steps. It first calls the preProcessDebit method to perform any pre-processing. Next, it actually performs a debit by calling a pipeline chain. The name of the chain to execute is determined by calling the getDebitChainName method. The following entries are added to the Map of parameters handed to the pipeline chain Finally, the postProcessDebit method is called. To determine if the debit succeeded or failed, retrieve the last PaymentStatus object in the debitStatus List property of the PaymentGroup and check the transactionSuccess and errorMessage properties.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup to debit
Throws:
PaymentException - if an error occured while debiting
CommerceException
See Also:
CreditCardProcessor, GiftCertificateProcessor, StoreCreditProcessor

debit

public java.util.List debit(Order pOrder,
                            java.util.List pPaymentGroups)
                     throws CommerceException
This method debits payment for the given PaymentGroups. It iterates over the List calling the debit(PaymentGroup) method in this class. The caller needs to check whether the returned List contains any ids which specify the PaymentGroups which failed debiting. Details of the failure can be found in debitStatus property of the PaymentGroup object.

Parameters:
pOrder - the Order which contains the PaymentGroups
pPaymentGroups - a list of PaymentGroups to debit
Returns:
the list of PaymentGroup ids which failed to be debited or an empty List if there were no failures
Throws:
InvalidParameterException - if pPaymentGroups is null
CommerceException
See Also:
debit(Order, PaymentGroup)

credit

public void credit(Order pOrder,
                   PaymentGroup pPaymentGroup)
            throws CommerceException
This method credits payment of the whole PaymentGroup. When this method is called the amount in the PaymentGroup is credited to the user's account. This is done by calling the credit method that takes an amount parameter. This amount is obtained from the pPaymentGroup. To determine if the credit succeeded or failed, retrieve the last PaymentStatus object in the creditStatus List property of the PaymentGroup and check the transactionSuccess and errorMessage properties.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup to credit
Throws:
PaymentException - if an error occured while crediting or pPaymentGroup is neither a CreditCard or GiftCertificate
CommerceException
See Also:
CreditCardProcessor, GiftCertificateProcessor, StoreCreditProcessor

credit

public void credit(Order pOrder,
                   PaymentGroup pPaymentGroup,
                   double pAmount)
            throws CommerceException
This method performs three steps. It first calls the preProcessCredit method to perform any pre-processing. Next, it actually performs a credit by calling a pipeline chain. The name of the chain to execute is determined by calling the getCreditChainName method. The following entries are added to the Map of parameters handed to the pipeline chain Finally, the postProcessCredit method is called. To determine if the credit succeeded or failed, retrieve the last PaymentStatus object in the creditStatus List property of the PaymentGroup and check the transactionSuccess and errorMessage properties.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup to credit
pAmount - the amount to credit to this PaymentGroup
Throws:
PaymentException - if an error occured while crediting or pPaymentGroup is neither a CreditCard or GiftCertificate
CommerceException
See Also:
CreditCardProcessor, GiftCertificateProcessor, StoreCreditProcessor

credit

public java.util.List credit(Order pOrder,
                             java.util.List pPaymentGroups)
                      throws CommerceException
This method credits payment for the given PaymentGroups. It iterates over the List calling the credit(PaymentGroup) method in this class. The caller needs to check whether the returned List contains any ids which specify the PaymentGroups which failed crediting. Details of the failure can be found in creditStatus property of the PaymentGroup object.

Parameters:
pOrder - the Order which contains the PaymentGroups
pPaymentGroups - a list of PaymentGroups to credit
Returns:
the list of PaymentGroup ids which failed to be credited or an empty List if there were no failures
Throws:
InvalidParameterException - if pPaymentGroups is null
CommerceException
See Also:
credit(Order, PaymentGroup)

authorizeCreditCard

protected PaymentStatus authorizeCreditCard(Order pOrder,
                                            CreditCard pPaymentGroup,
                                            double pAmount)
                                     throws CommerceException
Deprecated. use pipeline based authorization instead of methods directly in this class

This method authorizes payment for a given credit card PaymentGroup for the amount that is passed in.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the credit card PaymentGroup on which to authorize
pAmount - the amount to be authorized on the PaymentGroup
Throws:
PaymentException - if an error occured while authorizing or pPaymentGroup is neither a CreditCard or GiftCertificate.
CommerceException

authorizeGiftCertificate

protected PaymentStatus authorizeGiftCertificate(Order pOrder,
                                                 GiftCertificate pPaymentGroup,
                                                 double pAmount)
                                          throws CommerceException
Deprecated. use pipeline based authorization instead of methods directly in this class

This method authorizes payment for a given gift certificate PaymentGroup for the amount that is passed in.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the gift certificate PaymentGroup on which to authorize
pAmount - the amount to be authorized on the PaymentGroup
Throws:
PaymentException - if an error occured while authorizing or pPaymentGroup is not a GiftCertificate.
CommerceException

authorizeStoreCredit

protected PaymentStatus authorizeStoreCredit(Order pOrder,
                                             StoreCredit pPaymentGroup,
                                             double pAmount)
                                      throws CommerceException
Deprecated. use pipeline based authorization instead of methods directly in this class

This method authorizes payment for a given StoreCredit PaymentGroup for the amount that is passed in.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the StoreCredit PaymentGroup on which to authorize
pAmount - the amount to be authorized on the PaymentGroup
Throws:
PaymentException - if an error occured while authorizing or pPaymentGroup is not a StoreCredit.
CommerceException

expireGiftCertificateAuthorization

public void expireGiftCertificateAuthorization(Order pOrder,
                                               GiftCertificate pPaymentGroup,
                                               double pAmount)
                                        throws CommerceException
This method expires authorization for a given gift certificate PaymentGroup for the amount that is passed in.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the gift certificate PaymentGroup on which to expire authorization
pAmount - the amount to be expired on the PaymentGroup
Throws:
PaymentException - if an error occured while expiring the authorization or pPaymentGroup is not a GiftCertificate.
CommerceException

expireStoreCreditAuthorization

public void expireStoreCreditAuthorization(Order pOrder,
                                           StoreCredit pPaymentGroup,
                                           double pAmount)
                                    throws CommerceException
This method expires authorization for a given StoreCredit PaymentGroup for the amount that is passed in.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the StoreCredit PaymentGroup on which to expire authorization
pAmount - the amount to be expired on the PaymentGroup
Throws:
PaymentException - if an error occured while expiring the authorization or pPaymentGroup is not a StoreCredit.
CommerceException

debitCreditCard

protected PaymentStatus debitCreditCard(Order pOrder,
                                        CreditCard pPaymentGroup,
                                        double pAmount)
                                 throws CommerceException
Deprecated. use pipeline based debit instead of methods directly in this class

This method will debit a credit card for the amount that is passed into pAmount.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup against which we are debitting
pAmount - the amount to debit the PaymentGroup
Throws:
PaymentException - if an error occured while debiting or if the pPaymentGroup passed in is invalid.
CommerceException

debitGiftCertificate

protected PaymentStatus debitGiftCertificate(Order pOrder,
                                             GiftCertificate pPaymentGroup,
                                             double pAmount)
                                      throws CommerceException
Deprecated. use pipeline based debit instead of methods directly in this class

This method will debit a gift certificate for the amount that is passed into pAmount.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup against which we are debitting
pAmount - the amount to debit the PaymentGroup
Throws:
PaymentException - if an error occured while debiting or if the pPaymentGroup passed in is invalid.
CommerceException

debitStoreCredit

protected PaymentStatus debitStoreCredit(Order pOrder,
                                         StoreCredit pPaymentGroup,
                                         double pAmount)
                                  throws CommerceException
Deprecated. use pipeline based debit instead of methods directly in this class

This method will debit a StoreCredit for the amount that is passed into pAmount.

Parameters:
pOrder - the Order which contains the PaymentGroup
pPaymentGroup - the PaymentGroup against which we are debiting
pAmount - the amount to debit the PaymentGroup
Throws:
PaymentException - if an error occured while debiting or if the pPaymentGroup passed in is invalid.
CommerceException

creditCreditCard

protected PaymentStatus creditCreditCard(Order pOrder,
                                         CreditCard pPaymentGroup,
                                         double pAmount)
                                  throws CommerceException
Deprecated. use pipeline based credit instead of methods directly in this class

Credits a credit card a set amount. This method allows the user to specify whether a credit card can be credited against if it has not been debited by setting the @see #isDenyCreditWithNoDebit property.

Parameters:
pOrder - - the order that contains the PaymentGroup
pPaymentGroup - - the credit card payment group that should be credited
pAmount - - the amount that the payment group should be credited
Throws:
CommerceException

creditCreditCard

public CreditCardStatus creditCreditCard(CreditCardInfo pCreditCardInfo)
Deprecated. use pipeline based debit instead of methods directly in this class

Credits a credit card a set amount. This method runs independent of an Order.

Parameters:
pCreditCardInfo - - the information which is passed to the credit card processor
Returns:
a CreditCardStatus object containing the results of the transaction

creditGiftCertificate

protected PaymentStatus creditGiftCertificate(Order pOrder,
                                              GiftCertificate pPaymentGroup,
                                              double pAmount)
                                       throws CommerceException
Deprecated. use pipeline based credit instead of methods directly in this class

Credits a gift certificate a set amount.

Parameters:
pOrder - - the order that contains the PaymentGroup
pPaymentGroup - - the gift certificate payment group that should be credited
pAmount - - the amount that the payment group should be credited
Throws:
CommerceException

creditStoreCredit

protected PaymentStatus creditStoreCredit(Order pOrder,
                                          StoreCredit pPaymentGroup,
                                          double pAmount)
                                   throws CommerceException
Deprecated. use pipeline based credit instead of methods directly in this class

Credits a StoreCredit a set amount.

Parameters:
pOrder - - the order that contains the PaymentGroup
pPaymentGroup - - the StoreCredit payment group that should be credited
pAmount - - the amount that the payment group should be credited
Throws:
CommerceException

creditGiftCertificate

public GiftCertificateStatus creditGiftCertificate(GiftCertificateInfo pGiftCertificateInfo)
Deprecated. use pipeline based credit instead of methods directly in this class

Credits a gift certificate a set amount. This method runs independent of an Order.

Parameters:
pGiftCertificateInfo - - the information which is passed to the gift certificate processor
Returns:
a GiftCertificateStatus object containing the results of the transaction

creditStoreCredit

public StoreCreditStatus creditStoreCredit(StoreCreditInfo pStoreCreditInfo)
Deprecated. use pipeline based credit instead of methods directly in this class

Credits a store credit a set amount. This method runs independent of an Order.

Parameters:
pStoreCreditInfo - - the information which is passed to the StoreCredit processor
Returns:
a StoreCreditStatus object containing the results of the transaction

preProcessAuthorize

protected void preProcessAuthorize(Order pOrder,
                                   PaymentGroup pPaymentGroup,
                                   double pAmount)
                            throws CommerceException
This method executes pre processing before an authorize() call to a payment processor.

Parameters:
pOrder - the Order that the PaymentGroup exists in
pPaymentGroup - the PaymentGroup to be authorized
pAmount - the amount of the transaction
Throws:
CommerceException

postProcessAuthorize

protected void postProcessAuthorize(PaymentGroup pPaymentGroup,
                                    PaymentStatus pStatus,
                                    double pAmount)
                             throws CommerceException
This method executes post processing after an authorize() call to a payment processor.

Parameters:
pPaymentGroup - the PaymentGroup which was authorized
pStatus - the PaymentStatus object returned from the authorize call of the payment processor
pAmount - the amount of the transaction
Throws:
CommerceException

preProcessDebit

protected void preProcessDebit(Order pOrder,
                               PaymentGroup pPaymentGroup,
                               double pAmount)
                        throws CommerceException
This method executes pre processing before a debit() call to a payment processor.

Parameters:
pOrder - the Order that the PaymentGroup exists in
pPaymentGroup - the PaymentGroup to be debited
pAmount - the amount of the transaction
Throws:
CommerceException

postProcessDebit

protected void postProcessDebit(PaymentGroup pPaymentGroup,
                                PaymentStatus pStatus,
                                double pAmount)
                         throws CommerceException
This method executes post processing after a debit() call to a payment processor.

Parameters:
pPaymentGroup - the PaymentGroup which was debited
pStatus - the PaymentStatus object returned from the debit call of the payment processor
pAmount - the amount of the transaction
Throws:
CommerceException

preProcessCredit

protected void preProcessCredit(Order pOrder,
                                PaymentGroup pPaymentGroup,
                                double pAmount)
                         throws CommerceException
This method executes pre processing before a credit() call to a payment processor.

Parameters:
pOrder - the Order that the PaymentGroup exists in
pPaymentGroup - the PaymentGroup to be credited
pAmount - the amount of the transaction
Throws:
CommerceException

postProcessCredit

protected void postProcessCredit(PaymentGroup pPaymentGroup,
                                 PaymentStatus pStatus,
                                 double pAmount)
                          throws CommerceException
This method executes post processing after a credit() call to a payment processor.

Parameters:
pPaymentGroup - the PaymentGroup which was credited
pStatus - the PaymentStatus object returned from the credit call of the payment processor
pAmount - the amount of the transaction
Throws:
CommerceException

getLastAuthorizationStatus

public PaymentStatus getLastAuthorizationStatus(PaymentGroup pPaymentGroup)
                                         throws CommerceException
This method returns the last PaymentStatus object in the authorizationStatus list of the given PaymentGroup

Parameters:
pPaymentGroup - the PaymentGroup to get the PaymentStatus from
Throws:
CommerceException

getLastDebitStatus

public PaymentStatus getLastDebitStatus(PaymentGroup pPaymentGroup)
                                 throws CommerceException
This method returns the last PaymentStatus object in the debitStatus list of the given PaymentGroup

Parameters:
pPaymentGroup - the PaymentGroup to get the PaymentStatus from
Throws:
CommerceException

isAmountTooHigh

public boolean isAmountTooHigh(double pAmountSoFar,
                               double pNewAmount,
                               PaymentGroup pPaymentGroup)
This method will add pAmountSoFar and pNewAmount. If the sum is greater than pPaymentGroup.amount, then true is returned. Otherwise false is returned. This is used in preProcessAuthorize, preProcessDebit, preProcessCredit where pAmountSoFar is the amount that has previously been authorized, debited, or credited and pNewAmount is the amount that will soon be authorized, debited, or credited.

Parameters:
pAmountSoFar - The amount that has already been "processed"
pNewAmount - The amount that is going to be "processed" if this method returns false
pPaymentGroup - The payment group that will be modified
Returns:
true if pAmountSoFar + pNewAmount > pPaymentGroup.amount, false otherwise

getChainName

protected java.lang.String getChainName(PaymentGroup pPaymentGroup)
                                 throws CommerceException
This method provides a mechanism by which to obtain a PipelineChain name from a given payment group. This is done by looking up a key in the paymentGroupToChainName map. They key is the class name of the payment group. The resulting value should be the corresponding chain.

Parameters:
pPaymentGroup - the payment group whose pipeline chain is obtained
Returns:
a chain name
Throws:
CommerceException - if pPaymentGroup is null, or no entry in the map could be found for the payment group class.

getAuthorizationChainName

protected java.lang.String getAuthorizationChainName(PaymentGroup pPaymentGroup)
                                              throws CommerceException
Obtain a pipeline chain that can authorize the pPaymentGroup. This implementation is done by calling the getChainName method.

Parameters:
pPaymentGroup - the payment group that the pipeline chain will be obtained for
Returns:
a pipeline chain name
Throws:
CommerceException - if an error occurs

getDebitChainName

protected java.lang.String getDebitChainName(PaymentGroup pPaymentGroup)
                                      throws CommerceException
Obtain a pipeline chain that can debit the pPaymentGroup. This implementation is done by calling the getChainName method.

Parameters:
pPaymentGroup - the payment group that the pipeline chain will be obtained for
Returns:
a pipeline chain name
Throws:
CommerceException - if an error occurs

getDecreaseAuthorizationChainName

protected java.lang.String getDecreaseAuthorizationChainName(PaymentGroup pPaymentGroup)
                                                      throws CommerceException
Obtain a pipeline chain that can decrease the authroization amount on the pPaymentGroup. This implementation is done by calling the getChainName method.

Parameters:
pPaymentGroup - the payment group that the pipeline chain will be obtained for
Returns:
a pipeline chain name
Throws:
CommerceException - if an error occurs

getCreditChainName

protected java.lang.String getCreditChainName(PaymentGroup pPaymentGroup)
                                       throws CommerceException
Obtain a pipeline chain that can credit the pPaymentGroup. This implementation is done by calling the getChainName method.

Parameters:
pPaymentGroup - the payment group that the pipeline chain will be obtained for
Returns:
a pipeline chain name
Throws:
CommerceException - if an error occurs

runProcessorChain

protected PipelineResult runProcessorChain(java.lang.String pChainName,
                                           PaymentManagerPipelineArgs pParameters)
                                    throws CommerceException
Utility method to run a pipeline chain.

Parameters:
pChainName - the name of the chain to run
pParameters - the parameters to hand to the chain
Throws:
CommerceException - if an error occurs