Search Overlay

Card Payment with Token

Once you have received the single-use token, you can use it to make a payment using the Card Payments API.

The single-use token is actually called token when created by the SDKs and paymentToken when created by the Vault. Also called paymentToken when used with Card Payments API in an Auth; with Direct Debit API in a Purchase; and with APMs in a Payment.

If your transactions are in multiple currencies you need to consider how you will handle the multiple merchant accounts involved and select the correct one to use when taking payment.

The payment endpoint uses the server-to-server API key. Do not use the Card Payments API from the client's web browser as this will expose this key.

Call the following endpoint from your server to take payment:

POST /cardpayments/v1/accounts/account_id/auths

curl -X POST https://api.test.paysafe.com/cardpayments/v1/accounts/1001087580/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"
},
"billingDetails": {
"street":"100 Queen Street West",
"city":"Toronto",
"state":"ON",
"country":"CA",
"zip":"M5H 2N2"
}
} '

Prior to trying the example, you should:

  • Replace the account number (1001087580) in the URL with the Test account number you received from Paysafe, according to the currency you wish to use. In this example, it's an ACH object.
  • Replace the API key user name and password (after the -u) with the Test API key you have received from Paysafe.
  • Substitute the paymentToken with the Test card token you obtained from Paysafe.js.

If your account has AVS (address verification system) enabled, you must include a billing address in the authorization call using the billingDetails object. The billing address is the address of the card represented by the payment token. Note that Developer Center test accounts have AVS enabled.

{
"links": [
{
"rel": "settlement",
"href": "https://api.test.paysafe.com/cardpayments/v1/accounts/1001087580/settlements/25c5a148-c5aa-4157-8318-c91961e1128e"
},
{
"rel": "self",
"href": "https://api.test.paysafe.com/cardpayments/v1/accounts/1001087580/auths/25c5a148-c5aa-4157-8318-c91961e1128e"
}
],
"id": "25c5a148-c5aa-4157-8318-c91961e1128e",
"merchantRefNum": "payment-token-demo-1",
"txnTime": "2017-03-06T20:42:06Z",
"status": "COMPLETED",
"amount": 520,
"settleWithAuth": true,
"preAuth": false,
"availableToSettle": 0,
"card": {
"type": "VI",
"lastDigits": "2345",
"cardExpiry": {
"month": 2,
"year": 2020
}
},
"authCode": "100614",
"billingDetails": {
"street": "100 Queen Street West",
"city": "Toronto",
"state": "ON",
"country": "CA",
"zip": "M5H2N2"
},
"merchantDescriptor": {
"dynamicDescriptor": "DD Line 1",
"phone": "000-111000099"
},
"currencyCode": "GBP",
"avsResponse": "MATCH",
"cvvVerification": "NOT_PROCESSED",
"settlements": [
{
"links": [
{
"rel": "self",
"href": "https://api.test.paysafe.com/cardpayments/v1/accounts/1001087580/settlements/25c5a148-c5aa-4157-8318-c91961e1128e"
}
],
"id": "25c5a148-c5aa-4157-8318-c91961e1128e",
"merchantRefNum": "payment-token-demo-1",
"txnTime": "2017-03-06T20:42:06Z",
"status": "PENDING",
"amount": 520,
"availableToRefund": 520
}
]
}

If the card specified or identified by a token in the request is enrolled in 3DS, there will be an authentication object in the response and this will contain details of the enrollment.

Converting a Single-Use Token to a Permanent Token

You can convert the single-use token to a re-usable permanent payment token by using it to create a profile in the Customer Vault—the paymentToken field returned in the card attribute contains the permanent token. Paysafe recommends that you verify that the single-use token corresponds to a valid card before creating the profile.