Integrating with the Paysafe REST APIs

If you do not want to use the SDK, you can integrate directly with our REST APIs to process transactions.

You will need both your API Keys – API key for single-use token and API key for server-to-server API calls.

If you are using Apple Pay, before you can make API calls you need to:

  1. Modify your iOS payment application and code to:

    • Check for the availability of Apple Pay on the device
    • Retrieve the payment token from the Secure Element (SE) by integrating with the PassKit framework
  2. Set up Xcode to enable Apple Pay within your iOS application

Once you have integrated with PassKit to check for the availability of Apple Pay on the device, and are able to retrieve the payment token, follow the steps below to make calls to our REST APIs to process the Apple Pay transactions.

API Calls

The following sequence for API calls applies to both Apple Pay and mobile card payment methods.

  1. Call the Customer Vault API from the iOS device to get a single-use token.

    Using your API key for single-use tokens, call our Customer Vault API from your iOS payment application to get a single-use token.

    You need to provide either the card data (for a regular card payment) or the Apple Pay payment bundle data (for an Apple Pay payment). See the following examples:

    Option A – Get a single-use token using card data

    POST /customervault/v1/singleusetokens

    Sample Request
    {
        "card": {
            "holderName": "MR. JOHN SMITH",
            "cardNum": "4111111111111111",
            "cardExpiry": {
                "month": 12,
                "year": 2019
            },
            "billingAddress": {
                "street": "100 Queen Street West",
                "street2": "Unit 201",
                "city": "Toronto",
                "country": "CA",
                "state": "ON",
                "zip": "M5H 2N2"
            }
        }
    }
    Sample Response
    {
        "id": "a02e52c7-c991-4418-966a-b62989cb0eae",
        "paymentToken": "abcdefg23d32d2",
        "timeToLiveSeconds": 899,
        "card": {
            "cardBin": "411111",
            "lastDigits": "1111",
            "holderName": "MR. JOHN SMITH",
            "cardType": "VI",
            "cardExpiry": {
                "month": 12,
                "year": 2019
            }
        },
        "billingAddress": {
            "street": "100 Queen Street West",
            "street2": "Unit 201",
            "city": "Toronto",
            "country": "CA",
            "state": "ON",
            "zip": "M5H 2N2"
        }
    }

    Option B – Get a single-use token using the Apple Pay payment bundle

    POST /customervault/v1/applepaysingleusetokens

    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" : "ABC4AFQQBC5UR5H",
        "timeToLiveSeconds" : "899",
        "applePayPaymentToken": {
            "version": "EC_v1",
    		"signature": "<signature_for_payment_and_header_data>",
            "header": {
                "transactionId": "b53e22ef6669ce7f50951cfd6821908f4e679f050f5a551a1b5f6202253136ae",
                "publicKeyHash": "O5gJ/P5sQ7ufMZQXA7ccLoOkJ13VNknbu+4K0TaCQXE="
            }
        },
        "card": {
            "lastDigits": "1111",
            "holderName": "Joe Smith"
        },
        "transaction": {
            "amount": 1000,
            "currency": "USD"
        }
     }
  2. Send the single-use token received in step 1 to your server.

    From your mobile application, send this single-use payment token to your server (which is set up to make server-to-server calls to our REST APIs for the rest of the flow).

  3. From your server, and using the single-use token, call the Card Payments API to process a transaction.

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

    This call needs to be made using the API key for server-to-server API calls.

  4. Send the response your server receives from the Card Payments API to the iOS device or application.

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

    The request and response format is the same as for regular tokenized card payments requests and responses.

Did you find this page useful?