Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

ApplePay Container

Version: 2.0.0

Configuration

The ApplePay container provides the following configuration options:

ParameterTypeReq?Description
locationPaymentLocationYesLocation where the Apple Pay button is to be rendered.
getCartIdfunctionNoRequired if createCart not provided. Should return a promise that resolves to the shopper’s cart ID.
createCart{ getCartItems: () => CartItem[]; }NoLocation where the Apple Pay button is to be rendered.
onButtonClickfunctionNoCalled when the user clicks the Apple Pay button. This callback receives a ‘showPaymentSheet’ function as its only argument that must be called to begin the Apple Pay session and show the payment sheet. IMPORTANT: The ‘showPaymentSheet’ function must be called synchronously. If called asynchronously, it will throw … an exception “Must create a newApplePaySession from a user gesture handler.”
onSuccessfunctionNoCalled when payment flow is successful.
onErrorfunctionNoCalled when the payment flow was aborted due to an error. The function receives an object with two properties, { name: string, message: string }, containing the localized error name and message. Both properties are user-facing and can be translated using the “PaymentServices.ApplePay.errors” language definitions.
hiddenbooleanNoCalled when the payment flow was aborted due to an error. The function receives an object with two properties, { name: string, message: string }, containing the localized error name and message. Both properties are user-facing and can be translated using the “PaymentServices.ApplePay.errors” language definitions.
disabledbooleanNoWhether the button is hidden. Set this to true to hide the Apple Pay button (default: false).

Slots

This container does not expose any customizable slots.

Usage

The following example demonstrates how to use the ApplePay container:

import { render as provider } from '@dropins/storefront-payment-services/render.js';
import { ApplePay } from '@dropins/storefront-payment-services/containers/ApplePay.js';
await provider.render(ApplePay, {
location: location,
getCartId: getCartId,
createCart: [],
})(block);