Process a Transaction Using a Payment Token

You can process payments using credit cards (Card Payments API) or bank accounts (Direct Debit API) that you have stored in the Customer Vault by referring to the paymentToken associated with the card or bank account. In these cases, the payment token replaces all the card or bank account information that otherwise might be included in the request (e.g., card number and expiry date).

  • When you added a card to the profile in a previous example, you got back a paymentToken with the value of CaBP0abDKgROjYU.
  • When you added a bank account to the profile in a previous example, you got back a paymentTokenwith the value of CNjEzMTM4NDg1.

You can process payments using a mobile device, e.g., with Apple Pay, by including the single-use paymentToken that is required for each mobile payment request. Single-use tokens are valid for only 15 minutes and are not consumed by verification. When you created an Apple Pay single-use token in a previous example, you got back a paymentToken with the value of ABC4AFQQBC5UR5H.

To process a credit card purchase transaction using a payment token, you must include it in a POST request to the auths endpoint in the Card Payments API. See the figure below for an overview of the steps.

Overview of Card Purchase Using Payment Token

The following example shows you how to process a credit card request using the paymentToken that represents that card.

Prior to trying the example, you should:

  • Replace the API key (after the -u) with the API key you have received.
  • Replace the account ID with your account ID.
Request Example
curl -X POST https://api.test.paysafe.com/cardpayments/v1/accounts/89987201/auths \
  -u devcentre322:B-qa2-0-53625f86-302c021476f52bdc9deab7aea876bb28762e62f92fc6712d0214736abf501e9675e55940e83ef77f5c304edc7968 \
  -H 'Content-Type: application/json' \
  -d ' {
    "merchantRefNum" : "payment-token-demo-1",
    "amount" : 500,
    "settleWithAuth":true,
    "card" : {
      "paymentToken" : "CaBP0abDKgROjYU"
    }
   } '
Value Required? Type Description
merchantRefNum Yes string The merchant's own card identification.
amount Yes integer The amount in minor currency units.
card.paymentToken Yes string The payment token representing the card used for the request.
settleWithAuth boolean true when the request is an authorization and settlement.
dupCheck boolean Set to true if this request is not a duplicate.
description string A description of the transaction provided by the merchant.
billingDetails object The request billing details.
merchantDescriptor object The merchant descriptor shown on the customer's card statement.
Response Example
{
  "links":[
    {
      "rel":"settlement",
      "href":"https://api.test.paysafe.com/cardpayments/v1/accounts/89987201/settlements/81ed5db0-971b-475b-81fd-18023732acd3"
    },
    {
      "rel":"self",
      "href":"https://api.test.paysafe.com/cardpayments/v1/accounts/89987201/auths/81ed5db0-971b-475b-81fd-18023732acd3"
    }
  ],
  "id":"81ed5db0-971b-475b-81fd-18023732acd3",
  "merchantRefNum":"payment-token-demo-1",
  "txnTime":"2014-06-09T15:57:49Z",
  "status":"COMPLETED",
  "amount":500,
  "settleWithAuth":true,
  "availableToSettle":0,
  "card":{
    "type":"VI",
    "lastDigits":"2345",
    "cardExpiry":{
      "month":12,
      "year":2019
    }
  },
  "authCode":"100001",
  "profile":{
    "firstName":"John",
    "lastName":"Smith",
    "email":"john.smith@somedomain.com"
  },
  "billingDetails":{
    "street":"100 Queen Street West",
    "city":"Toronto",
    "state":"ON",
    "country":"CA",
    "zip":"M5H2N2",
    "phone":"713-444-5555"
  },
  "merchantDescriptor":{
    "dynamicDescriptor":"test",
    "phone":"test"
  },
  "currencyCode":"USD",
  "avsResponse":"MATCH",
  "settlements":[
    {
      "links":[
        {
          "rel":"self",
          "href":"https://api.test.paysafe.com/cardpayments/v1/accounts/89987201/settlements/81ed5db0-971b-475b-81fd-18023732acd3"
        }
      ],
      "id":"81ed5db0-971b-475b-81fd-18023732acd3",
      "merchantRefNum":"payment-token-demo-1",
      "txnTime":"2014-06-09T15:57:49Z",
      "status":"PENDING",
      "amount":500,
      "availableToRefund":500
    }
  ]
}

See our API Reference section for a complete description of the parameters for this request type.

Did you find this page useful?