Apple Pay is a digital payment method that allows cardholders to use their Apple devices to securely make purchases online or in person. By integrating with Apple Pay on PayFields, you can enhance your customers' checkout experience on your website or app by providing them with a trusted and convenient payment option.
Prerequisites
Your merchant ID allows Apple to identify you as a merchant that can accept payments. This ID never expires, and you can use it on multiple websites and iOS apps.
To create your merchant ID, log in to your Apple Developer Account using the Account Holder, Admin, or App Manager role. Do not log in using a Developer role or as a Sandbox Tester user.
The identifier name you entered is your merchant ID.
Note: If you have multiple environments, such as test and production, you may choose to create additional merchant IDs for each environment.
Example merchant IDs:
A certificate associated with the merchant ID that is used to secure transaction data.
Note: The payment processing certificate expires after 25 months. When the certificate expires, follow these instructions again to create a new certificate.
Create the private key and the Certificate Signing Request (CSR)
Create the private key for the payment processing certificate.
openssl ecparam -out private_payment_processing_test.key -name prime256v1 -genkey
Create the CSR. This is required later to generate the payment processing certificate.
openssl req -new -sha256 -key private_payment_processing_test.key -nodes -out private_payment_processing_test.csr
You will need to provide the following:
Generate the payment processing certificate and upload the CSR
A Transport Layer Security (TLS) certificate that is associated with your merchant ID and is used to authenticate sessions with the Apple Pay servers.
Note: The merchant identity certificate is only required for Apple Pay on the web. It’s not required for iOS apps.
Create the private key and the Certificate Signing Request (CSR)
openssl req -new -newkey rsa:2048 -nodes -keyout merchant.com.paygateway.test.web.key -out merchant.com.paygateway.test.web.csr
You will need to provide the following:
Generate the merchant identity certificate
openssl x509 -inform der -in merchant_id.cer -out merchant.com.paygateway.test.web.pem
To start processing transactions, you need to first register and verify your domain for Apple Pay.
Apple Pay servers don’t require domain verification for the testing or sandbox environment. You only receive domain verification files for merchant IDs that are used for the production environment.
To register and verify your domain:
Note: Keep the browser page open; you'll need to use it later to validate the URL.
Create a group of merchants to contain all of the merchant keys that will be sharing the same Apple Pay configuration. Each merchant key is linked to a terminal ID.
** Note:** All terminals in a group will be able to add, delete, and update terminals in the same group. However, you can’t create a new group using a terminal that is already linked to a group. To create a new group, you must delete a terminal from the current group, and then use that terminal to create a new group.
To create a group of merchants, use the Merchant Management API to send a POST request to the relevant endpoint. For group_name, spaces are not permitted and alphanumeric symbols are accepted.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | POST | https://api.pit.paygateway.com/merchant-management/groups |
| production | POST | https://api.paygateway.com/merchant-management/groups |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
{
"group_name": "BMW-Of-ButterField",
"entity_type": "merchant_key",
"entity_list": ["{{terminal_A_merchant_key}}, "{{terminal_B_mk}}""]
}
})){
"group_id": "1411077945",
"group_name": "BMW-Of-ButterField",
"created_by": "{{terminal_A_mk}}",
"created_date": "2023-05-18T19:38:19Z"
}
}))To update a group name, use the Merchant Management API to send a PATCH request including the group_id to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | PATCH | https://api.paygateway.com/merchant-management/groups/{group_id} |
| production | PATCH | https://api.paygateway.com/merchant-management/groups/{group_id} |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
{
"group_name": "BMW-Of-ButterField-US",
}
})){
"group_id": "1411077945",
"group_name": "BMW-Of-ButterField-US",
"entity_type": "merchant_key",
"entity_list": ["{{terminal_A_merchant_key}}, "{{terminal_B_mk}}""]
"created_by": "{{terminal_A_mk}}",
"created_date": "2023-05-18T19:38:19Z"
"modified_by": "906000103556",
"modified_date": "2023-06-18T19:45:19Z"
}
}))To update a group entity list, use the Merchant Management API to send a PATCH request to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | PATCH | https://api.paygateway.com/merchant-management/groups/{group_id}/entities |
| production | PATCH | https://api.paygateway.com/merchant-management/groups/{group_id}/entities |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
{
"entity_type": "merchant_key",
"entity_list": ["{{terminal_C_merchant_key}}, "{{terminal_D_mk}}""]
}
})){
"group_id": "1411077945",
"group_name": "BMW-Of-ButterField-US",
"entity_type": "merchant_key",
"entity_list": ["{{terminal_C_merchant_key}}, "{{terminal_D_mk}}""]
"created_by": "{{terminal_A_mk}}",
"created_date": "2023-05-18T19:38:19Z"
"modified_by": "906000103556",
"modified_date": "2023-06-18T19:45:19Z"
}
}))To delete a group of merchants, use the Merchant Management API to send a DELETE request including the group_id to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | DELETE | https://api.paygateway.com/merchant-management/groups/{group_id} |
| production | DELETE | https://api.paygateway.com/merchant-management/groups/{group_id} |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
To retrieve a group of merchants, use the Merchant Management API to send a GET request to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | GET | https://api.paygateway.com/merchant-management/groups/{group_id} |
| production | GET | https://api.paygateway.com/merchant-management/groups/{group_id} |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
To retrieve a group of merchants by entity type and value, use the Merchant Management API to send a GET request to the relevant endpoint.
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
To configure Apple Pay for a website, you need the following:
IMPORTANT: Please ensure to take a note of the group ID (group_id) and the configuration ID (config_id) returned in the response. Both parameters are required for any future updates to your configuration.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | GET | https://api.paygateway.com/merchant-management/configurations |
| production | GET | https://api.paygateway.com/merchant-management/configurations |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
{
config_request: {
"config_type": "apple-pay",
"group_id" : "{{group_id}}",
"config_attributes":[
{
"name":"merchant_identity",
"value":"{{your-apple-merchant-id}}"
},
{
"name":"merchant_domain_name",
"value":"{{domain_hosting_verified_w_apple}}"
},
{
"name":"merchant_identity_certificate",
"value":"file1"
},
{
"name":"merchant_processing_certificate",
"value":"file2"
}
]
}
file1: <<pathTo/merchant.com.domain.product.final.pem>>
file2: <<pathTo/private_payement_processing_test.key-pkcs8.key>>
}
})){
"config_id": "1411077945",
"config_type": "apple-pay",
"group_id" : "{{group_id}}",
"config_attributes":[
{
"name":"merchant_identity",
"value":"XXXXXXXXXXXXX"
},
{
"name":"merchant_domain_name",
"value":"XXXXXXXXXXXXXXX"
},
{
"name":"merchant_identity_certificate",
"value":"SCRT-XXXXXXXXXXXXXXXX"
},
{
"name":"merchant_processing_certificate",
"value":"SCRT-XXXXXXXXXXXXX"
}
]
"created_by": "{{terminal_A_mk}}",
"created_date": "2023-05-18T19:38:19Z"
}
}))To update an Apple Pay configuration, use the Merchant Management API to send a PATCH request to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | PATCH | https://api.paygateway.com/merchant-management/configurations/{config_id} |
| production | PATCH | https://api.paygateway.com/merchant-management/configurations/{config_id} |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
{
config_request: {
"config_type": "apple-pay",
"group_id" : "{{current_group_id}}",
"config_attributes":[
{
"name":"merchant_identity",
"value":"{{your-apple-merchant-id}}"
},
{
"name":"merchant_domain_name",
"value":"{{domain_host_verified_w_apple}}"
},
{
"name":"merchant_identity_certificate",
"value":"file1"
},
{
"name":"merchant_processing_certificate",
"value":"file2"
}
]
}
file1: <<pathTo/merchant.com.domain.product.final.pem>>
file2: <<pathTo/private_payement_processing_test.key-pkcs8.key>>
}
})){
"config_id": "{{config_id}}",
"config_type": "apple-pay",
"group_id" : "{{group_id}}",
"config_attributes":[
{
"name":"merchant_identity",
"value":"XXXXXXXXXXXXX"
},
{
"name":"merchant_domain_name",
"value":"XXXXXXXXXXXXXXX"
},
{
"name":"merchant_identity_certificate",
"value":"SCRT-XXXXXXXXXXXXX"
},
{
"name":"merchant_processing_certificate",
"value":"SCRT-XXXXXXXXXXXXX"
}
]
"created_by": "{{terminal_A_mk}}",
"created_date": "2023-05-18T19:38:19Z"
}
}))To delete an Apple Pay configuration, use the Merchant Management API to send a DELETE request to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | DELETE | https://api.paygateway.com/merchant-management/configurations/{config_id} |
| production | DELETE | https://api.paygateway.com/merchant-management/configurations/{config_id} |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
To retrieve an Apple Pay configuration group, use the Merchant Management API to send a GET request to the relevant endpoint.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | GET | https://api.paygateway.com/merchant-management/configurations/{config_id} |
| production | GET | https://api.paygateway.com/merchant-management/configurations/{config_id} |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
Encrypt account credentials
Important: Encrypting account credentials is only required once and not per transaction. Account credentials received from the merchant must be encrypted and stored in their encrypted state for reuse with every future transaction.
To integrate Apple Pay with PayFields, the account_credential parameter must be encrypted when you use it to generate the authTokenV2. To do so, encrypt xwebid in locationid:terminalid:authkey. Account credentials are encrypted because they are used client-side on a consumer device, and this prevents exposing the credentials when used on the Apple device.
Once encrypted, the account_credential can be used to generate the authTokenV2 which is required when configuring your payment page.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | POST | https://api.pit.paygateway.com/accounts/credentials |
| production | POST | https://api.pit.paygateway.com/accounts/credentials |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
| Parameter | Type | Description |
|---|---|---|
| app_name | String | IString format of your app name and it is case sensitive. Note: you must include either the app_name or app_id in the request. |
| app_id | String | Unique app ID that is generated by the APIGEE gateway for each onboarded partner. Note: you must include either the app_id or app_name in the request. |
| Authkey | String | The terminal auth key (the third part of your terminal xweb account). |
| merchant_id | String | The terminal location ID (the first part of your terminal xweb account). |
| terminal_id | String | The terminal ID of your terminal. |
{
"app_name": "Silverstar Home Rental Services",
"auth_key": "WaZva*****40*******************z",
"merchant_id": "800000000000",
"terminal_id": "80000000"
}
})){
"account_credential": "gNgAAe9VQKjnBBGFnoAodEfxq1zfWWHATPgmhxdHVC78kQw2rccsDFHZ50upTQZg5YtgVUlJapucdY5/wVgmbM1Bg3VhmRumwR/1JV7VWDXx2dwb"
}
}))To integrate with PayFields, you first need to configure your payment page. For more information, go to Configuring your payment page.
<script src= https://js.paygateway.com/secure_payment/v1/globalpayments.js></script>GlobalPayments.configure( {
‘X-GP-Api-Key’ : “QwAnDXXXXXXXXXXXXXXXXXXXXXXETHqV”,
‘X-GP-Environment’ : “test”,
'enableAutocomplete': true,
'Authorization' : "AuthToken {{authTokenV2}}",
'X-GP-Merchant-Key': "{{terminal-merchant-key}}"
});
}))To enable the Apple Pay button, update your payment page with the following configuration for the button. To customize your Apple Pay button, see the Apple Pay button documentation.
Note: The total object is part of the Apple Wallet processing page.
const paymentRequestForm = GlobalPayments.paymentRequest.setup("#paymentRequestPlainButton", {
total: { label: 'Donation', amount: { currency: 'USD', value: '34.00' } },
}, [{
supportedMethods: 'basic-card',
data: {supportedNetworks: ['amex', 'diners', 'discover', 'jcb', 'mastercard', 'unionpay',
'visa', 'mir'], supportedTypes: ['debit', 'credit', 'prepaid']},
}, {
supportedMethods: "https://apple.com/apple-pay",
data: {
version: 3,
merchantIdentifier: "{{your-apple-merchant-identifier}}", // usually starts with merchant.com....
merchantCapabilities: ["supports3DS", "supportsCredit", "supportsDebit"],
supportedNetworks: ["amex", "discover", "masterCard", "visa"],
countryCode: "US",
storeDisplayName: "{{store_name}}"
},
}]);
}))The gateway returns a token-success response when a customer completes and submits the pay fields. This response includes a temporary_token that you must submit to the gateway for transaction requests.
paymentRequestForm.on("token-success", (resp) => {
// Payment data was successfully tokenized
console.log('payment api token is here', resp);
// TODO: POST data with the token to your server and send it to the transaction api
// Mark the payment as `success`, `fail`, or `unknown` based on the. transaction api response
GlobalPayments.paymentRequest.complete("success");
});
}))If this is the first time processing using PayFields, you must create a transaction reference_id in your request.
| Environment | HTTP method | URL |
|---|---|---|
| TEST | POST | https://api.pit.paygateway.com/transactions/creditsales |
| production | POST | https://api.pit.paygateway.com/transactions/creditsales |
| Parameter | Type | Description |
|---|---|---|
| Content-Type | String | Indicates the type of data that you are sending in the request. Send application/json. |
| Authorization | String | Secure JSON web token (JWT) you include in the authorization header of your request, for example "Authorization": "AuthToken AuthTokenV2". |
| X-GP-Api-Key | String | Your unique API key that you use to send transaction requests. |
| X-GP-Request-Id | String | The GUID is an optional parameter that you can generate for each request. The value for this parameter should have a prefix of API-, for example API-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX. |
| X-GP-Version | String | Version of the PayFields API that you use in your integration. Send 2023-03-28. |
| X-GP-Partner-App-Name | String | Name of your application. |
{ "reference_id": "{{transaction_reference_d}}",
"card": {
"temporary_token": "{{temp_token}}"
},
"customer": {
"billing_address": {
"line1": "8200 Central Ave.",
"postal_code": "94560"
}
},
"payment": {
"amount": "0.00",
"currency_code": "840"
},
"transaction": {
"country_code": "840",
"processing_indicators": {
"create_token": true,
"address_verification_service": true,
"generate_receipt": true
}
}
}
})){
"sale_id": "000000003015",
"status": "Approved",
"approval_code": "005741",
"cardsecurity_response": "match",
"processor_response": "DEVELOPMENT APPROVAL",
"card": {
"masked_card_number": "545454XXXXXX5454",
"expiry_month": "12",
"expiry_year": "23",
"type": "MasterCard"
},
"payment": {
"amount": "33.00",
"currency_code": "840",
"reference_id": "PAYAPI-8f07eb9a-6e05-4a9f-b03d-7b05280a4ae6",
"type": "Credit"
},
"transaction": {
"batch_amount": "543.00",
"batch_number": "000253",
"entry_type": "Keyed",
"language": "en-US"
},
}
}))