Add Apple Pay to your integration

Allow your merchants to accept Apple Pay as a payment method.

Integration steps

Step 1. Integrate with the Apple Pay JS API.
Step 2. Integrate with the Payroc API:
Step 2a - Start an Apple Pay session.
Step 2b - Run a sale.

Before you begin

Bearer tokens

Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps:

  1. Include your API key in the x-api-key parameter in the header of a POST request.
  2. Send your request to https://identity.payroc.com/authorize.

Note: You need to generate a new Bearer token before the previous Bearer token expires.

Example request

1curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: <api key>'

Example response

If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.

1{
2 "access_token": "eyJhbGc....adQssw5c",
3 "expires_in": 3600,
4 "scope": "service_a service_b",
5 "token_type": "Bearer"
6}

Headers

To create the header of each GET request, you must include the following parameters:

  • Content-Type: Include application/json as the value for this parameter.
  • Authorization: Include your Bearer token in this parameter.
1curl
2 -H "Content-Type: application/json"
3 -H "Authorization: <Bearer token>"

To create the header of each POST request, you must include the following parameters:

  • Content-Type: Include application/json as the value for this parameter.
  • Authorization: Include your Bearer token in this parameter.
  • Idempotency-Key: Include a UUID v4 to make the request idempotent.
1curl
2 -H "Content-Type: application/json"
3 -H "Authorization: <Bearer token>"
4 -H "Idempotency-Key: <UUID v4>"

Errors

If your request is unsuccessful, we return an error. For more information about errors, see Errors.

Step 1. Integrate with the Apple JS API

To integrate with the Apple Pay JS API, go to https://developer.apple.com/apple-pay/.

Your integration with Apple must retrieve the following information:

  • Validation URL - Apple provides the validation URL that you send to us when you create an Apple Pay session.
  • Encrypted payment details - Apple encrypts the cardholder’s payment details and returns them to your integration. After you receive the encrypted payment details, convert them to hexidecimal.

Step 2. Integrate with the Payroc API

Use our API to start the merchant session with Apple Pay and retrieve the startSessionResponse object. After you use the Apple Pay JS API to encrypt the cardholder’s payment details, use our API to run the sale.

Step 2a. Start an Apple Pay session

To start an Apple Pay session with Apple, send a request to our Apple Pay sessions endpoint.

In the body of your request, include the following parameters:

  • appleDomainId - You can view the appleDomainId after you add the merchant’s domain to the Self-Care Portal.
  • appleValidationUrl - Apple provides the validation URL as part of your integration with the Apple Pay JS API.

In the response, we return the startSessionResponse object. Send the content of the startSessionResponse object to Apple to retrieve the cardholder’s encrypted payment details.

Request parameters

To create the body of your request, use the following parameters:

Request

appleDomainIdstringRequired
Unique identifier of the merchant's domain that we assigned when you added their domain to our Self-Care Portal.
appleValidationUrlstringRequired
Validation URL from the Apple Pay JS API.

Example request

POST
/v1/processing-terminals/:processingTerminalId/apple-pay-sessions
1curl -X POST https://api.payroc.com/v1/processing-terminals/ \
2 -H "Authorization: Bearer <token>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "appleDomainId": "DUHDZJHGYY",
6 "appleValidationUrl": "https://apple-pay-gateway.apple.com/paymentservices/startSession"
7}'

Response fields

If your request is successful, our gateway starts the merchant session with Apple and returns the following fields:

Response

startSessionResponsestringRequired
Object that Apple returns when they start the merchant's Apple Pay session. Use this object to retrieve the cardholder's encrypted payment details from Apple.

Example response

Response
1{
2 "startSessionResponse": "{\n \"epochTimestamp\": 1736264582447,\n \"expiresAt\": 1736268182447,\n \"merchantSessionIdentifier\": \"SSHE464E2B91B714F18BFD19D46D0F582BF_916523AAED1343F5BC5815E12BEE9250AFFDC1A17C46B0DE5A943F0F94927C24\",\n \"nonce\": \"e5775127\",\n \"merchantIdentifier\": \"BFB110EE83BE2AF4AA7468926C926CCFC57F4A541CCE6E7F3BEFD05002ECE503\",\n \"domainName\": \"store.com\",\n \"displayName\": \"Store One\",\n \"signature\": \"308006092a864886f70d010702a0803080020101310d300b0609608648016503040201308006092a864886f70d0107010000a080308203e43082038ba003020102020859d8a1bcaaf4e3cd300a06082a8648ce3d040302307a312e302c06035504030c254170706c65204170706c69636174696f6e20496e746567726174696f6e204341202d20473331263024060355040b0c1d4170706c652043657274696669636174696f6e20417574686f7269747931133011060355040a0c0a4170706c6520496e632e310b3009060355040613025553301e170d3231303432303139333730305a170d3236303431393139333635395a30623128302606035504030c1f6563632d736d702d62726f6b65722d7369676e5f5543342d53414e44424f5831143012060355040b0c0b694f532053797374656d7331133011060355040a0c0a4170706c6520496e632e310b30090603550406130255533059301306072a8648ce3d020106082a8648ce3d030107034200048230fdabc39cf75e202c50d99b4512e637e2a901dd6cb3e0b1cd4b526798f8cf4ebde81a25a8c21e4c33ddce8e2a96c2f6afa1930345c4e87a4426ce951b1295a38202113082020d300c0603551d130101ff04023000301f0603551d2304183016801423f249c44f93e4ef27e6c4f6286c3fa2bbfd2e4b304506082b0601050507010104393037303506082b060105050730018629687474703a2f2f6f6373702e6170706c652e636f6d2f6f63737030342d6170706c65616963613330323082011d0603551d2004820114308201103082010c06092a864886f7636405013081fe3081c306082b060105050702023081b60c81b352656c69616e6365206f6e207468697320636572746966696361746520627920616e7920706172747920617373756d657320616363657074616e6365206f6620746865207468656e206170706c696361626c65207374616e64617264207465726d7320616e6420636f6e646974696f6e73206f66207573652c20636572746966696361746520706f6c69637920616e642063657274696669636174696f6e2070726163746963652073746174656d656e74732e303606082b06010505070201162a687474703a2f2f7777772e6170706c652e636f6d2f6365727469666963617465617574686f726974792f30340603551d1f042d302b3029a027a0258623687474703a2f2f63726c2e6170706c652e636f6d2f6170706c6561696361332e63726c301d0603551d0e041604140224300b9aeeed463197a4a65a299e4271821c45300e0603551d0f0101ff040403020780300f06092a864886f76364061d04020500300a06082a8648ce3d0403020347003044022074a1b324db4249430dd3274c5074c4808d9a1f480e3a85c5c1362566325fbca3022069369053abf50b5a52f9f6004dc58aad6c50a7d608683790e0a73ad01e4ad981308202ee30820275a0030201020208496d2fbf3a98da97300a06082a8648ce3d0403023067311b301906035504030c124170706c6520526f6f74204341202d20473331263024060355040b0c1d4170706c652043657274696669636174696f6e20417574686f7269747931133011060355040a0c0a4170706c6520496e632e310b3009060355040613025553301e170d3134303530363233343633305a170d3239303530363233343633305a307a312e302c06035504030c254170706c65204170706c69636174696f6e20496e746567726174696f6e204341202d20473331263024060355040b0c1d4170706c652043657274696669636174696f6e20417574686f7269747931133011060355040a0c0a4170706c6520496e632e310b30090603550406130255533059301306072a8648ce3d020106082a8648ce3d03010703420004f017118419d76485d51a5e25810776e880a2efde7bae4de08dfc4b93e13356d5665b35ae22d097760d224e7bba08fd7617ce88cb76bb6670bec8e82984ff5445a381f73081f4304606082b06010505070101043a3038303606082b06010505073001862a687474703a2f2f6f6373702e6170706c652e636f6d2f6f63737030342d6170706c65726f6f7463616733301d0603551d0e0416041423f249c44f93e4ef27e6c4f6286c3fa2bbfd2e4b300f0603551d130101ff040530030101ff301f0603551d23041830168014bbb0dea15833889aa48a99debebdebafdacb24ab30370603551d1f0430302e302ca02aa0288626687474703a2f2f63726c2e6170706c652e636f6d2f6170706c65726f6f74636167332e63726c300e0603551d0f0101ff0404030201063010060a2a864886f7636406020e04020500300a06082a8648ce3d040302036700306402303acf7283511699b186fb35c356ca62bff417edd90f754da28ebef19c815e42b789f898f79b599f98d5410d8f9de9c2fe0230322dd54421b0a305776c5df3383b9067fd177c2c216d964fc6726982126f54f87a7d1b99cb9b0989216106990f09921d00003182018930820185020101308186307a312e302c06035504030c254170706c65204170706c69636174696f6e20496e746567726174696f6e204341202d20473331263024060355040b0c1d4170706c652043657274696669636174696f6e20417574686f7269747931133011060355040a0c0a4170706c6520496e632e310b3009060355040613025553020859d8a1bcaaf4e3cd300b0609608648016503040201a08193301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3235303130373135343330325a302806092a864886f70d010934311b3019300b0609608648016503040201a10a06082a8648ce3d040302302f06092a864886f70d010904312204209a4e5d8d01ad895c444f1dc7d92737c013db0837955996dc633fb44c096dfcb3300a06082a8648ce3d04030204483046022100aef85f669578d5e2628d7e570b41558dd8504fd0050ca0e9d82db9b1120a8319022100cdbfba17f0873be9be029786e84d4e6cef99cc5c79f32d61ee73aafc157296aa000000000000\",\n \"operationalAnalyticsIdentifier\": \"Store One:BFB110EE83BE2AF4AA7468926C926CCFC57F4A541CCE6E7F3BEFD05002ECE503\",\n \"retries\": 0,\n \"pspId\": \"17D4AAA8D9357D26D771ABA0DAA0B9D3BB462AD1585492E1FE688AF8BB9558E5\"\n}\n"
3}

Step 2b. Run a sale

After you retrieve the cardholder’s encrypted payment details from Apple, use our payments endpoint to run a sale.

In your request, send the following parameters in the paymentMethod object:

type - Provide a value of digitalWallet.
serviceProvider - Provide a value of apple.
encryptedData - Provide the encrypted payment details that you retrieved from the Apple Pay JS API. The payment details must be in hexadecimal format.

Request parameters

To create the body of your request, use the following parameters:

Request

channelenumRequired
Channel that the merchant used to receive the payment details.
Allowed values:
processingTerminalIdstringRequired>=4 characters<=50 characters
Unique identifier that we assigned to the terminal.
orderobjectRequired
Object that contains information about the payment.
paymentMethodobjectRequired
Object that contains information about the customer's payment details.
operatorstringOptional>=0 characters<=50 characters
Operator who ran the transaction.
customerobjectOptional
Customer contact and address details.
ipAddressobjectOptional
Object that contains information about the IP address of the device that sent the request.
threeDSecureobjectOptional
Object that contains information for an authentication check on the customer's payment details using the 3-D Secure protocol.
credentialOnFileobjectOptional
Object that contains information about saving the customer’s payment details.
offlineProcessingobjectOptional
Object that contains information about the transaction if the merchant ran it when the terminal was offline.
autoCapturebooleanOptionalDefaults to true
Indicates if we should automatically capture the payment amount. - `true` - Run a sale and automatically capture the transaction. - `false`- Run a pre-authorization and capture the transaction later. **Note:** If you send `false` and the terminal doesn't support pre-authorization, we set the transaction's status to pending. The merchant must capture the transaction to take payment from the customer.
processAsSalebooleanOptionalDefaults to false
Indicates if we should immediately settle the sale transaction. The merchant cannot adjust the transaction if we immediately settle it. **Note:** If the value for **processAsSale** is `true`, the gateway ignores the value in **autoCapture**.
customFieldslist of objectsOptional
Array of customField objects.

Example request

POST
/v1/payments
1curl -X POST https://api.payroc.com/v1/payments \
2 -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \
3 -H "Authorization: Bearer <token>" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "channel": "pos",
7 "processingTerminalId": "1234001",
8 "order": {
9 "amount": 4999,
10 "currency": "AED",
11 "orderId": "OrderRef6543"
12 },
13 "paymentMethod": {
14 "type": "card",
15 "cardDetails": {
16 "entryMethod": "raw",
17 "device": {
18 "model": "bbposChp",
19 "serialNumber": "1850010868"
20 },
21 "rawData": "A1B2C3D4E5F67890ABCD1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"
22 }
23 }
24}'

Response fields

If your request is successful, our gateway uses the card details to run a sale. The response contains the following fields:

Response

paymentIdstringRequired=10 characters
Unique identifier that our gateway assigned to the transaction.
processingTerminalIdstringRequired>=4 characters<=50 characters
Unique identifier of the terminal that initiated the transaction.
orderobjectRequired
Object that contains information about the payment.
cardobjectRequired
Object that contains information about the card.
transactionResultobjectRequired
Object that contains information about the transaction response details.
operatorstringOptional>=0 characters<=50 characters
Operator who initiated the request.
customerobjectOptional
Customer contact and address details.
refundslist of objectsOptional
Array of refundSummary objects. Each object contains information about refunds linked to the transaction.
supportedOperationslist of enumsOptional
Array of operations that you can perform on the transaction. - `capture` - Capture the payment. - `refund` - Refund the payment. - `fullyReverse` - Fully reverse the transaction. - `partiallyReverse` - Partially reverse the payment. - `incrementAuthorization` - Increase the amount of the authorization. - `adjustTip` - Adjust the tip post-payment. - `addSignature` - Add a signature to the payment. - `setAsReady` - Set the transaction’s status to `ready`. - `setAsPending` - Set the transaction’s status to `pending`. - `setAsDeclined` - Set the transaction’s status to `declined`.
customFieldslist of objectsOptional
Array of customField objects.

Example response

Response
1{
2 "paymentId": "M2MJOG6O2Y",
3 "processingTerminalId": "1234001",
4 "order": {
5 "amount": 4999,
6 "currency": "USD",
7 "orderId": "OrderRef6543",
8 "dateTime": "2024-07-02T15:30:00Z",
9 "description": "Large Pepperoni Pizza"
10 },
11 "card": {
12 "type": "MasterCard",
13 "entryMethod": "keyed",
14 "cardNumber": "453985******7062",
15 "expiryDate": "1225",
16 "securityChecks": {
17 "cvvResult": "M",
18 "avsResult": "Y"
19 }
20 },
21 "transactionResult": {
22 "type": "sale",
23 "status": "ready",
24 "responseCode": "A",
25 "responseMessage": "OK3",
26 "approvalCode": "OK3",
27 "authorizedAmount": 4999,
28 "currency": "USD"
29 },
30 "operator": "Postman",
31 "customer": {
32 "firstName": "Sarah",
33 "lastName": "Hopper",
34 "billingAddress": {
35 "address1": "1 Example Ave.",
36 "city": "Chicago",
37 "state": "Illinois",
38 "country": "US",
39 "postalCode": "60056",
40 "address2": "Example Address Line 2",
41 "address3": "Example Address Line 3"
42 },
43 "shippingAddress": {
44 "recipientName": "Sarah Hopper",
45 "address": {
46 "address1": "1 Example Ave.",
47 "city": "Chicago",
48 "state": "Illinois",
49 "country": "US",
50 "postalCode": "60056",
51 "address2": "Example Address Line 2",
52 "address3": "Example Address Line 3"
53 }
54 }
55 },
56 "supportedOperations": [
57 "capture",
58 "fullyReverse",
59 "partiallyReverse",
60 "incrementAuthorization",
61 "adjustTip",
62 "setAsPending"
63 ],
64 "customFields": [
65 {
66 "name": "yourCustomField",
67 "value": "abc123"
68 }
69 ]
70}

Next steps

After you integrate with the Apple Pay JS API and the Payroc API, complete the following steps:

  • Set up Apple Pay for each merchant - To set up Apple Pay for a merchant to run transactions, go to Set up Apple Pay for a Merchant.
  • Set up a Sandbox Apple Account - To run test transactions with Apple Pay, set up a Sandbox Apple Account. To set up a Sandbox Apple Account, contact our Integrations Team at [email protected].