Provide a payment request and create the session.
- Apple Pay JS
- Payment Request API
After you've checked that the Apple Pay JS API is available and is enabled on the current device, you're ready to create the payment request and start the session. You can create a session only when a user explicitly asks to make a payment. For example, you can create the session when the user taps the Apple Pay button.
You supply two parameters to
Version number. The Apple Pay version you're using. (See Apple Pay on the Web Version History for version information.)
Payment Request. An
Appledictionary that contains all the information needed to display the payment sheet.
Pay Payment Request
Any Apple Pay JS API is called from an insecure page.
You pass an invalid payment request. Payment requests are invalid if they contain missing, unknown, or invalid properties, or if they have a total that is zero or less.
You attempt to create the
Appleoutside of a user gesture handler. The exception error "Must create a new ApplePaySession from a user gesture handler" appears.
After the session is created, call its
begin method to show the payment sheet.
Listing 1 shows creating a payment request and a new Apple Pay session, and displaying the payment sheet.