com.ibm.commerce.payment.commands
Class PaymentHelper

java.lang.Object
  |
  +--com.ibm.commerce.payment.commands.PaymentHelper

public class PaymentHelper
extends java.lang.Object

This class defines several helper methods used by the Order Capture subsystem classes.


Field Summary
static java.lang.String COPYRIGHT
          IBM copyright notice field.
 
Constructor Summary
PaymentHelper()
          PaymentHelper default constructor.
 
Method Summary
 boolean checkAccountAndCreditLineAreActive_AB( AccountAccessBean abAccount, CreditLineAccessBean abCreditLine)
          Checks if both the specified Account and CreditLine are active.
 boolean checkAccountAndCreditLineAreActive(java.lang.String sAccountId, java.lang.String sCreditLineId)
          Checks if both the specified Account and CreditLine are active.
 void checkCardExpiryYearAndMonth( TypedProperty requestProperties, java.lang.String errorViewName, CommandContext cmdCtx)
          Checks the cardExpiryMonth and cardExpiryYear parameters if present.
 void checkCardNumberAndBrand( TypedProperty requestProperties, java.lang.String errorViewName, CommandContext cmdCtx)
          Checks the cardNumber and cardBrand parameters if present.
 java.lang.Long checkFromOrdPayMthdIfAllCreditLineAreActive(java.lang.Long nOrderId)
          Checks if the Account & Creditline associated with the OrdPayMthd entries of the specified order are both active.
 void checkPaymentInfoForDelayedProcess( TypedProperty requestProperties, OrderAccessBean abOrder, java.lang.String errorViewName, CommandContext cmdCtx)
          Checks several payment related parameters before scheduling an Order or holding the Order for Approval by the Buyer Approver.
 boolean checkPaymentPolicyAccess( OrderAccessBean abOrder, java.lang.Long nPolicyId)
          Deprecated. - This method is obsolete. It always return true.
 boolean checkPaymentPolicyAccess( OrderAccessBean abOrder, OrderItemAccessBean[] abOrderItemArray, java.lang.Long nPolicyId)
          Deprecated. - This method is obsolete. It always return true.
 java.lang.Long[] findTAsWithCompatiblePaymentTC(java.lang.Long[] nTAIds, OrderAccessBean abOrder, CommandContext cmdCtx)
          From the array of input TradingIds find all the Trading Agreements that have compatible PaymentTC with the existing Trading Agreements specified by the OrderItems of the Order.
 java.lang.Long[] findTAsWithCompatiblePaymentTC(java.lang.Long[] nTAIds, java.util.Set setOfExistingTAIds, CommandContext cmdCtx)
          Deprecated.  
 java.util.Set findTAsWithCompatiblePaymentTC(java.lang.Long nMemberId, java.util.List lstTAIds, CommandContext cmdCtx)
          Find the biggest set of Trading Agreement IDs from the List of Trading Agreement IDs that have compatible Payment Terms and Conditions.
 java.lang.Long[] findTAsWithCompatiblePaymentTC(java.lang.Long nMemberId, java.lang.Long[] nTAIds, java.util.Set setOfExistingTAIds, CommandContext cmdCtx)
          From the array of input TradingIds find all the Trading Agreements that have compatible PaymentTC that the specified customer is entiyled to and with the existing Trading Agreements identified by the Set of TradingIds.
 java.lang.Long getBillToAddressIdFromTC( TypedProperty requestProperties)
          Checks if a tcId parameter is specified in the input TypedProperty object and returns the billToAddress ID specified by the Payment TC if a billToAddress is included in the TC.
static  PaymentHelper getInstance()
          Returns the PaymentHelper instance that can be used to invoke the instance helper methods.
 boolean isCardExpiryDateValid(int expiryMonth, int expiryYear)
          Checks if the specified expiry date (expiryMonth and expiryYear) is valid.
 boolean isPaymentPolicyValid( OrderAccessBean abOrder, java.lang.String strPolicyId, java.lang.String strTCId, CommandContext commandContext)
          This one basically initialized the TermConditionAccessBean from the given strTCId And all the other isPaymentPolicyValid that takes TermConditionAccessBean.
 boolean isPaymentPolicyValid( OrderAccessBean abOrder, java.lang.String strPolicyId, TermConditionAccessBean abPayTC, CommandContext commandContext)
          Checks if the Payment Policy ID specified is valid for the Order.
 java.lang.String removeSpaceAndHyphenFromString(java.lang.String aCardNumber)
          Returns a new string that is free of any spaces and hyphenated characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail
public static final java.lang.String COPYRIGHT
IBM copyright notice field.
See Also:
Constant Field Values
Constructor Detail

PaymentHelper

public PaymentHelper()
PaymentHelper default constructor.
Method Detail

checkAccountAndCreditLineAreActive

public boolean checkAccountAndCreditLineAreActive(java.lang.String sAccountId,
                                                  java.lang.String sCreditLineId)
                                           throws javax.ejb.CreateException,
                                                  javax.ejb.FinderException,
                                                  javax.naming.NamingException,
                                                  java.rmi.RemoteException
Checks if both the specified Account and CreditLine are active. This method gets the AccessBean for the two input parameters and calls the checkAccountAndCreditLineAreActive_AB method to do the actual check.
Parameters:
sAccountId - the internal ID of the Account
sCreditLineId - the internal ID of the CreditLine
Returns:
true if both the Account and the CreditLine are active.
Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException

checkAccountAndCreditLineAreActive_AB

public boolean checkAccountAndCreditLineAreActive_AB(AccountAccessBean abAccount,
CreditLineAccessBean abCreditLine)
                                              throws javax.ejb.CreateException,
                                                     javax.ejb.FinderException,
                                                     javax.naming.NamingException,
                                                     java.rmi.RemoteException
Checks if both the specified Account and CreditLine are active.
Parameters:
abAccount - the AcountAccessBean representing the Account
abCreditLine - the CreditLineAccessBean representing the CreditLine
Returns:
true if both the Account and the CreditLine are active.
Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException

checkCardExpiryYearAndMonth

public void checkCardExpiryYearAndMonth(TypedProperty requestProperties,
                                        java.lang.String errorViewName,
CommandContext cmdCtx)
                                 throws ECException
Checks the cardExpiryMonth and cardExpiryYear parameters if present.
Parameters:
requestProperties - the TypedProperty object that may contain the cardExpiryMonth and cardExpiryYear parameters.
errorViewName - the name of the ErrorView.
cmdCtx - the CommandContext.
Throws:
ECException - this helper method throws ECApplicationException if the cardExpiryYear or cardExpiryMonth is specified and is invalid. Note that if one of the parameters is specified, the other must be specified as well. It is considered an error if only one of the two is specified.

checkCardNumberAndBrand

public void checkCardNumberAndBrand(TypedProperty requestProperties,
                                    java.lang.String errorViewName,
CommandContext cmdCtx)
                             throws ECException
Checks the cardNumber and cardBrand parameters if present.

This helper method calls the CheckCCNumber Task Command to do the actual checking.

Parameters:
requestProperties - the TypedProperty object that may contain the cardNumber and cardBrand parameters.
errorViewName - the name of the ErrorView.
cmdCtx - the CommandContext.
Throws:
ECException - this helper method throws ECApplicationException if the cardNumber is specified and is invalid. Note that if one of the parameters is specified, the other must be specified as well. It is considered an error if only one of the two parameters is present.

checkFromOrdPayMthdIfAllCreditLineAreActive

public java.lang.Long checkFromOrdPayMthdIfAllCreditLineAreActive(java.lang.Long nOrderId)
                                                           throws javax.ejb.CreateException,
                                                                  javax.ejb.FinderException,
                                                                  javax.naming.NamingException,
                                                                  java.rmi.RemoteException
Checks if the Account & Creditline associated with the OrdPayMthd entries of the specified order are both active.
Parameters:
nOrderId - the ID of the order
Returns:
null if both the Account and the Creditline are active; otherwise, the ID of the CreditLine if an inactive one is found.
Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException

checkPaymentInfoForDelayedProcess

public void checkPaymentInfoForDelayedProcess(TypedProperty requestProperties,
OrderAccessBean abOrder,
                                              java.lang.String errorViewName,
CommandContext cmdCtx)
                                       throws ECException
Checks several payment related parameters before scheduling an Order or holding the Order for Approval by the Buyer Approver. This helper method is called to check the parameters if the actual ProcessOrder command and the DoPayment command (which normally checks these parameters) will be delayed for some time.

This helper method may call other Task Commands to do the actual checking of the parameters. The Task Commands that may be called include ValidatePONumber, CheckCCNumber and DoLuhnCheck.

Parameters:
requestProperties - the TypedProperty object containing the name-value pairs from the URL.
abOrder - the OrderAccessBean.
errorViewName - the name of the ErrorView. If null, use "DoPaymentErrorView".
cmdCtx - the CommandContext.
Throws:
ECException - throws ECApplicationException for user correctable errors and ECSystemException for system type errors related to the site or the JSP or the coinfiguration of the Store that the user has no direct control.

checkPaymentPolicyAccess

public boolean checkPaymentPolicyAccess(OrderAccessBean abOrder,
OrderItemAccessBean[] abOrderItemArray,
                                        java.lang.Long nPolicyId)
Deprecated. - This method is obsolete. It always return true.
Checks if the specified Payment Business Policy is usable for the order.
Parameters:
abOrder - the OrderAccessBean for the order
abOrderItemArray - the OrderItemAccessBeans for the order items in the order
nPolicyId - the ID of the Payment Business Policy to check
Returns:
true if the policy is usable

checkPaymentPolicyAccess

public boolean checkPaymentPolicyAccess(OrderAccessBean abOrder,
                                        java.lang.Long nPolicyId)
Deprecated. - This method is obsolete. It always return true.
Checks if the specified Payment Business Policy is usable for the order.
Parameters:
abOrder - the OrderAccessBean for the order
nPolicyId - the ID of the Payment Business Policy to check
Returns:
true if the policy is usable

findTAsWithCompatiblePaymentTC

public java.lang.Long[] findTAsWithCompatiblePaymentTC(java.lang.Long[] nTAIds,
OrderAccessBean abOrder,
CommandContext cmdCtx)
                                                throws ECException
From the array of input TradingIds find all the Trading Agreements that have compatible PaymentTC with the existing Trading Agreements specified by the OrderItems of the Order.
Parameters:
nTAIds - an input array containing the TradingIds to check.
abOrder - the OrderAccessBean
cmdCtx - the CommandContext.
Returns:
an arry containing the TradingIds with compatible PaymentTC.
Throws:
ECException

findTAsWithCompatiblePaymentTC

public java.lang.Long[] findTAsWithCompatiblePaymentTC(java.lang.Long[] nTAIds,
                                                       java.util.Set setOfExistingTAIds,
CommandContext cmdCtx)
                                                throws ECException
Deprecated.  
From the array of input TradingIds find all the Trading Agreements that have compatible PaymentTC with the existing Trading Agreements identified by the Set of TradingIds.
Parameters:
nTAIds - the array of Trading Agreement IDs
setOfExistingTAIds - the set of IDs of existing Trading Agreements
cmdCtx - the CommandContext
Returns:
the list of IDs of Trading Agreements with compatible compatible Payment Terms and Conditions.
Throws:
ECException

findTAsWithCompatiblePaymentTC

public java.lang.Long[] findTAsWithCompatiblePaymentTC(java.lang.Long nMemberId,
                                                       java.lang.Long[] nTAIds,
                                                       java.util.Set setOfExistingTAIds,
CommandContext cmdCtx)
                                                throws ECException
From the array of input TradingIds find all the Trading Agreements that have compatible PaymentTC that the specified customer is entiyled to and with the existing Trading Agreements identified by the Set of TradingIds.
Parameters:
nMemberId - the Memeber ID that identifies the customer
nTAIds - the array of Trading Agreement IDs
setOfExistingTAIds - the Set of IDs of existing Trading Agreements
cmdCtx - the CommandContext
Returns:
the list of IDs of Trading Agreements with compatible compatible Payment Terms and Conditions.
Throws:
ECException

findTAsWithCompatiblePaymentTC

public java.util.Set findTAsWithCompatiblePaymentTC(java.lang.Long nMemberId,
                                                    java.util.List lstTAIds,
CommandContext cmdCtx)
                                             throws ECException
Find the biggest set of Trading Agreement IDs from the List of Trading Agreement IDs that have compatible Payment Terms and Conditions. The Trading Agreement IDs chosen are weighted by the number of times it appears in the input List. For example, if there are three distinct Trading Agreements in the input List all having different and incompatible Payment Terms and Conditions, any single one could be returned. However, if one of the Trading Agreement appears in the list more than once, and the other two are only referenced once, then the Trading Agreement ID referenced more than once would be chosen over the other two.
Parameters:
nMemberId - the member ID that identifies the customer.
cmdCtx - the CommandContext
Returns:
the Set of Trading Agreement IDs representing the largest set of Trading Agreements from the List of Trading Agreement that have compatible Payment Terms and Conditions.
Throws:
ECException

getBillToAddressIdFromTC

public java.lang.Long getBillToAddressIdFromTC(TypedProperty requestProperties)
                                        throws ECException
Checks if a tcId parameter is specified in the input TypedProperty object and returns the billToAddress ID specified by the Payment TC if a billToAddress is included in the TC. Otherwise, returns a null.
Parameters:
requestProperties - the TypedProperty object containing the name-value pairs from the URL.
Returns:
the billToAddress ID if one is specified by the Payment TC. Otherwise, returns null.
Throws:
ECException

getInstance

public static PaymentHelper getInstance()
Returns the PaymentHelper instance that can be used to invoke the instance helper methods.
Returns:
PaymentHelper

isCardExpiryDateValid

public boolean isCardExpiryDateValid(int expiryMonth,
                                     int expiryYear)
Checks if the specified expiry date (expiryMonth and expiryYear) is valid.
Parameters:
expiryMonth - the calender month of the expiry date (1 for January, 2 for February, and so on.)
expiryYear - the calender year of the expiry date
Returns:
ture if the expiry date is valid.

isPaymentPolicyValid

public boolean isPaymentPolicyValid(OrderAccessBean abOrder,
                                    java.lang.String strPolicyId,
TermConditionAccessBean abPayTC,
CommandContext commandContext)
                             throws ECException
Checks if the Payment Policy ID specified is valid for the Order. A Policy is valid if all Trading Agreements associated with the OrderItems include a Payment TC that specifies this Policy and if the specified TC includes a billToAddress and pre-defined attributes, all the other Trading Agreements must have a compatible TC that specify the same billToAddress and attributes. Trading Agreement with no Payment TC could use any Payment Policy unless the Policy has an exclude-from-defaultTC or require-explicit-TC clause.
Parameters:
abOrder - the OrderAccessBean representing the Order.
strPolicyId - the String representing the Payment Policy ID.
abPayTC - the TermConditionAccessBean representing the Payment Terms and Conditions to use for the purchase. It can be null.
commandContext - the CommandContext
Returns:
true if the specified Payment Policy is valid for the Order.
Throws:
ECException

isPaymentPolicyValid

public boolean isPaymentPolicyValid(OrderAccessBean abOrder,
                                    java.lang.String strPolicyId,
                                    java.lang.String strTCId,
CommandContext commandContext)
                             throws ECException
This one basically initialized the TermConditionAccessBean from the given strTCId And all the other isPaymentPolicyValid that takes TermConditionAccessBean. Please read the other isPaymentPolicyValid for more detail
Parameters:
abOrder - the OrderAccessBean representing the Order.
strPolicyId - the String representing the Payment Policy ID.
strTCId - the String representing the ID of the Payment Terms and Conditions to use for the purchase. This String could be an empty String but cannot be null.
commandContext - the CommandContext
Returns:
true if the specified Payment Policy is valid for the Order.
Throws:
ECException

removeSpaceAndHyphenFromString

public java.lang.String removeSpaceAndHyphenFromString(java.lang.String aCardNumber)
Returns a new string that is free of any spaces and hyphenated characters. If the supplied string is already free of spaces and hyphens the same string may be returned.
Parameters:
aCardNumber - the card number to be examined and stripped
Returns:
a String free of spaces and hyphenated characters ('-')