Prerequisites
- A connected customer (via
client.getConnection()orclient.connect()). - A UI surface where you can render the Buy Button frame. For an Apple Pay quote, it renders the Apple Pay button.
Flow overview
Device and browser support
Apple Pay is available in Safari on macOS and in every iOS browser. The customer also needs a card set up in Apple Pay. In other browsers, the frame reports Apple Pay as unavailable and renders nothing. It does not offer Apple’s cross-device flow, where the page shows a QR code that the customer scans with their iPhone to approve the payment. The widget does support the cross-device flow. In a native iOS app, you can embed the Buy Button frame in aWKWebView. By default, WKWebView silently dismisses the JavaScript dialogs the frame relies on, so you must handle them through WKUIDelegate. See the frame requirements and the iOS manual integration guide.
When Apple Pay isn’t available in the customer’s environment, the frame emits an error event with code applePayUnavailable. Use it to build the experience that fits your product. For example, hide the Apple Pay option up front, or route customers who select Apple Pay to the widget with your apple_pay quote. The code sample in Execute the transaction handles this event.
Display payment methods
Use the SDK or API to fetch and display the payment methods that are available for the customer right now.Get quotes
Quotes provide real-time prices and fees for transactions. Show the contextual quote summary above the Apple Pay button. The Apple Pay sheet presents fees, so you do not need to render a fee breakdown. See Going Live for the required presentation and fee behavior for how fees relate to the source amount. Only quotes withexecutable: true can be used to execute a transaction. See the quotes API reference for the fields required to receive executable: true.
Execute the transaction
To execute a transaction, callclient.setupBuyButton() with your apple_pay quote. The buy button renders the Apple Pay button and opens the Apple Pay sheet on tap. Don’t pass headless: true. Headless mode accepts card and SEPA bank transfer quotes only, and rejects an apple_pay quote with an error event, code unsupportedPaymentMethod. For the frame URL, size, permissions, and events, see the Buy Button frame reference.
Apple Pay
Transaction statuses
Transactions have the following statuses:- Pending: The transaction has been initiated and the payment accepted. The assets are being transferred.
- Complete: The transaction is finalized. The payment is complete and the assets have been delivered to their destination.
- Failed: The transaction has failed. The payment was not executed and funds were not transferred.