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 Google Pay, before you can make API calls you will need to:

  1. Modify your Android payment application and code to:

    • Verify that Google Pay is supported on the device
    • Retrieve the payment token
  2. Set up Google Pay to enable payments within your Android application

Once you have checked the availability of Google 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 Google Pay transactions.

API Calls

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

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

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

    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 Google Pay payment bundle

    POST /customervault/v1/googlepaysingleusetokens

    If you are not using the Paysafe SDK, you must integrate Google Pay to generate the payment bundle.

    Sample Request
    {
      "googlePayPaymentToken": {
        "signature": "MEYCIQC3SyFpLO3yVxqYeVDeFJ8rHbkSSe4TyuATINrAMmzf9AIhALusXhNPJvWVoEUo5ZjSXIK8dx/GMswkdQiqp4/xCd/D",
        "protocolVersion": "ECv1",
        "signedMessage": "<signed_message_from_google_payment_api>"
      }
    }
    Sample Response for Card on File
    {
      "id": "a02e52c7-c991-4418-966a-b62989cb0eae",
      "paymentToken": "GTCJskXfjWqo34U",
      "timeToLiveSeconds": 899,
      "googlePayPaymentToken": {
        "ephemeralPublicKey": "BDR57RpnLXtBEuKZfuVKNTym9u2q93bXxAds+Gpe0VwBw8nL6dyMaEENB4hnXRglx0QQYRHoxc1qKwNBqBnx4qY=",
        "tag": "8EKZt7vGFjtvuukkWlc5U93h+PBxjB7YKJF/w32Wfk8=",
        "paymentMethod": "CARD_ON_FILE",
        "messageId": "AH2EjtdtxE5P5FVoHjoVhVJiaslejbWZePOtu2G2nyZYJpZVIWeNV_tJYodBbX9iuZWMCUe_aBOVim6sKd1u2-KUSia5C9WNqGw7tTVy1epkqjxDhMBCnxQ6C8WJcMJ9luBWWjOnrHzb",
        "messageExpiration": "1506708174199"
      },
      "card": {
        "status": "ACTIVE",
        "cardBin": "411111",
        "lastDigits": "8298",
        "cardType": "VI"
      }
    }
    Sample Response for Android Pay Card
    {
    	"id": "a02e52c7-c991-4418-966a-b62989cb0eae",
    	"paymentToken": "GTCJskXfGXTYbsejEDnGQt3jWqo34U",
    	"timeToLiveSeconds": 899,
    	"googlePayPaymentToken": {
    		"ephemeralPublicKey": "BCTSvnX1fF6b64NPlKwJl1r1dAfF0vAWHoktOS4CwH1BocAjnBHfHvKyX2CSM7jf7Cv1b6YfrQMkY9+hgE0dzgY=",
    		"tag": "8EKZt7vGFjtvuukkWlc5U93h+PBxjB7YKJF/w32Wfk8=",
    		"authMethod": "3DS",
    		"tdsCryptogram": "AgAAAAAABk4DWZ4C28yUQAAAAAA=",
    		"tdsEciIndicator": "07",
    		"paymentMethod": "TOKENIZED_CARD",
    		"messageId": "AH2EjtfdYZ6GzEduMx5KnnTyAwfuB7fzoIQD483zShYR7Az29Hwx7_6kS5PlD_1A_zHght_YSl2-FxEsKXWW3fF2ZTJMgbrxBUYvYLOzDnLT3X0dYppVbFpVT0_WyCOmKC9UdrTYWDdl",
    		"messageExpiration": "1506708174199"
    	},
    	"card": {
    		"status": "ACTIVE",
    		"cardBin": "489537",
    		"lastDigits": "3478",
    		"cardType": "VI"
    	}
    }
  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 Android 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?