Websphere Commerce Payment SubSystem


Payment Subsystem got introduced in Websphere Commerce version 6.0.Before that websphere commerce multi payment frame work was used.


Let us understand details of Payment Page in Order Processing Flow.


When a shopper reaches payment screen in the shopping flow they are provided with list of payment options. As you can see from the below screen billing \payment method used is Visa Credit Card.Each of these payment method is configured in websphere commerce data base as a payment policy.




Payment SubSystem



The description of the payment method “VISA Crdeit Card” is the value of DESCRIPTION column in POLICYDESC table as shown below.
 
Payment SubSystem


Tables involved with payment policy are listed below .

POLICY Table 
Each row of this table indicates that the Trading Positions in a TradingPositionContainer are available to customers of Stores. There the Contract is deployed, subject to any terms and conditions associated with the Contract. 
POLICYTYPE Table 
This table stores information about the type of business policy for a policy.  
POLICYDESC Table 
This table stores descriptions for a business policy. 
POLICYCMD Table 
This table stores command relationship information for a business policy. 
POLICYTC Table

This table stores information about which business policy is referenced by a specific term or condition.
 
A payment instruction is a payment method plus any additional information necessary to  perform payment action. For eg: for visa payment method we need to give visa card number and expiration date.Once user enters the payment information and click on next button PIAddCmd is invoked. This controller command is used to create a new payment method to an order.PIAddCmd is responsible for persisting payment information to ORDPAYINFO table .It also creates a new record in EDPPAYINST table for the payment description. Other tables populated are  EDPORDER, PPCEXTDATA and PPCPAYINST.

Payment SubSystem

Payment SubSystem

Payment SubSystem


ORDPAYINFO
Each row in this table holds a name-value pair representing payment information for a particular Order. Values added to this table are encrypted when the "Instance/PDIEncrypt" configuration flag is "on".
EDPPAYINST
This table stores the information of the value object container Payment Instruction in Payment Rules.
EDPORDER
This table stores the information of the value object container Credit for credit-related transactions in the WebSphere Commerce Payments.
PPCPAYINST
This table stores the value object Payment Instruction in WebSphere Commerce which contains the detailed information required by plug-ins to process financial transactions. The amount in the payment instruction can be used by plug-ins to determine what is the maximum target amount the WebSphere Commerce Payments intends to consume collectively.
PPCEXTDATA 
This table records can be associated with a payment instruction or a financial transaction.The column PPCPAYINST_ID will have the paymentinstructionId or null means it is associated with financial transaction.This table has two columns ATTRIBUTENAME and DATAVALUE.ATTRIBUTENAME  will have values like bill to details(state,city,addressId,zipcode,country)Card details(expire year,month,cvc)etc  and DATAVALUE will have its values in encrypted form.
 
Submit Order

Once the payment information is entered user will reach the order summary page where user will  submit the order.During this process payment plugin will be invoked and PPCPAYMENT and PPCPAYTRAN tables are populated.Read more details in the below section.

Payment SubSystem



Payment SubSystem







 
PPCPAYMENT
This table will have the approved amount, Deposited amount and credited amount of payment related transaction.

PPCPAYTRAN
This table will have the financial transaction processed by a payment plug-in.This table will have the REQUESTEDAMOUNT (The requested amount to be processed by this financial transaction) and PROCESSEDAMOUNT by the plugin.This table also will have the response code and reason code from the back end financial system.

Steps in Payment processing flow during Order Capture are listed below.

1.When a user submits the order Order Process command invokes a payment task command called Prime Payment task command.
2.The payment task command (PrimePaymentCmdImpl) calls the Payment Rules Engine.
3.The Payment Rules Engine determines the Action that needs to be performed (For eg: Approve).
4.The Action is wrapped into an Event, which is passed to the Payment Plug-in Controller.
5.The Payment Plug-in Controller determines the Plug-in to be used.
6.The Action is invoked against the Plug-in.
7.The plugin interacts with the payment service provider.
8.Plugin sets the transaction state and update the payment related records in database.


Payment Subsystem contains following components.
1.Payment Rules Engine
2.Payment plug-in controller
3.payment plug-ins



1.Payment Rules Engine
Payment rules engine determines the action based on payment instruction, payment method and payment event which caused the action.Payment Rules engine makes use of the following configuration files.

a)PaymentMappings.xml

b)PaymentRules.xml

c)CorePaymentActions.xml

a)Paymentmapping.xml(xml/config/payments/edp/groups/default/PaymentMapping.xml)
This file configures the mapping from payment method to payment method configuration and payment actions. We can change what payment rule a payment method uses by changing the PaymentMappings XML file. We cannot change the payment rules associated with refund methods because the rules are not configurable for refund methods.

<Mapping  paymentMethod="VISA“ paymentConfiguration="CreditCardOnline“ paymentActionRule="Early Approval"/>

paymentMethod
The payment method name as defined in the POLICY table.
paymentConfiguration
The payment method is associated to a payment back-end system as defined in PaymentMethodConfigurations.xml file.
paymentActionRule
The payment actions behavior for the payment method as defined in PaymentRules.xml file.


b)PaymentRules.xml(xml/config/payments/edp/groups/default/PaymentRules.Xml) 
This is a read-only file that configures the payment rules for a store or store group. Each entry defines the target state of the relevant payment amount for each payment event in the order.

<PaymentRule name="Early Approval">
<PrimePaymentEvent targetState="APPROVED" />
<ReservePaymentEvent targetState="APPROVED" />
<FinalizePaymentEvent targetState="DEPOSITED" />
</PaymentRule>

c)CorePaymentActions.xml(xml/config/payments/edp/groups/default/CreditCardOnline/ CorePaymentActions.Xml) 
This read-only file defines how the required target state of the payment is achieved in terms of payment actions defined by the payment back-end system.

<TargetApproved>
<CurrentDNE>
<Action name="Approve" amount="requested" target="new"/>
</CurrentDNE>
</TargetApproved>

DNE Stands for doesn’t exist. Since we are submitting a new order current state is DNE.Approve Action is used for moving from DNE to approved state.An event called “APPROVE” is created by the Payment Rules Engine and it is passed to the Payment Plugin Controller.

2. Payment plug-in controller
Payment plugin controller is responsible for 
a)Creating a financial transaction .
b)Determine the plugin that services the request, and then calls plugin. Approve () method.
c)It also persists the up-to-date payment states with corresponding payment information in the payment related tables.

a)Creating a financial transaction.
A FinancialTransaction is used to track the progress of the Action as it is processed.It is populated with data associated to the Action and the Payment Instruction.The Financial Transaction object will contain attributes as shown below:

state:               new            
requested amount:   100.000        
processed amount:   0.00000        
reference number:   ...      
response code:      ...
payment ID:         10005
...
PPCPAYTRAN Table
This table stores the information of a financial transaction processed by a payment plug-in. 

b)Determine the plugin that services the request, and then calls plugin. Approve () method.
Payment plugin controller makes use of the following configuration files to determine the plugin.

a)PaymentMappings.xml

b)PaymentMethodConfigurations.xml

c)PaymetSystemPluginMapping.xml


a)PaymentMappings.xml (xml/config/payments/edp/groups/default/PaymentMapping.xml )
Payment Mappings XML file is used to get the payment configuration based on the selected payment method.

<Mapping paymentMethod="VISA"
paymentConfiguration="CreditCardOnline"
paymentActionRule="Early Approval"/>

b)PaymentMethodConfigurations.xml(xml/config/payments/edp/groups/default/ PaymentMethodConfigurations.xml )
PaymentMethodConfigurations XML file to get the payment system name based on the payment configuration.

<PaymentMethodConfiguration
name="CreditCardOnline"
paymentSystemName="Paymentech"
systemEditable="true"
humanEditable="true"
refundAllowed="true"
minimumAmount="0"
maximumAmount="Unbounded"
priority="MEDIUM"
partiallyConsumable="true"/>

c)PaymetSystemPluginMapping.xml 
PaymetSystemPluginMapping XML file to get the plug-in name based on the payment system name.

<PaymentSystemName name="Paymentech" >
<Mapping paymentConfigurationId="default" pluginName="PaymentechPlugin" >
<Keyword name="cc_cvc" mask ="-" plain="0" removeAfterApproval ="true"/>
<Keyword name="cc_nameoncard" mask ="*" plain="0" removeAfterApproval ="true"/>
<Keyword name="account" mask ="*" plain="-5" searchable="true"/>
</Mapping>
</PaymentSystemName>

Calls Plugin.Approve() method. Here it will be PaymentechPlugin.Approve().

c)Persist the up-to-date payment states with corresponding payment information in the payment related tables. 



    

3 comments:

  1. Hi Deepak,

    Good work. you are giving good amount of info on ur blog.

    As for as i know OrderProcessCmd calls PIAddCmd. but you mentioned Prime payment command which is not correct i feel. correct me if I am wrong.

    Thanks,
    Chandu

    ReplyDelete
  2. Please see the below link for more details


    http://www-01.ibm.com/support/knowledgecenter/SSZLC2_7.0.0/com.ibm.commerce.api.doc/com/ibm/commerce/edp/commands/PrimePaymentCmd.html

    ReplyDelete
  3. @Chandu PIAdd is called when the user selects the payment type in billing page and moves to order review page.

    It is used to save payment instruction in DB.

    Where as PrimePaymentCmd is invoked during order process to determine what action has to be performed , early approval or deposit based on the rules defined in xml.

    ReplyDelete