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:
- Include your API key in the x-api-key parameter in the header of a POST request.
- 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
Example response
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.
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.
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.
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
Example request
Response fields
If your request is successful, our gateway starts the merchant session with Apple and returns the following fields:
Response
Example response
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
Example request
Response fields
If your request is successful, our gateway uses the card details to run a sale. The response contains the following fields:
Response
Example response
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].