com.ibm.commerce.payment.commands
Class DoPaymentMPFInternalCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.payment.commands.DoPaymentMPFInternalCmdImpl
All Implemented Interfaces:
DoInventory, DoPaymentMPFInternalCmd, ECCommand, ECTargetableCommand, TaskCommand

public class DoPaymentMPFInternalCmdImpl
extends TaskCommandImpl
implements DoPaymentMPFInternalCmd, DoInventory

This DoPaymentMPFInternalCmd Task Command Implementation is called by the DoPaymentMPFCmdImpl Task Command to process payment for an order using WebSphere Commerce Payments when the payMethodId url parameter was specified with the OrderProcess command. This Task Command Implementation is a renamed version of the original DoPaymentMPFCmdImpl class and is mainly for backward compatibility. It does not support any of the new function introduced with WCBE.

This DoPaymentMPFInternalCmd implementation class is independent of the payment cassette that would be used to process the payment for the order. It uses the Cashier profile specified by the payMethodId parameter to direct the Cashier to gather parameters needed by the payment cassette. This command implementation supports both non-wallet based payment cassettes and wallet-based payment cassettes.

If the command is successful, the OrderProcessCmd will set the Order status to the value specified by this command.

If unsuccessful, the command throws the ECApplicationException specifying an Error Code and the Error View named by the com.ibm.commerce.DoPaymentCmd.ERROR_TASK_NAME.

The DoPaymentMPFInternalCmdImpl class may result in non-empty returnData for the OrderProcessCmd dependent on the Cassette.

See Also:
Serialized Form

Field Summary
static java.lang.String BILLTO_ADDRESS1
           
static java.lang.String BILLTO_CITY
           
static java.lang.String BILLTO_COUNTRY
           
static java.lang.String BILLTO_COUNTRY_CODE
           
static java.lang.String BILLTO_FIRSTNAME
           
static java.lang.String BILLTO_LASTNAME
           
static java.lang.String BILLTO_MIDDLENAME
           
static java.lang.String BILLTO_STATE
           
static java.lang.String BILLTO_ZIPCODE
           
static java.lang.String BUYER_LANGUAGE_ID
           
static java.lang.String CARD_EXPIRY
           
static java.lang.String CARD_NUMBER
           
static java.lang.String CURRENCY_ALPHA_CODE
           
static java.lang.String PAYMTHD_PSRVR
           
static java.lang.String PAYMTHD_SET
           
static int PRC_DUPLICATE_OBJECT
           
static int SRC_CONNECTION_TO_PM_FAILED
           
static int SRC_INITIALIZATION_MESSAGE
           
static int SRC_ORDER
           
static int SRC_USER_NOT_AUTHORIZED
           
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.payment.commands. DoPaymentMPFInternalCmd
CC_VALID_Y_RANGE, COPYRIGHT, defaultCommandClassName, ERR_CODE_BAD_CCNUM, ERR_CODE_BAD_SYS, ERR_CODE_BAD_XDATE, ERR_CODE_MISSING_PARAM, ERRTASK_NAME, MESSAGE_FOR_BUYER, NAME, NVP_field, NVP_FIELD, PM_MESSAGE_FOR_BUYER, PM_MESSAGE_FOR_MERCHANT, PM_PRIMARY_RC, PM_SECONDARY_RC, WCSHOSTNAME, WCSWEBSERVERPORT, WEBPATH
 
Fields inherited from interface com.ibm.commerce.command. ECTargetableCommand
COPYRIGHT
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
DoPaymentMPFInternalCmdImpl()
           
 
Method Summary
protected  void checkParameters()
          Deprecated. Use validateParameters() instead.
 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()
          Returns the currency exponent.
protected  java.sql.Connection getDBConnection()
          Deprecated.  
protected  java.lang.String getDisplayPaymentStateForTrace(int anPaymentState)
          Returns the display String represnting the Payment State as returned by WebSphere Commerce Payments for Trace purposes.
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 getOrderAccessBean()
          This method will first check if the local variable is set or not.
protected  java.lang.Long getOrderId()
           
 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()
           
protected  java.lang.Integer getPaymentMethodId()
           
protected  java.math.BigInteger getPMTotalAmount()
           
protected  java.lang.String getProfileName()
           
 byte[] getReturnData()
          Returns the byte Array containing Return Data from WebSphere Commerce Payments.
protected  java.math.BigDecimal getTotalAmount()
           
 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.
protected  void setContentType(java.lang.String sContentType)
           
protected  void setCurrencyExponent(java.lang.String astrCurrencyExponent)
           
protected  void setNumericCurrencyCode(java.lang.String astrCurrencyCode)
           
protected  void setOrderAccessBean( OrderAccessBean abOrder)
           
 void setOrderId(java.lang.Long orderId)
          Sets the orderId property of the command.
protected  void setOrderState(java.lang.String orderState)
          Sets the Order State.
 void setPaymentAttributes( TypedProperty paymentAttributes)
          Sets the paymentAttributes property of the command.
 void setPaymentMethodId(java.lang.Integer nPayMthdId)
          Sets the payment method ID to be used.
protected  void setPMTotalAmount(java.math.BigInteger biPMTotalAmount)
          Sets the total amount normalized for input to WebSphere Commerce Payments.
protected  void setProfileName(java.lang.String strProfileName)
           
protected  void setReturnData(byte[] ba)
           
 void setTotalAmount(java.math.BigDecimal totalAmount)
          Sets the totalAmount property of the command.
protected  void setupNumericCurrencyCodeAndPMTotalAmount()
          This method retrieves the numeric currency code from the SETCURR Table and converts the totalAmount to a normalized form required for input to WebSphere Commerce Payments.
protected  void setupProfileName(java.lang.Integer nStoreId, java.lang.Integer nPayMthdId)
           
protected  void updateOrderPaymentMethod()
           
protected  void updatePaymentStatus()
           
 void validateParameters()
          Checks the validity of customer-supplied parameters.
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRC_DUPLICATE_OBJECT

public static final int PRC_DUPLICATE_OBJECT
See Also:
Constant Field Values

SRC_INITIALIZATION_MESSAGE

public static final int SRC_INITIALIZATION_MESSAGE
See Also:
Constant Field Values

SRC_ORDER

public static final int SRC_ORDER
See Also:
Constant Field Values

SRC_CONNECTION_TO_PM_FAILED

public static final int SRC_CONNECTION_TO_PM_FAILED
See Also:
Constant Field Values

SRC_USER_NOT_AUTHORIZED

public static final int SRC_USER_NOT_AUTHORIZED
See Also:
Constant Field Values

PAYMTHD_SET

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

PAYMTHD_PSRVR

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

BILLTO_FIRSTNAME

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

BILLTO_MIDDLENAME

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

BILLTO_LASTNAME

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

BILLTO_ADDRESS1

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

BILLTO_CITY

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

BILLTO_STATE

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

BILLTO_ZIPCODE

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

BILLTO_COUNTRY

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

BILLTO_COUNTRY_CODE

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

CARD_NUMBER

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

CARD_EXPIRY

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

CURRENCY_ALPHA_CODE

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

BUYER_LANGUAGE_ID

public static final java.lang.String BUYER_LANGUAGE_ID
See Also:
Constant Field Values
Constructor Detail

DoPaymentMPFInternalCmdImpl

public DoPaymentMPFInternalCmdImpl()
Method Detail

checkParameters

protected void checkParameters()
                        throws ECException
Deprecated. Use validateParameters() instead.
Checks the validity of customer-supplied parameters.
Overrides:
checkParameters in class AbstractECTargetableCommand
Throws:
ECException.
ECException

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 DoPaymentMPFInternalCmd
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()
Returns the currency exponent.

getDBConnection

protected java.sql.Connection getDBConnection()
                                       throws java.sql.SQLException,
ECException
Deprecated.  
Returns the connection to WCS database. User are responsible to close it.
java.sql.SQLException
ECException

getDisplayPaymentStateForTrace

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

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()

getOrderAccessBean

protected OrderAccessBean getOrderAccessBean()
This method will first check if the local variable is set or not. If not set it will attempt to get it by create a new AccessBean.

getOrderId

protected java.lang.Long getOrderId()

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 DoPaymentMPFInternalCmd
Returns:
the preferred order state

getPaymentAttributes

protected TypedProperty getPaymentAttributes()

getPaymentMethodId

protected java.lang.Integer getPaymentMethodId()

getPMTotalAmount

protected java.math.BigInteger getPMTotalAmount()

getProfileName

protected java.lang.String getProfileName()

getReturnData

public byte[] getReturnData()
Returns the byte Array containing Return Data from WebSphere Commerce Payments. This method returns a zero length byte array if there is no return data from WebSphere Commerce Payments.
Specified by:
getReturnData in interface DoPaymentMPFInternalCmd
Returns:
byte[]

getTotalAmount

protected java.math.BigDecimal getTotalAmount()

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.
Overrides:
isReadyToCallExecute in class AbstractECTargetableCommand
Returns:
true if we can execute the command; false otherwise.

performExecute

public void performExecute()
                    throws ECException
Performs the main business logic of the command.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException

query

public java.util.Hashtable query(java.lang.String queryString)
                          throws 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:
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.

Overrides:
reset in class AbstractECTargetableCommand

setContentType

protected void setContentType(java.lang.String sContentType)

setCurrencyExponent

protected void setCurrencyExponent(java.lang.String astrCurrencyExponent)

setNumericCurrencyCode

protected void setNumericCurrencyCode(java.lang.String astrCurrencyCode)

setOrderAccessBean

protected void setOrderAccessBean(OrderAccessBean abOrder)

setOrderId

public void setOrderId(java.lang.Long orderId)
Sets the orderId property of the command.
Specified by:
setOrderId in interface DoPaymentMPFInternalCmd
Parameters:
orderId - the order reference number of the Order for which payment is to be processed.

setOrderState

protected void setOrderState(java.lang.String orderState)
Sets the Order State.
Parameters:
orderState - the single-character state value.

setPaymentAttributes

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

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

       Keyword                         Value
     ===========        ====================================
     payMethodId        PayMthd_Id 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 cassette. (The Protocol Data keywords all start with the "$" character.)

For this command, the payMethodId 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 WebSphere Commerce Payments. The BrandID is case-sensitive.


setPaymentMethodId

public void setPaymentMethodId(java.lang.Integer nPayMthdId)
Sets the payment method ID to be used. The payment method ID identifies the payment method to be used to process payment for the order. (The ID is the ID of a row in the PAYMTHD Table.)
Parameters:
nPayMthdId - the numeric ID of the payment method to be used.

setPMTotalAmount

protected void setPMTotalAmount(java.math.BigInteger biPMTotalAmount)
Sets the total amount normalized for input to WebSphere Commerce Payments.

The normalized amount is the amount converted to the smallest denomination for the currency. For example, if the total amount is US $10.95, PMTotalAmount is 1095 in cents, which is the lowest denomination for this currency. If there is no smaller denomination other than the main currency unit for the currency, the normalized amount is the same as the totalAmount.

Parameters:
biPMTotalAmount - the total amount in the smallest denomination for the currency.

setProfileName

protected void setProfileName(java.lang.String strProfileName)

setReturnData

protected void setReturnData(byte[] ba)

setTotalAmount

public void setTotalAmount(java.math.BigDecimal totalAmount)
Sets the totalAmount property of the command.
Specified by:
setTotalAmount in interface DoPaymentMPFInternalCmd
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 retrieves the numeric currency code from the SETCURR Table and converts the totalAmount to a normalized form required for input to WebSphere Commerce Payments. The normalized form of the amount is the amount converted to the lowest denomination of the currency. For example, if the amount is US $10.95, the normalized amount is 1095 in cents, which is the lowest denomination for this currency.
Throws:
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException
ECException

setupProfileName

protected void setupProfileName(java.lang.Integer nStoreId,
                                java.lang.Integer nPayMthdId)
                         throws javax.ejb.CreateException,
                                javax.ejb.FinderException,
                                javax.naming.NamingException,
                                java.rmi.RemoteException,
ECException
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException
ECException

updateOrderPaymentMethod

protected void updateOrderPaymentMethod()
                                 throws javax.ejb.CreateException,
                                        javax.ejb.FinderException,
                                        javax.naming.NamingException,
                                        java.rmi.RemoteException
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException

updatePaymentStatus

protected void updatePaymentStatus()
                            throws javax.ejb.CreateException,
                                   javax.ejb.FinderException,
                                   javax.naming.NamingException,
                                   java.rmi.RemoteException
javax.ejb.CreateException
javax.ejb.FinderException
javax.naming.NamingException
java.rmi.RemoteException

validateParameters

public void validateParameters()
                        throws ECException
Checks the validity of customer-supplied parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
ECException