Goal
Enable a user to pay with Apple Pay by initializing the Push Apple Pay launcher, displaying the payment sheet, and authorizing the payment.Sequence Diagram
Steps
Step 1: Initialize the Apple Pay launcher
What you need to do
Generate an Apple Pay URL, initialize the Push SDK launcher, and render the Apple Pay button if supported.If a user has not previously used Push, you must first register them following the create-user guide.
How to do it
-
Call create-user-url with
type: "apple_pay"when the user loads the payment page. - Initialize the launcher with the returned URL.
-
Check
ApplePaySession.canMakePayments()and render the Apple Pay button.
Initialization Example
Initialization Example
Example code to generate a URL, initialize the Apple Pay launcher, and conditionally render the button.
If you want to support Apple Pay on non-Apple devices (or if you are not using Safari), install the Apple Pay JS SDK on your cashier. Initiating the payment will display a QR code which you will scan with an Apple device to authorize the payment.
Step 2: Display the payment sheet
What you need to do
When the user clicks the Apple Pay button, launch the payment sheet using the SDK.How to do it
-
Call
launcher.display()with the paymentamount,currency,direction, and anonAuthorizecallback. - The SDK handles merchant validation and presents the Apple Pay payment sheet to the user.
-
You may optionally provide an
onCompletecallback that runs when the Apple Pay payment sheet is dismissed.
Display Example
Display Example
Example code to launch the Apple Pay payment sheet.
https://your-domain.com/.well-known/apple-developer-merchantid-domain-association.txt to complete domain verification.
Step 3: Authorize the payment
What you need to do
Handle theonAuthorize callback to receive the token and call the Push API to authorize the payment.How to do it
-
The
onAuthorizecallback receives atokenafter the user authorizes via Face ID / Touch ID. -
Pass the
token, along withamount,currency, anddirectionto authorize-payment. -
Return the intent status (i.e.
approvedordeclined) from the callback to complete the Apple Pay session.
Authorization Example
Authorization Example
The amount and currency passed to
POST /authorize must match the values provided to display(). The return value of onAuthorize is used to complete the Apple Pay session — return 'approved' for a successful payment or 'declined' otherwise.Integration checklist
- Simulate an approved transaction by submitting a payment
- Simulate a declined transaction by submitting a transaction for $0.01
- Verify domain association file is in place at
https://your-domain.com/.well-known/apple-developer-merchantid-domain-association.txt