Skip to main content

URL

Requirements

Size

The frame container height must be 44px. Width is flexible; the Apple Pay button inside the frame uses 100% of the container width. If you set a custom height through applePayButtonSettings, size the frame container to match that height instead of 44px.

Permissions

The payment permission policy is required. In test mode, the frame uses window.confirm to simulate the Apple Pay payment. If your iframe uses the sandbox attribute, you will need to include allow-modals.
Example

WKWebView

To embed the Apple Pay frame in a native iOS app, you render it inside a WKWebView. The frame communicates with the host app through the postMessage-based frames protocol. See Events below. You must handle JavaScript dialogs. The frame uses window.confirm, for example to present the simulated Apple Pay sheet in test mode. By default a WKWebView silently dismisses window.confirm, alert, and prompt: the call returns false with no UI shown, and the frame reads that as the customer cancelling, so the transaction comes back with status: "failed". To fix this, conform your view controller to WKUIDelegate, set webView.uiDelegate, and present the confirm panel, for example as a UIAlertController:
Wire this even if you only ship live mode, since the default behaviour applies to any dialog the frame surfaces. For a complete native walkthrough that covers rendering the frame, wiring the bridge and events, and the full dialog handler, see iOS manual integration.

Initialization parameters

Apple Pay button settings

Use applePayButtonSettings to style the Apple Pay button without injecting custom CSS. Build a settings object, pass it through JSON.stringify, URL-encode the result, and append it to the frame URL. Every property is optional. Any property you omit keeps the button’s default. Dimensions accept pixels only. A bare number is treated as pixels and normalized to a px value.

Validation

Validation applies each property on its own:
  • A property with an invalid value is ignored, and the remaining valid properties still apply. Invalid values include a non-pixel dimension such as 50%, and a style, type, or locale outside its allowed set.
  • If the whole value is not valid JSON, the frame ignores applePayButtonSettings entirely and uses the defaults.

Example

This object sets a 52px-tall white button with a 26px corner radius, the buy label, and French text:
Run it through JSON.stringify, URL-encode the result, and append it to the frame URL:
If you set a custom height, size the frame container to match.

Events

All events are dispatched using the message pattern described in the frames protocol. Below are the event payloads specific to the Apple Pay frame.

Outbound events

frame->parent These events are sent from this frame to the parent window.

handshake

The frame requests that you open a message channel.

ready

The frame finished loading and the UI is fully rendered. You can use this to coordinate UI transitions if needed.

buttonPressed

The customer tapped the Apple Pay button. The frame emits this the instant the button is tapped, before iOS presents the PassKit payment sheet. Treat it as an intent-to-buy signal: use it to react to the tap, for example to show a loading state or fire analytics. This event carries no payload. Route it by channelId. buttonPressed is not a purchase outcome. It still fires if the customer opens the payment sheet and then cancels, and it fires before any authorization happens. For the transaction result, listen for complete, which reports the outcome once the payment resolves.

complete

The transaction is complete. Use the transaction ID to track status updates (for example, by polling or via webhooks).
Failure codes
When a complete event has status: "failed", the failureCode field indicates the failure category. Use this value — not failureReason — for programmatic branching. failureReason is a human-readable fallback suitable for display when you do not have custom copy for a given code.
failureCode is optional. When the frame cannot classify a failure, it sends failureReason alone — fall back to showing that message to the customer.
Quote expiry is reported through the error event with code: "quoteExpired", not through complete. Listen for both events to cover all failure paths.

challenge

Verification is required before the transaction can proceed. Render the challenge frame at the provided URL. Do not construct the URL yourself — use it as-is.

cancelled

The customer dismissed the native Apple Pay sheet without completing the payment. This is a user cancellation, not a failure, so handle it separately from error. Re-enable your UI so the customer can try again, and log the abandonment if you track it. The payload carries code: "payment_sheet_dismissed" and a developer-facing message. The message is not intended to be rendered in UI.

error

This event dispatches errors that occur in the flow and, if available, provides steps for recovery.

Inbound events

parent->frame These events are sent from the parent window to this frame.

ack

Acknowledge the handshake.

setQuote

Provide a new quote to the frame. Pass signature as returned by the quote endpoint. Upon receiving this event, the frame disables the Apple Pay button until the quote is revalidated.