Integrating REST APIs

Once you have successfully integrated with the Google Pay API, you can now complete your integration with our REST APIs to process Google Pay transactions.

  1. Get a Paysafe single-use token using the data provided by Google Pay

    POST /customervault/v1/googlepaysingleusetokens

    Sample Request
    curl --location --request POST 'https://api.test.paysafe.com/customervault/v1/googlepaysingleusetokens' \
    --header 'Authorization: Basic T1QtMjE5OTUwOkItcWEyLTAtNWIzZTIwMTUtMC0zMDJjMDIxNDNmNzQ3MmFmZTQ0ZTM0NzlmZDM1MDllOTI4ZWZjZDNkMzAzMjZiNTQwMjE0MDIwZWI0MjhiODgzOGIxNzRjNTQ4OTFiMmNiYTA3N2RiNzZkMTkxOQ==' \
    --header 'Content-Type: application/json' \
    --data-raw '{ "googlePayPaymentToken":
            "signature": "<signature_for_payment_and_header_data>",
            "protocolVersion": "ECv1",
    		"header": {
                "transactionId": "b53e22ef6669ce7f50951cfd6821908f4e679f050f5a551a1b5f6202253136ae",
                "ephemeralPublicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEB39YqvWZG0NOYjbkL5D61Mxip6uw23Q7m8gWgxL41k4fs0BgJ+MFcIGYOH86kAGL/wjiftDahRkUnzOGls2hzw==",
                "publicKeyHash": "O5gJ/P5sQ7ufMZQXA7ccLoOkJ13VNknbu+4K0TaCQXE="
    
       }
    }
    Sample Response
    curl -d '{
        "id": "008f0f25-1de7-4317-8864-e2a74d47b93c",
        "paymentToken": "CaBP0abDKgROjYU",
        "timeToLiveSeconds": 899,
        "googlePayPaymentToken": {
            "ephemeralPublicKey": "BHaFNRf/MES0rnD7YfLizybXQO5vV+Tt4uZXJT05ksHdKpdtH/tcCiYeozqj4Y5fItkicuj5k4dgNKgG9rtvzDA=",
            "tag": "YvIVom34MTgI2J/S6vb/GX3XN7AK5NHQMuzn2dqqM20=",
            "paymentMethod": "CARD_ON_FILE",
            "messageId": "AH2EjtcRk-fyy0ddVqIa28xJXpWX43-HS7RCJIO1xo5VBGJWi2NC5XMNEtmrmny2jvx1iz4Q9_MUyGpbrN-1ajM1A1SyzrzhPkTDb_cbfzN26mPGaDJv1Utioxk8AlBkuTTrTLCsJmrT",
            "messageExpiration": "1583463591312"
        },
        "card": {
            "status": "ACTIVE",
            "cardBin": "411111",
            "lastDigits": "2345",
            "cardType": "VI",
            "cardCategory": "CREDIT"
        }
    }'

    The Test environments of Google and Paysafe return payment tokens that you can use for test purposes only. These tokens are not live chargeable tokens.

    You should check the value of the paymentMethod whether it is "CARD_ON_FILE" or "TOKENIZED CARD". Based on this information, you should use only the corresponding Paysafe merchant id.

  2. In the response, you will find a paymentToken value and the cardBin to include with your Authorization or Purchase request in the Card Payments API.

    If the paymentMethod is CARD_ON_FILE, then you should invoke the 3DS flow in compliance with the SCA requirements.
  3. From your server, call the Card Payments API to process a transaction using the single-use token.

    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. 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
        }
      ]
    }
  5. Send the response your server receives from the Card Payments API to the web.

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

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

Did you find this page useful?