Processing of a payment is triggered by adding an initial transaction to a Commercetools payment resource. Before this can be done, the payment must be populated with the amount, a token representing the payment card and the billing address associated with the card.
-
Prepare your cart
a. Ensure your cart locale is set
b. Ensure the cart billing and shipping addresses are set. The default mapping of Commercetools address fields to Cybersource fields is as follows
NOTE: : If the cart has multiple shipping methods, the shipping address of the first available shipping method applied to the cart will be used to process the payment
Commercetools address Cybersource shipping fields Cybersource billing fields Notes firstName shipTo_firstName billTo_firstName lastName shipTo_lastName billTo_lastName streetNumber and streetName shipTo_address1 billTo_address1 If both values populated they are concatenated together with a space between. Otherwise streetName is used by itself city shipTo_city billTo_city postalCode shipTo_postalCode billTo_postalCode region shipTo_state billTo_state country shipTo_country billTo_country email shipTo_email billTo_email -
Tokenize Card details using Cybersource Flex
Skip this step when using a saved token and proceed to step 3a. Create a Commercetools payment (https://docs.commercetools.com/api/projects/payments) and populate the following
Property Value Required Notes customer Reference to Commercetools customer See notes Required for non-guest checkout. If using MyPayments API this will automatically be set to the logged in customer. One of customer or anonymousId must be populated anonymousId Id for tracking guest checkout See notes Required for guest checkout. If using MyPayments API this will automatically be set. One of customer or anonymousId must be populated amountPlanned Amount to be processed Yes Should match cart gross total, unless split payments are being used paymentMethodInfo.paymentInterface Cybersource Yes paymentMethodInfo.method creditCard Yes custom.type.key isv_payment_data Yes custom.fields.isv_merchantId Merchant Id used for the transaction No Required when you want to support Multi-Mid functionality. Populate this field with the value of merchant Id in which the transaction should happen. When this field is empty, default mid configuration will be considered for the transaction. The same mid will be used for the follow-on transactions.. b. The response should have the
isv_tokenCaptureContextSignatureandisv_tokenVerificationContextcustom fields, set theisv_tokenCaptureContextSignaturecustom field value to the captureContext of flex object which will load Cybersource MicroformflexInstance = new Flex(captureContext);c. Use the Microform Integration v2 to tokenize card details. See https://github.com/CyberSource/cybersource-flex-samples-node for an example of how to use the captureContext obtained above and the Microform JS to tokenize a Card
-
For saved token, create a Commercetools payment (https://docs.commercetools.com/api/projects/payments) and populate the following
Property Value Required Notes customer Reference to Commercetools customer See notes Required for non-guest checkout. If using MyPayments API this will automatically be set to the logged in customer. One of customer or anonymousId must be populated anonymousId Id for tracking guest checkout See notes Required for guest checkout. If using MyPayments API this will automatically be set. One of customer or anonymousId must be populated amountPlanned Amount to be processed Yes Should match cart gross total, unless split payments are being used paymentMethodInfo.paymentInterface Cybersource Yes paymentMethodInfo.method creditCard Yes custom.type.key isv_payment_data Yes custom.fields.isv_savedToken Saved token value Yes custom.fields.isv_tokens's "paymentToken" value from Customer object custom.fields.isv_tokenAlias Alias for saved token No custom.fields.isv_tokens's "alias" value from Customer object custom.fields.isv_maskedPan Masked Card number No custom.fields.isv_tokens's "cardNumber" value from Customer object.
Not required by the extension but used for displaycustom.fields.isv_cardType Card type No custom.fields.isv_tokens's "cardType" value from Customer object.
Not required by the extension but used for displaycustom.fields.isv_cardExpiryMonth Card expiry month No custom.fields.isv_tokens's "cardExpiryMonth" value from Customer object
Not required by the extension but used for displaycustom.fields.isv_cardExpiryYear Card expiry year No custom.fields.isv_tokens's "cardExpiryYear" value from Customer object
Not required by the extension but used for displaycustom.fields.isv_deviceFingerprintId Customer device fingerprint Id Yes Refer Device Fingerprinting to generate this value custom.fields.isv_saleEnabled false Yes Set the value to true if sale is enabled custom.fields.isv_merchantId Merchant Id used for the transaction No Required when you want to support Multi-Mid functionality. Populate this field with the value of merchant Id in which the transaction should happen. When this field is empty, default mid configuration will be considered for the transaction. Also see Decision Manager for additional fields to be populated if you are using Decision Manager
-
Add the payment to the cart
-
Update a Commercetools payment (https://docs.commercetools.com/api/projects/payments) and populate the following
Skip this step for saved token
Property Value Required Notes custom.fields.isv_token Cybersource flex token See notes This is the token parameter passed into the callback for the microform.createToken call
Required when not using a saved tokencustom.fields.isv_tokenAlias Alias for saved token No When this is passed the token will be saved as a subscription for later use. Merchant can either provide a input text field asking for the customer to provide value for this field or a checkbox to select if the token needs be saved as a subscription for later use. In the latter case, Merchant should provide a unique value for isv_tokenAliasupon selecting the checkboxcustom.fields.isv_maskedPan Masked Card number No Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a flexData.content.paymentInformation.card.number.maskedValuefield containing the masked card number
Not required by the extension but used for displaycustom.fields.isv_cardType Card type No Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a flexData.content.paymentInformation.card.number.detectedCardTypes[0]field containing the card type
Not required by the extension but used for displaycustom.fields.isv_cardExpiryMonth Card expiry month No Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a flexData.content.paymentInformation.card.expirationMonth.valuefield containing the card type
Not required by the extension but used for displaycustom.fields.isv_cardExpiryYear Card expiry year No Can be obtained from the token parameter passed into the callback for the microform.createToken call. The token is a JWT which when decoded has a flexData.content.paymentInformation.card.expirationYear.valuefield containing the card type
Not required by the extension but used for displaycustom.fields.isv_deviceFingerprintId Customer device fingerprint Id Yes Should pass this field to extension, if Decision Manager is enabled.Refer Device Fingerprinting to generate this value custom.fields.isv_customerIpAddress Customer IP address No Populated from client-side libraries custom.fields.isv_saleEnabled false Yes Set the value to true if sale is enabled custom.fields.isv_shippingMethod Shipping method for the order No Possible values: -
lowcost: Lowest-cost service sameday: Courier or same-day serviceoneday: Next-day or overnight servicetwoday: Two-day servicethreeday: Three-day service.-
pickup: Store pick-up -
other: Other shipping method -
none: No shipping method because product is a service or subscription
custom.fields.isv_metadata Metadata for the order No This field can be used to send additional custom data as part of the authorization request. The data should be serialized into a string format (e.g., JSON string) before passing it in the request.
Example:"isv_metadata": "{"1":"value1", "2":"value2"}"custom.fields.isv_accountPurchaseCount Required to determine account creation history and purchase activity No Provide the user's purchase count for the last six months. This value will be used to determine account creation history and populate the riskInformation section of the authorization request -
-
Add a transaction to the payment with the following values populated
If only Authorization is required, populate the following fields to the paymentProperty Value Notes type Authorization state Initial amount Amount to be processed Should match amountPlanned on payment If Sale is enabled, populate the following fields to the paymentProperty Value Notes type Charge state Initial amount Amount to be processed Should match amountPlanned on payment -
Verify the payment state and convey the payment result to the customer
a. If the transaction is successful, transaction state will be updated to Success, display the order confirmation page
b. If the state of transaction is updated to Pending which is due to Fraud, display the order confirmation page
c. If the state of transaction is updated to Failure, display the error page and See Overview#Errorhandling for handling errors or failures
When a token is saved as a subscription the saved token value will be returned as a custom property on the payment called isv_savedToken.
See Commercetools Setup for more details on the individual fields.