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 Subsystem classes.


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 OrderId are all 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.
 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.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)
          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
 

Constructor Detail

PaymentHelper

public PaymentHelper()
PaymentHelper default constructor.
Method Detail

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.
Returns:
true if both the Account and the CreditLine are active.

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.
Returns:
true if both the Account and the CreditLine are active.

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 OrderId are all active. Returns null if both the Account and the Creditline are active. Otherwise, returns the creditline ID if an inactive one is found.

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.

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.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.
nTAIds - list of Trading Agreement IDs to check.
cmdCtx - the CommandContext
Returns:
the Set of Trading Agreement IDs representing the largest set of Trading Agreements from the List of Trading Agreement IDs that have compatible Payment TC.
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 - java.lang.Long MemeberId that identidies the customer.
nTAIds - java.lang.Long[] input array of TradingIds to check.
setOfExistingTAIds - java.util.Set TradingIds of the existing Trading Agreements. The TradingIds are of type java.lang.Long.
cmdCtx - com.ibm.commerce.command.CommandContext
Returns:
java.lang.Long[] the list of TradingIds with compatible compatible PaymentTC.
Throws:
ECException - The exception description.

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.

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,
                                    java.lang.String strTCId,
                                    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.
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.
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 ('-')