java.lang.Object | +--CacheableCommandImpl | +--com.ibm.commerce.command.AbstractECTargetableCommand | +--com.ibm.commerce.command.TaskCommandImpl | +--com.ibm.commerce.command.BusinessPolicyCommandImpl | +--com.ibm.commerce.payment.commands.DoPaymentPMCmdImpl
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 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 Cashier.collectPayment() call.
The following table summarizes the parameters passed to the command and environment variables that the command passes to the Payment Cashier:
Parameter / Environment variable | Description |
---|---|
The following parameters are mandatory parameters received by the DoPaymentPMCmdImpl command from the DoPaymentMPFCmdImpl class. | |
storeId | The value for the store identification number |
Order | The OrderAccessBean representing the order. |
totalAmount | The amount of the order to be sent to WebSphere Commerce Payments. |
The following parameters are optional parameters received by the DoPaymentPMCmdImpl command from the DoPaymentMPFCmdImpl class. | |
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 parameters are optional parameters received by the DoPaymentPMCmdImpl command from the command URL. (through setting PaymentAttributes of the command) | |
cardExpiryMonth cardExpiryYear |
These two 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 two 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 WebSphere Commerce Payments 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, but are not recognized by WebSphere Commerce Payments. 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-supplied Cashier profile specifies the card_number environment variable as a value for the WebSphere Commerce Payments "$PAN" parameter which is the WebSphere Commerce Payments parameter name for credit card number and does not allow non-numeric characters. |
The following variables are environment variables that are always passed by DoPaymentPMCmdImpl to the Cashier. | |
storeId | The store ID from the storeId parameter above. |
orderId | The order ID from the Order parameter above. |
WebPath | The WebSphere Commerce application server web path. (For example, /webapp/wcs/stores/servlet |
WCSHostName | The domain-qualified host name of the WebSphere Commerce web server. |
WCSWebServerPort | The WebSphere Commerce 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. |
buyer_language_id | The language ID of the buyer from the Command Context above. |
language_encoding | The character encoding for the language of the buyer as specified by the entry in the LANGUAGE table for the language ID. |
The following Environment variables are mandatory parameters required by WebSphere Commerce Payments for all cassettes for the Cashier.collectPayment call. | |
CURRENCY | A code indicating the currency AMOUNT is in. This is the numeric currency code as per ISO 4217. |
AMOUNT | The total amount of the order. In the case of a
backorder a padding, as specified by the BOPMPADFACTOR field in the STORE
table, will be added to the total order amount in case the total amount changes
later when the inventory is available. The customer will only be charged for
the actual amount when the order is released.
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 Environment variables are used by WebSphere Commerce Payments for all cassettes if present. | |
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.
DoPaymentPMCmdImpl always passes this to the Cashier. |
PONumber | The purchase order number specified by the buyer when
submitting the order for processing.
DoPaymentPMCmdImpl passes this to the Cashier if it is present. |
The following variables are gathered by DoPaymentPMCmdImpl command from other sources | |
approval_amount | The amount to be approved in the currency's
smallest denomination.
The value for this variable is the same as the value for the AMOUNT variable except for the backorder case. In the event of a backorder situation, a small amount, as specified by the appropriate row in the CURFORMAT table for the store and currency, is used as the approval amount. The full amount will only be authorized when sufficient inventory can be allocated to release the backorder |
billtoAddressId | The Address ID of the billto address.
This parameter is either obtained from the order or from the Payment Terms and Conditions. If the Payment Terms and Conditions used includes a billto address, that take precedence over the billto address stored in the addressId field in the Orders table. The DoPaymentPMCmdImpl command uses the information from the Address table to create several billto_xxxx environment variables to pass to the Cashier. The billto_xxx environment variables are described below. |
billto_firstname billto_middlename billto_lastname billto_address1 billto_address2 billto_city billto_state billto_country billto_zipcode billto_phone_number billto_email_addr1 | 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. Certain payment cassette may 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 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 in 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 currency alpha code is obtained from the Orders table. |
Behavior
Returned Parameters:
Default Error View Name:
ErrorCodes:
PaymentConstants.ERR_CODE_MISSING_PARAM
(190) - Missing
parameterPaymentConstants.ERR_CODE_MISSING_PARAM
(1005) - Bad credit
card numberPaymentConstants.ERR_CODE_BAD_XDATE
(1006) - Bad expiry
datePaymentConstants.ERR_CODE_BAD_SYS
(1007) - A system error has
occurred.PaymentConstants.ERR_CODE_PM_COMM_ERR
(1950) - Communication
to Payment System failed. (Connection to WebSphere Commerce Payments
Failed.)PaymentConstants.ERR_CODE_PM_REJECTED
(1952) - Payment System
rejected the command due to error. (WebSphere Commerce Payments Operation
"p" for StoreId "s" OrderId "m" failed. WebSphere
Commerce Payments PrimaryRC=x, SecondaryRC=y.)This command uses the following AccessBeans:
AddressAccessBean
AccountAccessBean
CountryCodeAccessBean
CurrencyAccessBean
OrderAccessBean
OrderItemAccessBean
OrderPaymentMethodAccessBean
PaymentJDBCHelperAccessBean
StoreAccessBean
This command calls the following TaskCommands:
Field Summary |
---|
Fields inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl |
policyId,
requestProperties |
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand |
commandContext |
Fields inherited from interface com.ibm.commerce.payment.commands. DoPaymentPolicyCmd |
CC_VALID_Y_RANGE,
COPYRIGHT,
defaultCommandClassName,
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 | |
---|---|
DoPaymentPMCmdImpl() |
Method Summary | |
---|---|
protected
void |
checkParameters() Deprecated. Use validateParameters() instead. |
protected
AccountAccessBean |
getAccount() Returns the AccountAccessBean representing the Account associated with the order. |
protected
java.lang.Long |
getAccountId() Returns the account ID of the Account associated with the order. |
protected
java.lang.Long |
getBuyerPOId() Returns the internal ID of the BuyerPO record if a buyer purchase order number is specified. |
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.lang.Double |
getCurrencyFactor() Deprecated. |
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 |
getErrorViewName() Returns the name of the error view to use for reporting error. |
static java.lang.String |
getNiceBytes(byte[] bytes) |
static java.lang.String |
getNiceBytes(java.lang.String s) |
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() Returns the numeric currency code. |
protected
OrderAccessBean |
getOrder() Returns the OrderAccessBean representing the Order being processed. |
java.lang.String |
getOrderState() Returns the single character String value that this 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() Returns the total amount normalized for WebSphere Commerce Payments. |
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 WebSphere Commerce Payments. |
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 account property of the command. |
void |
setBuyerPOId(java.lang.Long n) Sets optional buyerPOId if the customer (buyer) had specified a buyer purchase order number. |
protected
void |
setContentType(java.lang.String sContentType) Sets Content Type (or MIME type) of the returned data. |
protected
void |
setCurrencyExponent(java.lang.String astrCurrencyExponent) Sets Currency Exponent. |
protected
void |
setCurrencyFactor(java.lang.Double d) Deprecated. |
void |
setErrorViewName(java.lang.String sEVN) Sets the error view to be used to report error. |
protected
void |
setNumericCurrencyCode(java.lang.String astrCurrencyCode) Sets Numeric Currency Code. |
void |
setOrder(
OrderAccessBean ab) Sets the order property of the command. |
protected
void |
setOrderState(java.lang.String orderState) Sets the order state to be returned to the caller. |
void |
setPaymentAttributes(
TypedProperty paymentAttributes) Sets the paymentAttributes property of the command. |
protected
void |
setPMTotalAmount(java.math.BigInteger biPMTotalAmount) Sets the total amount normalized for input to WebSphere Commerce Payments. |
protected
void |
setPONumber(java.lang.String sPONumber) Sets the Purchase Order Number attribute. |
protected
void |
setProfileName(java.lang.String s) Sets the Profile Name attribute. |
protected
void |
setReturnData(byte[] ba) Sets the Return Data to be returned to the caller. |
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 into a normalized form required for input to WebSphere Commerce Payments. |
protected
void |
updateOrderPaymentMethod() This method 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 class com.ibm.commerce.command. BusinessPolicyCommandImpl |
getPolicyId,
getRequestProperties,
setPolicyId,
setRequestProperties |
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 |
Methods inherited from interface com.ibm.commerce.command. BusinessPolicyCommand |
getPolicyId,
getRequestProperties,
setPolicyId,
setRequestProperties |
Constructor Detail |
---|
public DoPaymentPMCmdImpl()
Method Detail |
---|
protected void checkParameters() throws ECException
checkParameters
in class
AbstractECTargetableCommand
ECException.
ECException
protected AccountAccessBean getAccount()
protected java.lang.Long getAccountId() 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
protected java.lang.Long getBuyerPOId()
public java.lang.String getContentType()
null
if the type is not known.
getContentType
in interface
DoPaymentPolicyCmd
String
containing the name of the MIME type of the return
data, or null if the type is not knownprotected java.lang.String getCurrencyExponent()
protected java.lang.Double getCurrencyFactor()
Currency factor is the multiplication factor that could be used to convert a currency amount to its lowest denomination. For example, the currency factor for US Dollar is 100. To convert US $5.00 to cents, multiply the currency amount by the currency factor of 100. You get 500 cents.
protected java.sql.Connection getDBConnection() throws java.sql.SQLException, ECException
java.sql.SQLException
ECException
protected java.lang.String getDisplayPaymentStateForTrace(int anPaymentState)
anPaymentState
- the numeric payment state from WebSphere
Commerce Payments.protected java.lang.String getErrorViewName()
protected java.lang.String getNumericCountryCode(java.lang.String productVendor, java.lang.String country) throws ECException
productVendor
- the product/vendor character-code used for the
querycountry
- the country/region name used for the queryECException
protected java.lang.String getNumericCurrencyCode()
protected OrderAccessBean getOrder()
public java.lang.String getOrderState()
getOrderState
in interface
DoPaymentPolicyCmd
protected TypedProperty getPaymentAttributes()
protected java.math.BigInteger getPMTotalAmount()
setPMTotalAmount
protected java.lang.String getPONumber()
protected java.lang.String getProfileName()
setPaymentAttributes
public byte[] getReturnData()
getReturnData
in interface
DoPaymentPolicyCmd
protected java.math.BigDecimal getTotalAmount()
public boolean isReadyToCallExecute()
isReadyToCallExecute
in class
AbstractECTargetableCommand
public void performExecute() throws ECException
performExecute
in interface
ECCommand
performExecute
in class
AbstractECTargetableCommand
ECException
public static java.lang.String getNiceBytes(java.lang.String s)
public static java.lang.String getNiceBytes(byte[] bytes)
public java.util.Hashtable query(java.lang.String queryString) throws CashierException
This method is defined by the com.ibm.etill.cashier.Queryable interface.
queryString
- a query string in the form of an SQL Select
statement from a Cashier profileCashierException
- if there is an error creating and
populating the result Hashtable.public void reset()
This is useful if the command instance is to be called multiple times with different command parameters.
reset
in class
AbstractECTargetableCommand
public void setAccount(AccountAccessBean abAccount)
setAccount
in interface
DoPaymentPolicyCmd
abAccount
- the AccountAccessBean representing the Account the
Order is associated withpublic void setBuyerPOId(java.lang.Long n)
setBuyerPOId
in interface
DoPaymentPolicyCmd
n
- the internal ID of the BuyerPO record representing the
purchase order number specifiedprotected void setContentType(java.lang.String sContentType)
sContentType
- the Content Type of the returned
data.protected void setCurrencyExponent(java.lang.String astrCurrencyExponent)
astrCurrencyExponent
- the currency exponent of the currency
used for the orderprotected void setCurrencyFactor(java.lang.Double d)
Currency factor is the multiplication factor that could be used to convert a currency amount to its lowest denomination. For example, the currency factor for US Dollar is 100. To convert US $5.00 to cents, multiply the currency amount by the currency factor of 100. You get 500 cents.
d
- the currency factor for the currency used for the
orderpublic void setErrorViewName(java.lang.String sEVN)
setErrorViewName
in interface
DoPaymentPolicyCmd
sEVN
- the Error View nameERRTASK_NAME
protected void setNumericCurrencyCode(java.lang.String astrCurrencyCode)
astrCurrencyCode
- the currency code of the currency used for
the orderpublic void setOrder(OrderAccessBean ab)
setOrder
in interface
DoPaymentPolicyCmd
ab
- the OrderAccessBean representing the order for which
payment is to be processedprotected void setOrderState(java.lang.String orderState)
orderState
- a String
representing the preferred
order statepublic void setPaymentAttributes(TypedProperty paymentAttributes)
Some of the Payment Attributes that may be passed to the command are:
Keyword Value =========== ==================================== PONumber The purchase order number profileName The 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
For this command implementation, the profileName attribute is mandatory. This parameter normally comes from the properties field of the Policy Table entry for the payment policy used. This is the short name of the file on the file system without the .profile extension.
The cardBrand and cardNumber attributes, if specified, must both be present. Same is true for the cardExpiryMonth and the cardExpiryYear attributes.
The cardBrand attribute must match the BrandID used to configure the Merchant Account in WebSphere Commerce Payments. The BrandID is case-sensitive.
The PONumber attribute is required if the Account associated with the trading agreements used for the order includes a Purchase Order Terms and Conditions.
setPaymentAttributes
in interface
DoPaymentPolicyCmd
paymentAttributes
- the TypedProperty object that contains all
the command parameters to be passed to this command.protected void setPMTotalAmount(java.math.BigInteger biPMTotalAmount)
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.
biPMTotalAmount
- the total amount normalized for WebSphere
Commerce Paymentsprotected void setPONumber(java.lang.String sPONumber)
sPONumber
- the purchase order numberprotected void setProfileName(java.lang.String s)
s
- the profile namesetPaymentAttributes
protected void setReturnData(byte[] ba)
ba
- the byte array containing the return
datapublic void setTotalAmount(java.math.BigDecimal totalAmount)
setTotalAmount
in interface
DoPaymentPolicyCmd
totalAmount
- the total price of the Order for which payment
is to be processed.protected void setupNumericCurrencyCodeAndPMTotalAmount() 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
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
public void validateParameters() throws ECException
validateParameters
in interface
ECCommand
validateParameters
in class
AbstractECTargetableCommand
ECException.
ECException