Framework

Apple Pay JS

Use JavaScript to incorporate Apple Pay into your websites.

Overview

The Apple Pay JS API lets you accept Apple Pay payments on the web. The Apple Pay JS API is supported on the following platforms:

  • iOS 10 and later. Apple Pay JS is supported on all iOS devices with a Secure Element. It is supported both in Safari and in SFSafariViewController objects.

  • macOS 10.12 and later. Apple Pay JS is supported in Safari. The user must have an iPhone or Apple Watch to authorize the payment, or a MacBook Pro with Touch ID.

Apple Pay is available in supported regions.

The Apple Pay JS API is analogous to the PassKit framework for using Apple Pay in apps. If you have used the PassKit API, then the Apple Pay JS API should feel familiar to you.

Sample code is available here: EmporiumWeb: Request and handle Apple Pay payments on the web.

Apple Pay Requirements

There are three requirements for using Apple Pay on your website:

  • You must have an Apple Developer Account.

  • All pages that incorporate Apple Pay must be served over HTTPS.

  • Your website must comply with the Apple Pay guidelines. For more information, see Apple Pay on the Web Acceptable Use Guidelines.

Topics

First Steps

Setting Up Server Requirements

Set up your server for secure communications with Apple Pay.

Configuring Your Environment

Create your Apple Pay merchant ID and certificates, and verify your domain to start working with Apple Pay.

Maintaining Your Environment

Prevent interruptions in your Apple Pay service by keeping certificates and domain verification current.

Apple Pay Availability

Checking if Apple Pay is Available

Check if Apple Pay JS API is available and if payments are possible.

canMakePayments

Indicates whether the device supports Apple Pay.

canMakePaymentsWithActiveCard

Indicates whether the device supports Apple Pay and whether the user has an active card in Wallet.

Apple Pay Buttons

Displaying Apple Pay Buttons

Use CSS templates for displaying Apple Pay buttons on your webpage.

Choosing a Button Type

Choose the right type of button for purchases, set up, or donations.

Choosing Button Appearance

Choose the button's color and size that look best on your web page.

Localizing the Buy with Apple Pay Button

Set the language of an Apple Pay button.

Payment Request

ApplePayPaymentRequest

A request for payment, which includes information about payment processing capabilities, the payment amount, and shipping information.

Apple Pay Session

Creating an Apple Pay Session

Provide a payment request and create the session.

Providing Merchant Validation

Verify that your request is coming from a valid merchant.

ApplePaySession

A session object for managing the payment process on the web.

Status and Errors

ApplePayError

A customizable error type that you create to indicate problems with the address or contact information on an Apple Pay sheet.

ApplePayErrorCode

The error code that indicates whether an error on the payment sheet is for shipping or billing information, or for another kind of error.

ApplePayErrorContactField

Names of the fields in the shipping or billing contact information, used to locate errors in the payment sheet.

Apple Pay Status Codes

Codes used to report the status of an Apple Pay session after a callback.