Your Apple Pay integration makes REST requests to Toast's platform APIs to create payment sessions and authorize payments. This section includes information about the Toast API REST requests that your integration must make. Typically, your integration would use a server component to make Toast API requests when needed by a client component that implements a guest-facing ordering and payment interface.
Use the /merchants/{restaurantGuid}/applepay/paymentsession
endpoint of the Toast credit cards API to create an Apple Pay payment
session.
The following example shows a request to create an Apple Pay payment session.
Request to create an Apple Pay payment session
{ "validationURL": "https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession", "domain": "nicerestaurant.com", "restaurantName": "Nice Restaurant", "integrationIdentifier": "4f3d3ab6-feec-430c-9669-8844b9c818f6_nice_restaurant" }
If successful, the initiateApplePaySession API should return a merchant session response object.
{ "epochTimestamp": 1588637583664, "expiresAt": 1588641183664, "merchantSessionIdentifier": "", "nonce": "", "merchantIdentifier": "", "domainName": "domain1.com", "displayName": "My Favorite Restaurant", "signature": "" }
This session object can then be used in communicating with Apple Pay in order to retrieve an Apple Pay Payment object. The object is what needs to be passed into to completeMerchantValidation.
session.completeMerchantValidation(merchantSession);
The session should then complete validation to retrieve and display a payment sheet of payment cards available for Apple Pay. For more information, see completeMerchantValidation developer documentation.
Additional guidelines:
-
Request a new merchant session object for each transaction. You can only use a merchant session object a single time.
-
The merchant session object expires five minutes after it is created.
To authorize Apple Pay requests, you must provide the required fields in the Toast credit cards API. For more information, see Authorizing a credit card payment.
You need to pass in the encoded applicationData
as a
part of the PaymentAuthorization request.
The following example shows the message body of a request to authorize an Apple Pay payment.
{ "cardNumberOrigin": "END_USER","willSaveCard": false, "cardDataType": APPLE_PAY,
"encryptedCardData": {{APPLE PAY TOKEN BYTE ARRAY}},
"amount": 0, "keyId": "string", "tipAmount": 0, "requestMetadata": { "partnerServiceInfo": { "instanceId": "string", "additionalInfo": "string" }, "localTransactionDate": "2019-08-24T14:15:22Z", "originIPAddr": "string", "billingAddress": { "name": "string", "phone": "string", "address1": "string", "address2": "string", "city": "string", "region": "string", "postalCode": "string", "country": "string" }, "deliveryAddress": { "name": "string", "phone": "string", "address1": "string", "address2": "string", "city": "string", "region": "string", "postalCode": "string", "country": "string" }, "userAgent": "string", "guestIdentifier": "string", "guestEmail": "string", "appName": "string", "appVersion": "string", }, “applicationData”: {{base64 encoded data - SAME AS SENT TO APPLE}} } }
The value used for the “card on file”. The default value is
|
|
Set this value to |
|
The |