Integrating Paysafe REST API

Once you have successfully integrated with the Apple Pay JS API or the Paysafe Request SDK, you can now complete your integration with our REST APIs to process Apple Pay transactions.

You need both your API Keys – API key for single-use token and Card API key.

Make the following sequence of API calls once you get the payload from the Apple Pay Session:

  1. Get a single-use token using the Apple Pay payment bundle

    If you have integrated Paysafe Request SDK, you already have the Paysafe single-use token. You don't need to call this endpoint.

    POST /customervault/v1/applepaysingleusetokens

    Use the API key for single-use token.

    Sample Request
    {
        "applePayPaymentToken": {
            "version": "EC_v1",
            "data": "<passkit_encrypted_payment_data>",
            "signature": "<signature_for_payment_and_header_data>",
            "header": {
                "transactionId": "b53e22ef6669ce7f50951cfd6821908f4e679f050f5a551a1b5f6202253136ae",
                "ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEB39YqvWZG0NOYjbkL5D61Mxip6uw23Q7m8gWgxL41k4fs0BgJ+MFcIGYOH86kAGL/wjiftDahRkUnzOGls2hzw==",
                "publicKeyHash": "O5gJ/P5sQ7ufMZQXA7ccLoOkJ13VNknbu+4K0TaCQXE="
            }
        }
    }
    Sample Response
    {
        "id": "a02e52c7-c991-4418-966a-b62989cb0eae",
        "paymentToken" : "CaBP0abDKgROjYU",
        "timeToLiveSeconds" : "899",
        "applePayPaymentToken": {
            "version": "EC_v1",
    		"signature": "<signature_for_payment_and_header_data>",
            "header": {
                "transactionId": "b53e22ef6669ce7f50951cfd6821908f4e679f050f5a551a1b5f6202253136ae",
                "publicKeyHash": "O5gJ/P5sQ7ufMZQXA7ccLoOkJ13VNknbu+4K0TaCQXE="
            }
        },
        "card": {
            "lastDigits": 2345
            "holderName": "Joe Smith"
        },
        "transaction": {
            "amount": 500
            "currency": "GBP"
        }
     }
  2. Call the Card Payments API using the single-use token to process the transaction

    From your server, use the single-use token (paymentToken) to make an authorization or purchase request to our Card Payments API.

    Use the Card API key.

    Call the following endpoint from your server to take payment:

    POST /cardpayments/v1/accounts/account_id/auths

    Sample Request
    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"
        }
       } '
    Sample Response
    {
      "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
        }
      ]
    }
  3. Send the response your server receives from the Card Payments API to the website.

    The Card Payments API will return a response (successful or failed) to your server, which you need to send back to your website.

Did you find this page useful?