Apple Pay
Apple Pay allows customers to securely complete payments using credit or debit cards linked to their Apple account. Evervault has built-in support for Apple Pay. Our Apple Pay component will intercept the Apple Pay token and provide you with direct access to the encrypted payment method, which can then be sent to any payment processor using Relay.
Sandbox testing
You can use Sandbox apps to test Apple Pay end-to-end without charging a real card. In sandbox, based on the brand of the card the customer selects in their Apple Wallet, the network token is replaced with a test card and the rest of the flow proceeds as normal. See Testing (sandbox) for more details.
Getting started
All users of Apple pay must adhere to the Apple Pay Terms and Conditions.
Create a merchant
Before you can use Apple Pay, you need to create a Merchant record to use for the transaction. You can create a merchant from inside the payments tab in the Evervault Dashboard or via the Merchants API.
Verify your domain with Apple
After creating a merchant, Apple needs to verify the domains associated with it. You can add and verify your domains using the Evervault Dashboard under Payments > Apple Pay.
Alternatively, you can serve this identifier file from /.well-known/apple-developer-merchantid-domain-association on your domain, then register your domain via the Merchant API.
You can check the status of your domain verification with Apple via the Dashboard or by using the Merchant API. It may take up to 10 minutes for the verification to complete.
Reverification
Once a domain is verified, you must ensure that the validation token is always available at the specified URL. If the validation token is not available when Apple periodically attempts to retrieve it, Apple will not be able to verify the domain, and Apple Pay will not work on your website.
Install the SDK
Our JavaScript SDK is distributed from our CDN, and can be installed by placing this script tag in the head of your HTML file. The SDK must be loaded directly from our CDN and cannot be bundled with your application or self hosted.
Once the SDK is installed, initialize it using your Team ID and App ID. You can find these in the Evervault Dashboard.
You can also install Evervault via the @evervault/js package on npm. This package is a light wrapper which handles loading the SDK from our CDN and also provides TypeScript definitions.
Frequently Asked Questions
Create a transaction
Next, you will need to create a transaction to describe the payment you want to process. You will need to provide the amount, currency, country, and merchant details for the transaction. With Apple Pay a transaction can be a Payment Transaction or a Disbursement Transaction. You can pass either transaction type to the Apple Pay component.
Pending line items
Line items default to a final amount. For estimates such as tax or shipping that aren't final yet, set type: "pending" on the line item. The Apple Pay sheet shows the line as pending instead of displaying the amount. You can also return pending line items from onShippingAddressChange, onPaymentMethodChange, onCouponCodeChange, and prepareTransaction.
Mount the Apple Pay component
Now that you have created a transaction, you can create and mount the Apple Pay component to display the Apple Pay button to your users. The Apple Pay component takes the transaction you created as a first argument and an options object with a process function that will be called with the encrypted payment method when the user completes the payment. The process function is an asynchronous function that takes the encrypted payment method as the first argument and an object with a fail function as the second argument. The fail function can be called with an error message to display an error to the user.
Abort an active session
If the user changes their shipping address to a country that uses a different currency, you cannot update the currency on an open Apple Pay sheet. Call abort() to dismiss the sheet, update your transaction with the new currency and country, then let the user tap the Apple Pay button again. Note that abort() only works before the user authorizes payment — once they've authorized, use fail() in the process callback instead.
Availability
There are several requirements that must be met for Apple Pay to be available on the device. If you are having issues with the Apple Pay component not rendering, please check the Availability section below to ensure your device meets all the requirements.
Process the payment
The process function is called when the user authorizes the payment. This is where you should finalize the payment with your payment processor. The encrypted payment method will be passed to the process function as the first argument. This should be sent to your backend which can then use Relay to safely send the decrypted payment method to any payment provider.
The full encrypted payment method object contains the following data:
The optional card.paymentMethodType field is one of credit, debit, prepaid, or store. It reflects the funding type of the card the customer selected in Apple Wallet (from the Payment Request API’s payment method). Prefer it over BIN-derived metadata such as funding when you need to know how the user intends to pay: for dual-network cards, BIN-based fields can still report credit even when the customer picked their debit card. If Apple does not provide a type, the field is omitted.
paymentDataTypereflects the Apple token format from the credentials API (for example3DSecure).transactionTypeindicates the transaction category (oneOff,recurring, ordisbursement) based on how you created the transaction.transactionIdis Apple's identifier for the token, and comes from the PKPaymentToken header. Some payment gateways require it to be passed through, though it isn't used to authorize the transaction itself.billingContactandshippingContactare only populated when the transaction requested those contact fields.shippingMethodis populated when you configuredshippingMethodsand the customer selected one.phoneticFamilyNameandphoneticGivenNameare populated when the customer's Apple Wallet contact card includes a phonetic reading of their name (common in locales like Japan). If there's no phonetic reading, then these two values arenull.
Use Apple Pay with your PSP
You can use Evervault's Apple Pay integration with any PSP. This means you:
- Don't use your PSP's Apple Pay integration.
- Use network tokens (provided by Evervault) with your PSP's APIs.
Evervault generates network tokens for Apple Pay transactions, not your PSP. After you have the network token, use it for all payments, retries, etc. with your PSP. There's no additional configuration (e.g., certificates) with your PSP or Apple needed. Most PSPs have network token APIs and parameters for passing network token data. Like other 3rd party API calls, use Relay to decrypt network token data and send it to your PSP.
Availability
You can use the availability method to check if Apple Pay is available on the device. This method returns a promise that resolves to a string indicating the availability status.
available- Apple Pay is available on the device.unavailable- Apple Pay is supported but not currently available on the device.unsupported- Apple Pay is not supported on the device.
In order for Apple Pay to be available, the user's device or browser must meet the following requirements:
- The web page must be served over HTTPS.
- Have at least one card added to their Apple Wallet.
- The user must be using a compatible browser. Apple Pay is supported on Safari, Chrome, and Edge.
- If using Safari:
- The user must have Apple Pay enabled in their browser settings. Settings > Advanced > Allow websites to check for Apple Pay and Apple card.
- The user must have access to the biometric authentication controls on their device. If using a laptop this means the laptop must not be in clamshell mode and the user must have access to the Touch ID sensor.
Customization
Apple Pay allows you to customize the appearance of the payment button with various predefined styles. These can be passed as additional options when initializing the Apple Pay component. You can see the available options in the JS SDK documentation.
Configure card networks
Apple Pay allows you to specify the card networks that are supported by your merchant. This can be done by passing the allowedCardNetworks options when initializing the Apple Pay component. You can see the available options in the Apple Pay docs. Please check with your payment processor to ensure that the card networks you specify are supported.
Restrict cards by issuer country
To limit payments to cards issued in specific countries, pass supportedCountries when initializing the Apple Pay component. Use ISO 3166 country codes. This maps to Apple Pay's supportedCountries field.
Pass application data
You can attach opaque merchant data to the Apple Pay request with applicationData. The value must be a Base64-encoded string. Apple includes a hash of this data in the payment token so you can verify it server-side. See Apple's applicationData documentation.
Apple merchant identifier
By default, Evervault uses merchant.com.evervault.{merchantId} as the Apple Pay merchant identifier. This works with Evervault's domain verification and merchant-session API.
You can pass a custom appleMerchantId when initializing the component to match the iOS SDK surface:
A custom identifier is only used by the browser to open the Apple Pay sheet. It doesn't change merchant validation — that still uses Evervault's registered identifier unless the custom ID is separately registered with Apple for your domain.
Transaction updates
Apple Pay allows you to update the transaction after a user has launched the Apple Pay modal. This can be done by leveraging the options described below.
Responding to shipping address changes
You may want to alter the transaction amount based on the shipping address provided by the user. Apple Pay allows you to respond to changes in the shipping address after a user has launched the Apple Pay modal. This can be done by passing the requestShipping and onShippingAddressChange options when initializing the Apple Pay component. The onShippingAddressChange function should return an object with an updated amount and lineItems array.
Offering shipping methods
For one-off payment transactions, you can pass shippingType and a shippingMethods list so the Apple Pay sheet lets the customer choose how their order is fulfilled. Amounts use the same smallest-currency-unit convention as line items (for example, cents). Mark one method with selected: true when the transaction amount already includes that method's cost. If none are marked selected, the first method is selected by default.
shippingMethods are only supported on one-off payment transactions — recurring and disbursement transactions reject them. Providing shippingMethods enables shipping on the sheet (requestShipping).
When the customer selects a method, the sheet total is updated. Without a merchant callback, the SDK adjusts the total using the selected method's amount (treating the transaction amount as already including the initially selected method). To control totals yourself — for example when shipping cost depends on tax or address — use onShippingMethodSelected.
When relying on the internal recompute, your initial lineItems must include an entry whose label matches the selected method's label, or the shipping line won't be replaced correctly — use
onShippingMethodSelectedfor full control.
Responding to shipping method changes
Pass onShippingMethodSelected to recompute the amount and line items when the customer picks a different shipping method. Return an updated amount and optional lineItems, the same shape as onShippingAddressChange.
Responding to billing address changes
You can leverage the requestBillingAddress and onPaymentMethodChange options when initializing the Apple Pay component to respond to changes in the billing address.
Due to limitations in the Apple Pay API, if also requesting a shipping
address, the onPaymentMethodChange event will not return the billing
address.
Prefilling billing and shipping contact
If you know the customer's billing or shipping details (for example, from a logged-in checkout), you can prefill them on the Apple Pay sheet with billingContact and shippingContact. Set requestBillingAddress: true and requestShipping: true so the postal address fields appear on the sheet.
These options apply to payment and recurring transactions only. Disbursement transactions use requiredRecipientDetails on the transaction instead.
Responding to coupon code changes
To show a coupon field on the Apple Pay sheet, set supportsCouponCode: true. Optionally pass an initial couponCode. When the customer changes the code, onCouponCodeChange runs — return an updated amount and lineItems. To reject a code, return error with code set to couponCodeInvalid or couponCodeExpired.
Updating a transaction when Apple Pay is triggered
In some scenarios, you might want to perform an action before presenting the Apple Pay modal to the customer (e.g., applying a discount collected on your own checkout page). You can do this by passing the prepareTransaction option when initializing the Apple Pay component. The prepareTransaction function returns a promise that resolves to an object with an updated amount and lineItems array.
To let customers enter a coupon on the Apple Pay sheet itself, use supportsCouponCode instead.
Content security policy (CSP)
If you are using a Content Security Policy (CSP), you will need to add the following directives to allow the Evervault SDK to function correctly.
Notes
- The Apple Pay UI Component is currently not supported on devices in Mainland China.
- The Apple Pay UI Component requires a secure context (HTTPS) to function correctly.
Testing (sandbox)
In Sandbox apps, Apple Pay follows the same integration flow as production. The customer completes a real Apple Pay authorization in Apple Wallet, and Evervault decrypts the payment credentials from that token.
The Apple Pay sandbox environment allows merchants to test their implementation of Apple Pay with test credit and debit cards.
You’ll need the following to test Apple Pay in the sandbox:
- iPhone 6 or later, iPad mini 3 or later, iPad Air 2, iPad Pro, or Apple Watch
- App Store Connect sandbox tester account
- Supported test credentials
Follow the Apple Pay sandbox guide from Apple for more information on how to set up a sandbox account and add test cards to your Apple Wallet.
This applies to both the JavaScript SDK (web) and iOS SDK. No extra request fields are required — use the Apple Pay component as documented above.
Complete Apple Pay as normal
Sandbox no longer returns a fixed Visa test card for every authorization. The card brand returned depends on which card the user selects in their Apple Wallet during the Apple Pay payment flow.
Test cards returned by brand
When the customer authorizes with a card of the given brand in their Apple Wallet, the encrypted networkToken.number you receive corresponds to:
| Number | Brand |
|---|---|
Supported brandsIn sandbox, Evervault replaces the network token with the following test numbers for each card brand. | |
4242 4242 4242 4242 | Visa |
5555 5555 5555 4444 | Mastercard |
3782 8224 6310 005 | American Express |
6011 1111 1111 1117 | Discover |
If the selected card brand is not Visa, Mastercard, American Express, or Discover, Evervault defaults to the Visa test card (4242 4242 4242 4242).