Skip to content

ApplePay Container

Version: 3.1.0

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[]; }NoProvides cart items when getCartId is not used.
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 new ApplePaySession 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.
hiddenbooleanNoWhether the Apple Pay button is hidden from the layout.
disabledbooleanNoWhether the Apple Pay button is disabled. Set this to true to disable the button (default: false).

This container does not expose any customizable slots.

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);