Skip to content

Latest commit

 

History

History
126 lines (90 loc) · 29.9 KB

File metadata and controls

126 lines (90 loc) · 29.9 KB

Process a Card Payment (Without Payer Authentication)

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.

Card Payment without Payer Auth Sequence Diagram

Payment Flow

Details

  1. 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
  2. Tokenize Card details using Cybersource Flex

    Skip this step when using a saved token and proceed to step 3
    

    a. 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_tokenCaptureContextSignature and isv_tokenVerificationContext custom fields, set the isv_tokenCaptureContextSignature custom field value to the captureContext of flex object which will load Cybersource Microform

    flexInstance = 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

  3. 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 display
    custom.fields.isv_cardType Card type No custom.fields.isv_tokens's "cardType" value from Customer object.
    Not required by the extension but used for display
    custom.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 display
    custom.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 display
    custom.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

  4. Add the payment to the cart

  5. 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 token
    custom.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_tokenAlias upon selecting the checkbox
    custom.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.maskedValue field containing the masked card number

    Not required by the extension but used for display
    custom.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 display
    custom.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.value field containing the card type

    Not required by the extension but used for display
    custom.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.value field containing the card type

    Not required by the extension but used for display
    custom.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 service
    • oneday: Next-day or overnight service
    • twoday: Two-day service
    • threeday: 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
  6. Add a transaction to the payment with the following values populated

    If only Authorization is required, populate the following fields to the payment
    
    Property 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 payment
    
    Property Value Notes
    type Charge
    state Initial
    amount Amount to be processed Should match amountPlanned on payment
  7. 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

Stored values

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.