Payments
Apple Pay® (Beta)
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 using UI Components. 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.
Prerequisites
Register Domain with Apple
Before you can use Apple Pay, you need to set up an Evervault Merchant and register the domain where you want to display the Apple Pay button. Follow these steps:
Register your domain with Apple: Add the domain to your Evervault Merchant. Apple will verify the domain by sending a request to
https://[DOMAIN_NAME]/.well-known/apple-developer-merchantid-domain-association
.Verify the domain: The request must return the following identifier to confirm that your merchant is set up with the Evervault Apple Pay Platform:
Check verification status: You can check the verification status of your domain by retrieving the merchant details using the Get Merchant API.
For more information on registering an Evervault Merchant and an Apple Pay domain, see the Create Merchant API.
Install the Evervault SDK
To use the Apple Pay component, you will first need to install the Evervault SDK. Our JavaScript SDK is distributed from our CDN and can be loaded with a simple script tag. The SDK must be loaded directly from our CDN and cannot be bundled with your application or self hosted.
Once the SDK script has been loaded, you can initialize the SDK with your Team and App IDs.
Apple Pay 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.
Payment
A Payment Transaction can be used to obtain payment details from a customer. The card details returned can be used to process a payment with a payment processor.
Disbursement
A Disbursement Transaction can be used to obtain payment details from a customer. The card details returned can be used to process a fund transfer to the customer's card with a payment processor.
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 async 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.
Process the Payment
The process
function is triggered when the user completes the payment. It receives two parameters: data
and fail
.
data
: This is the Evervault encrypted payment method, a JSON object containing the payment details encrypted with the Evervault public key. You can send this encrypted payment method to your server and use Evervault Relay to decrypt the payment details.fail
: This function can be called to mark the payment as failed if an error occurs during the payment processing.
You can use the encrypted payment method to process the payment with a payment processor.
The data object contains the following fields:
Customize the Apple Pay Button
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 Apple Pay Docs.
Configure Card Network Support
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.
Override Apple Pay configuration
If you are looking to use an Apple Pay configuration for a feature we don't currently support, it is possible to override the Apple Pay configuration by passing the custom configuration when initializing the Apple Pay component. This can be done using the paymentOverrides
and disbursementsOverrides
fields on the Apple Pay component. Please note, you will have to specify some Evervault specific details for the configuration to work (eg: merchantIdentifier) reach out to us and we can help you with the configuration.
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 in Beta and is not supported on devices in Mainland China.
- The Apple Pay UI Component is only available on Safari on macOS and iOS devices.
- The Apple Pay UI Component requires a secure context (HTTPS) to function correctly.