Article

Processing Payment Requests

Process payment requests using the payment gateway endpoint.

Overview

If you support Apple Pay payment requests, you need to obtain the Apple Pay payment token from the customer's device. To receive this token, implement the payment gateway endpoint. Apple Pays calls this endpoint to send you the token and ask that you process the transaction. The URL to the endpoint must match the value in the paymentGatewayUrl field defined in the ApplePayEndpoints dictionary. For more information, see Sending an Apple Pay Payment Request.

Request

POST https://csp.example.com/paymentGateway

Parameters

The request body is a JSON dictionary with the following keys:

payment

A dictionary containing payment information. For the list of payment dictionary keys, see Payment Dictionary.

requestIdentifier

An identifier for the request. Business Chat includes the identifier in its response to the CSP.

version

The version number of the message extension schema; the version should be 1.0.

Payment Dictionary

The payment dictionary keys are:

billingContact

The customer's billing contact information. For more information, see billingContact.

paymentToken

The payment token. See Payment Token Format Reference for more information.

shippingContact

The customer's shipping address information. For more information, see shippingContact.

Sample Payment Gateway Request

POST https://csp.example.com/paymentGateway
 
content-type: application/json
 
{
    "requestIdentifier": "8EF748B5-3DC5-47AE-B185-65E91518D209",
    "version": "1.0",
    "payment": {
        "billingContact": {
            "phoneticFamilyName": "",
            "locality": "Cupertino",
            "postalCode": "95014",
            "subLocality": "",
            "administrativeArea": "CA",
            "country": "United States",
            "familyName": "Appleseed",
            "addressLines": ["1 Infinite Loop"],
            "givenName": "Johnny",
            "phoneticGivenName": "",
            "countryCode": "us"
        },
        "shippingContact": {
            "phoneNumber": "55555555555",
            "emailAddress": "user@example.com",
            "subLocality": "",
            "phoneticGivenName": "",
            "countryCode": "us",
            "phoneticFamilyName": "",
            "administrativeArea": "CA",
            "addressLines": ["1 Infinite Loop"],
            "givenName": "",
            "postalCode": "95014",
            "familyName": "",
            "locality": "Cupertino",
            "country": "United States"
        },
        "shippingMethod": {
            "amount": "0",
            "label": "In-Store Pickup",
            "detail": "Available within an hour",
            "type": "Final",
            "identifier": "in_store_pickup"
        },
        "paymentToken": {
            "transactionIdentifier": "5394..00",
            "paymentData": {
                "version": "EC_v1",
                "data": "kdHd..GQ==",
                "signature": "MIAGCSqGSIb3DQEH...AAA",
                "header": {
                    "applicationData": "94ee0..C2",
                    "transactionId": "d3b28af..f8",
                    "ephemeralPublicKey": "MFkwE..Q==",
                    "publicKeyHash": "dxCK..6o="
                }
            }
        }
    }
}

Response

After processing the payment, send a response with the transaction results and errors, if any. The body of the response is a JSON dictionary with the following fields:

errors

An array of ApplePayError types. This field is present only when the payment processing request detects errors.

status

Indicates the status of the transaction. For a list of status codes, see Apple Pay Status Codes.

Listing 2

Sample payment gateway response

{
    "status": "STATUS_SUCCESS"
}

See Also

Apple Pay Essentials

Accepting Apple Pay Payments

Accept payments from customers who use Apple Pay.

Sending an Apple Pay Payment Request

Request a payment from the customer by sending an Apple Pay payment request.