com.ibm.commerce.payment.commands
Class DoPaymentPMCmdImpl

com.ibm.commerce.payment.commands.DoPaymentPMCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, DoInventory, DoPaymentPolicyCmd, ECCommand, TaskCommand

public class DoPaymentPMCmdImpl
implements DoPaymentPolicyCmd, DoInventory

The DoPaymentPMCmdImpl command implements the DoPaymentPolicy business policy command, which is called by the DoPaymentMPFCmdImpl task command to process payment for an order.

The DoPaymentPMCmdImpl command passes environment variables to the Payment Manager Cashier. The Cashier will only use the value from the environment if directed to do so by the Cashier profile specified by the DoPaymentPMCmdImpl command with the CollectPayment call.

The following table summarizes environment variables that the DoPaymentPMCmdImpl command passes to the Payment Manager Cashier:

 Environment variable name Description
The following variables are mandatory variables received by the DoPaymentPMCmdImpl command from the DoPaymentMPFCmdImpl.
storeId The value for the store identification number
Order The Order Access Bean of the order.
totalAmount The amount of the order to be send to WebSphere Payment Manager.
The following variables are optional variables received by the DoPaymentPMCmdImpl command from the DoPaymentMPFCmdImpl.
Account The Account Access Bean of the order.
BuyerPOId The value for the Buyer Purchase Order identification number
errorViewName The error view name passed in by the Caller.
The following variables are optional variables received by the DoPaymentPMCmdImpl command from the command URL. (through setting PaymentAttributes of the command)
billtoAddressId  The value for the order identification number.

This parameter is actually a parameter for the OrderProcess command. If the parameter is present, OrderProcess would store the addressId in the Orders table. The DoPaymentPMCmdImpl command uses the addressId from the Orders table to create several billto_xxxx environment variables to pass to the Cashier. The billto_xxx environment variables are described in this table.

cardExpiryMonth
cardExpiryYear
These parameters must be specified as a pair -- If one is present, the other must also be present. Otherwise, it is an error.

cardExpiryMonth is a number representing the month of expiration for the payment card. For example, 1 for January, 2 for February, and so on.

cardExpiryYear is the year of expiration for the payment card.

DoPaymentPMCmdImpl will check if the date specified has already expired or if the date is too far in the future (more than 10 years). If the date passes these checks, DoPaymentPMCmdImpl will create a new environment variable called "card_expiry" with the value "yyyymm" from the cardExpiryYear ("yyyy") and cardExpiryMonth left-padded with "0" if the month is less than 10.

cardBrand
cardNumber
These parameters must be specified as a pair -- If one is present, the other must also be present. Otherwise, it is an error.

cardBrand represents the type of payment card the customer is using. It must match the BrandID used to configure the Payment Manager Account for the Merchant or Store. The name is case-sensitive.

cardNumber is the payment card number, for example 4111 - 1111- 1111- 1111. Note the embedded blanks, trailing blanks and hyphens. These formats are allowed in WebSphere Commerce Suite, but are not recognized by Payment Manager. DoPaymentPMCmdImpl calls the CheckCCNumberCmd task command to verify the cardNumber for the specified cardBrand. If the number passes the check, DoPaymentPMCmdImpl creates a new environment variable called card_number with all embedded and trailing blanks and embedded "-" removed. The WebSphere Commerce Suite-supplied Cashier profile specifies the card_number environment variable as a value for the Payment Manager "$PAN" parameter which is the Payment Manager parameter name for credit card number and does not allow non-numeric characters.

The following variables are environment variables that are always passed.
WebPath The WebSphere Commerce Suit application server Web path. (For example,  /webapp/wcs/stores/servlet
WCSHostName The domain-qualified host name of the WebSphere Commerce Suite host.
WCSWebServerPort The WebSphere Commerce Suite  Web server Port. Generally port 80.
CommandContext Reference to the CommandContext of the command. This is needed if the Cashier Extension needs to call a task command. The CommandContext has many useful methods. See documentation on the CommandContext interface for detail.
The following variables are mandatory parameters required by Payment Manager for all cassettes.
CURRENCY  A code indicating the currency AMOUNT is in. This is the numeric currency code as per ISO 4217.
AMOUNT  The amount is in the currency's smallest denomination. For example, for USD (U.S. dollars), the amount would be in cents, not dollars.
The following variables are optional parameters required by Payment Manager for all cassettes.
AMOUNTEXP10 Amount Exponent (power of 10). The exponential value by which AMOUNT (which is the amount in the sub-unit of a country's currency) is multiplied to get the amount in the country's main currency unit (such as pesos or dollars). For example, you would multiply the amount in cents by 10 to the power "-2" to get the amount in dollars. This value is 0 for countries with no currency sub-unit.
The following variables are gathered by DoPaymentPMCmdImpl command from other sources
billto_firstname
billto_middlename
billto_lastname
billto_address1
billto_city
billto_state
billto_country
billto_zipcode
 These variables are derived from the Address entry identified by billtoAddressId.

These environment variables are in the language entered by the shopper and may not be appropriate for use as values for the $AVS.xxxx parameters for some cassettes. For example, both the Cassette for SET and the Cassette for CyberCash allow only ASCII or English ASCII characters to be used for the $AVS.xxxx parameters and thus cannot use these environment variables unless it is verified that the variables only contain ASCII or English ASCII characters.

billto_country_code  This variable is derived using the Country Code table and the billto_country variable. Some of the Payment Manager cassettes require this for Address Verification Service (AVS).

If no Country Code entry can be found for the country, a code of "999" will be passed as the value for the billto_country_code environment variable. The country codes used by the Payment Manager are the numeric country codes specified by ISO 3166-1. The numeric codes are maintained by the United Nations Statistics Division in New York. See http://www.un.org/Depts/unsd/methods/m49alpha.htm for the current list.

If the Cashier profile uses billto_country_code you should not allow the customer to enter the country name in a bill-to address form as free-form text. That may result in the server not being able to find an exact match for the country in the country code table. Instead, use a dropdown list of country names for the customer to select as input for the country.

card_number This is derived from the cardNumber variable described above.
card_expiry This is derived from the cardExpiryMonth and the cardExpiryYear variables described above.
currency_alpha_code This code is derived from the Orders table.

Behavior

Returned Parameters: Error View Name: ErrorCodes:


Fields inherited from interface com.ibm.commerce.payment.commands.DoPaymentPolicyCmd
CC_VALID_Y_RANGE, COPYRIGHT, defaultCommandClassName, ERRTASK_NAME, MESSAGE_FOR_BUYER, NAME, NVP_FIELD, PM_MESSAGE_FOR_BUYER, PM_MESSAGE_FOR_MERCHANT, PM_PRIMARY_RC, PM_SECONDARY_RC, WCSHOSTNAME, WCSWEBSERVERPORT, WEBPATH
 
Constructor Summary
DoPaymentPMCmdImpl()
           
 
Method Summary
protected  void checkParameters()
          Checks the validity of customer-supplied parameters.
protected  AccountAccessBean getAccount()
          Returns the AccountAccessBean representing the Account.
protected  java.lang.Long getAccountId()
          This returns the Account ID.
protected  java.lang.Long getBuyerPOId()
          Returns the internal ID of the BuyerPO record passed to the command.
 java.lang.String getContentType()
          Returns the Content Type (or MIME type) of the return data, or null if the type is not known.
protected  java.lang.String getCurrencyExponent()
           
protected  java.lang.Double getCurrencyFactor()
           
protected  java.lang.String getDisplayPaymentStateForTrace(int anPaymentState)
          Returns the display String represnting the Payment State as returned by Payment Manager for Trace purposes.
protected  java.lang.String getErrorViewName()
          Returns the errorViewName attribute passed to this command.
protected  java.lang.String getNumericCountryCode(java.lang.String productVendor, java.lang.String country)
          Returns the numeric country/region code for the specified country/region as specified by the product/vendor in the Country Code Table (COUNTCODE).
protected  java.lang.String getNumericCurrencyCode()
           
protected  OrderAccessBean getOrder()
          Returns the OrderAccessBean representing the Order.
 java.lang.String getOrderState()
          Returns the single character String value that the called command wants the Calling command to use to set the Status of the order.
protected  TypedProperty getPaymentAttributes()
          Returns the TypedProperty object containing the payment attributes passed to this command by the calling command.
protected  java.math.BigInteger getPMTotalAmount()
           
protected  java.lang.String getPONumber()
          Returns the PONumber attribute passed to the command by the calling command.
protected  java.lang.String getProfileName()
          Returns the profileName attribute passed to the command by the calling command.
 byte[] getReturnData()
          Returns the byte Array containing Return Data from the Payment Manager.
protected  java.math.BigDecimal getTotalAmount()
          Returns the totalAmount attribute passed to the command by the calling command.
 boolean isReadyToCallExecute()
          This method is called by the Command Framework to check if all basic mandatory parameters have been set for this command.
 void performExecute()
          Performs the main business logic of the command.
 java.util.Hashtable query(java.lang.String queryString)
          The Cashier calls this method to construct a Hashtable of keywords and values which result from processing the input query string.
 void reset()
          Resets the instance variables of the command.
 void setAccount(AccountAccessBean abAccount)
          Sets the abAccount property of the command.
 void setBuyerPOId(java.lang.Long n)
          Sets optional buyerPOId.
protected  void setContentType(java.lang.String sContentType)
          Set Content Type.
protected  void setCurrencyExponent(java.lang.String astrCurrencyExponent)
          Sets Currency Exponent.
protected  void setCurrencyFactor(java.lang.Double d)
          Sets Currency Factor.
 void setErrorViewName(java.lang.String sEVN)
          Optional error view name passed in by the Caller.
protected  void setNumericCurrencyCode(java.lang.String astrCurrencyCode)
          Set Numeric Currency Code.
 void setOrder(OrderAccessBean ab)
          The order to be ReApproved.
protected  void setOrderState(java.lang.String orderState)
          Set Order State.
 void setPaymentAttributes(TypedProperty paymentAttributes)
          Sets the paymentAttributes property of the command.
protected  void setPMTotalAmount(java.math.BigInteger biPMTotalAmount)
          Sets total amount for WebSphere Payment Manager.
protected  void setPONumber(java.lang.String sPONumber)
          Sets Purchase Order number.
protected  void setProfileName(java.lang.String s)
          Sets the Profile Name.
protected  void setReturnData(byte[] ba)
          Sets the Return Data.
 void setTotalAmount(java.math.BigDecimal totalAmount)
          Sets the totalAmount property of the command.
protected  void setupNumericCurrencyCodeAndPMTotalAmount()
          This method is called by performExecute to convert the totalAmount to an integer amount usable by the Payment Manager.
protected  void updateOrderPaymentMethod()
          This is called by performExecute to create a new ORDPAYMTHD row with payment info
 void validateParameters()
          Checks the validity of customer-supplied parameters.
 
Methods inherited from interface com.ibm.commerce.command.BusinessPolicyCommand
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 
Methods inherited from interface com.ibm.commerce.command.ECCommand
checkIsAllowed, checkResourcePermission, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 

Constructor Detail

DoPaymentPMCmdImpl

public DoPaymentPMCmdImpl()
Method Detail

checkParameters

protected void checkParameters()
                        throws ECException
Checks the validity of customer-supplied parameters.

getAccount

protected AccountAccessBean getAccount()
Returns the AccountAccessBean representing the Account.

getAccountId

protected java.lang.Long getAccountId()
                               throws javax.ejb.CreateException,
                                      javax.ejb.FinderException,
                                      javax.naming.NamingException,
                                      java.rmi.RemoteException
This returns the Account ID.

getBuyerPOId

protected java.lang.Long getBuyerPOId()
Returns the internal ID of the BuyerPO record passed to the command.

getContentType

public java.lang.String getContentType()
Returns the Content Type (or MIME type) of the return data, or null if the type is not known.
Specified by:
getContentType in interface DoPaymentPolicyCmd
Returns:
a String containing the name of the MIME type of the return data, or null if the type is not known

getCurrencyExponent

protected java.lang.String getCurrencyExponent()

getCurrencyFactor

protected java.lang.Double getCurrencyFactor()

getDisplayPaymentStateForTrace

protected java.lang.String getDisplayPaymentStateForTrace(int anPaymentState)
Returns the display String represnting the Payment State as returned by Payment Manager for Trace purposes.
Parameters:
anPaymentState - the numeric payment state from Payment Manager.
Returns:
the display String for the specified payment state.

getErrorViewName

protected java.lang.String getErrorViewName()
Returns the errorViewName attribute passed to this command.

getNumericCountryCode

protected java.lang.String getNumericCountryCode(java.lang.String productVendor,
                                                 java.lang.String country)
                                          throws ECException
Returns the numeric country/region code for the specified country/region as specified by the product/vendor in the Country Code Table (COUNTCODE).
Throws:
ECException -  

getNumericCurrencyCode

protected java.lang.String getNumericCurrencyCode()

getOrder

protected OrderAccessBean getOrder()
Returns the OrderAccessBean representing the Order.

getOrderState

public java.lang.String getOrderState()
Returns the single character String value that the called command wants the Calling command to use to set the Status of the order. If the returned String is null, the Calling command will decide the value to use for the Status
Specified by:
getOrderState in interface DoPaymentPolicyCmd
Returns:
java.lang.String

getPaymentAttributes

protected TypedProperty getPaymentAttributes()
Returns the TypedProperty object containing the payment attributes passed to this command by the calling command.

getPMTotalAmount

protected java.math.BigInteger getPMTotalAmount()

getPONumber

protected java.lang.String getPONumber()
Returns the PONumber attribute passed to the command by the calling command.

getProfileName

protected java.lang.String getProfileName()
Returns the profileName attribute passed to the command by the calling command.

getReturnData

public byte[] getReturnData()
Returns the byte Array containing Return Data from the Payment Manager. This method returns a zero length byte array if there is no rturn data from the Payment Manager.
Specified by:
getReturnData in interface DoPaymentPolicyCmd
Returns:
byte[]

getTotalAmount

protected java.math.BigDecimal getTotalAmount()
Returns the totalAmount attribute passed to the command by the calling command.

isReadyToCallExecute

public boolean isReadyToCallExecute()
This method is called by the Command Framework to check if all basic mandatory parameters have been set for this command. This is done before the Framework calls the performExecute method of the command.

performExecute

public void performExecute()
                    throws ECException
Performs the main business logic of the command.
Specified by:
performExecute in interface ECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
com.ibm.commerce.command.CommandException - The superclass for all ECExceptions.

query

public java.util.Hashtable query(java.lang.String queryString)
                          throws com.ibm.commerce.payment.commands.CashierException
The Cashier calls this method to construct a Hashtable of keywords and values which result from processing the input query string.

This method is defined by the com.ibm.etill.cashier.Queryable interface.

Parameters:
queryString - a SelectStatement element from a Cashier profile
Throws:
com.ibm.commerce.payment.commands.CashierException - if there is an error creating and populating the result Hashtable.

reset

public void reset()
Resets the instance variables of the command. The reset() method will reset all instance variables. If the command includes any output values that are accessible via getters, then make sure those values are no longer needed before calling this method to reset the instance variables of the command.

This is useful if the command instance is to be called multiple times with different command parameters.


setAccount

public void setAccount(AccountAccessBean abAccount)
Description copied from interface: DoPaymentPolicyCmd
Sets the abAccount property of the command.
Specified by:
setAccount in interface DoPaymentPolicyCmd
Following copied from interface: com.ibm.commerce.payment.commands.DoPaymentPolicyCmd
Parameters:
abAccount - the AccountAccessBean of the Order is associated with

setBuyerPOId

public void setBuyerPOId(java.lang.Long n)
Sets optional buyerPOId. This is the internal ID of the record for the buyerPO object.
Specified by:
setBuyerPOId in interface DoPaymentPolicyCmd
Following copied from interface: com.ibm.commerce.payment.commands.DoPaymentPolicyCmd
Parameters:
nBuyerPOId - the Buyer Purchase Order Reference Number of the Order is associated with

setContentType

protected void setContentType(java.lang.String sContentType)
Set Content Type.

setCurrencyExponent

protected void setCurrencyExponent(java.lang.String astrCurrencyExponent)
Sets Currency Exponent.

setCurrencyFactor

protected void setCurrencyFactor(java.lang.Double d)
Sets Currency Factor.

setErrorViewName

public void setErrorViewName(java.lang.String sEVN)
Optional error view name passed in by the Caller.
Specified by:
setErrorViewName in interface DoPaymentPolicyCmd

setNumericCurrencyCode

protected void setNumericCurrencyCode(java.lang.String astrCurrencyCode)
Set Numeric Currency Code.

setOrder

public void setOrder(OrderAccessBean ab)
The order to be ReApproved.
Specified by:
setOrder in interface DoPaymentPolicyCmd
Following copied from interface: com.ibm.commerce.payment.commands.DoPaymentPolicyCmd
Parameters:
abOrder - the OrderAccessBean of the Order for which payment is to be processed.

setOrderState

protected void setOrderState(java.lang.String orderState)
Set Order State.

setPaymentAttributes

public void setPaymentAttributes(TypedProperty paymentAttributes)
Sets the paymentAttributes property of the command.
Specified by:
setPaymentAttributes in interface DoPaymentPolicyCmd
Parameters:
requestProperties - the requestProperties object that contains all the command parameters are to be passed to this command.

Some of the Payment Attributes that may be passed to the command are:

       Keyword                         Value
     ===========        ====================================
     profileName        Name of the Cashier Profile to use
     cardBrand          The credit card brand.
     cardNumber         The credit card number
     cardExpiryMonth    The credit card exipration month
     cardExpiryYear     The credit card exipration year
     $XXXXXX            Protocol Data Value for $XXXXXX
 
where $XXXXXX are special Protocol Data Keyword defined by the Payment Manager Cassette. (The Protocol Data keywords all start with the "$" character.)

For this command, the profileName attribute is mandatory. The cardBrand and cardNumber attributes, if specified, must both be present. Same is true for the cardExpiryMonth and the cardExpiryYear attributes.

Note: The cardBrand attribute must match the BrandID used to configure the Merchant Account in the Payment Manager. The BrandID is case-sensitive.


setPMTotalAmount

protected void setPMTotalAmount(java.math.BigInteger biPMTotalAmount)
Sets total amount for WebSphere Payment Manager.

setPONumber

protected void setPONumber(java.lang.String sPONumber)
Sets Purchase Order number.

setProfileName

protected void setProfileName(java.lang.String s)
Sets the Profile Name.

setReturnData

protected void setReturnData(byte[] ba)
Sets the Return Data.

setTotalAmount

public void setTotalAmount(java.math.BigDecimal totalAmount)
Sets the totalAmount property of the command.
Specified by:
setTotalAmount in interface DoPaymentPolicyCmd
Parameters:
totalAmount - the total price of the Order for which payment is to be processed.

setupNumericCurrencyCodeAndPMTotalAmount

protected void setupNumericCurrencyCodeAndPMTotalAmount()
                                                 throws javax.ejb.CreateException,
                                                        javax.ejb.FinderException,
                                                        javax.naming.NamingException,
                                                        java.rmi.RemoteException,
                                                        ECException
This method is called by performExecute to convert the totalAmount to an integer amount usable by the Payment Manager. This is done by converting the totalAmount to the lowest denomination specified by the currency.

updateOrderPaymentMethod

protected void updateOrderPaymentMethod()
                                 throws javax.ejb.CreateException,
                                        javax.ejb.FinderException,
                                        javax.naming.NamingException,
                                        java.rmi.RemoteException
This is called by performExecute to create a new ORDPAYMTHD row with payment info

validateParameters

public void validateParameters()
                        throws ECException
Checks the validity of customer-supplied parameters.
Specified by:
validateParameters in interface ECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
ECException. -