Embedding the checkout
Besides redirecting the payer to the payment link, a merchant can open the checkout on its own page: on desktop the payment happens in a modal (an iframe), and on phones the payer is redirected to the checkout page. Phones are redirected because wallet apps and their links work most reliably in a full page.

Integration modes
Section titled “Integration modes”| Mode | Description |
|---|---|
| Redirect (default) | After creating the order, send the payer to checkout_url; they return to return_url when done |
| Modal / iframe | The page loads /pay/embed.js; the checkout opens in a modal on desktop and by redirect on phones |
This page covers the second mode. Creating orders is described in the Integration guide.
Step 1: register the sites allowed to embed
Section titled “Step 1: register the sites allowed to embed”By default the checkout cannot be embedded. In the console under Merchant & checkout → Merchant and look, in the merchant card, enter the https origins of the merchant’s sites in Sites allowed to embed the checkout, one per line, for example:
https://shop.exampleThe checkout allows only these sites to embed it, through the frame-ancestors directive of its Content Security Policy. A site that is not listed cannot load the checkout in an iframe, and the embed script redirects instead.
Step 2: load the script
Section titled “Step 2: load the script”Load the embed script from the checkout’s domain on the merchant page. Replace https://pay.example.com in the examples with the address of your own deployment.
Declarative
Section titled “Declarative”Give a button the data-flowpay-checkout attribute with the order’s checkout_url; a click opens the checkout:
<script src="https://pay.example.com/pay/embed.js" defer></script>
<button data-flowpay-checkout="https://pay.example.com/pay/0b3f5a52-8f7e-4c1e-9d2a-6c1f0e9b7a31">Pay</button>Programmatic
Section titled “Programmatic”const checkout = FlowPay.open(order.checkout_url, { mode: 'auto', // auto (default: modal on desktop, redirect on phones) | modal | redirect onPaid(e) { /* { order_id, status: 'paid', return_url } */ }, onExpired(e) { /* { order_id, status: 'expired' } */ }, onClose(e) { /* { order_id, reason: 'closed' | 'return' | 'blocked' | 'replaced' } */ }, redirectOnReturn: true, // "Return to merchant" on the result page sends the top-level page to the signed return_url fallback: true, // redirect to the checkout when embedding is refused (not ready within 10 s); false only fires onClose(reason: 'blocked')});checkout?.close(); // null in redirect modeThe same events are also dispatched on window, with the same detail as the callback arguments above:
window.addEventListener('flowpay:paid', (e) => refreshOrder(e.detail.order_id));// also flowpay:expired and flowpay:closedOptions
Section titled “Options”| Option | Description |
|---|---|
mode |
auto (default): modal on desktop, redirect on phones; modal: always a modal; redirect: always a redirect |
onPaid |
Called when the payment reaches the required confirmations |
onExpired |
Called when the order expires |
onClose |
Called when the modal closes; reason says why |
redirectOnReturn |
When true, pressing “Return to merchant” on the result page sends the top-level page to the signed return_url |
fallback |
When true, a refused embed (not ready within 10 seconds) redirects to the checkout; when false, only onClose fires, with reason set to blocked |
Events
Section titled “Events”| Event | Source | When |
|---|---|---|
paid |
The checkout iframe | The payment reached the required confirmations and the result page is shown |
expired |
The checkout iframe | The order expired |
closed |
The embed script | The payer closed the modal (close button, Esc or a click on the backdrop), or pressed “Return to merchant” on the result page (reason: 'return') |
Security
Section titled “Security”- The checkout sends events only when the embedding page belongs to the sites allowed to embed it; the
postMessagetarget origin is fixed to that site, and the checkout accepts no messages from the parent page. - The embed script accepts only messages that come from the checkout iframe and whose origin is the checkout’s domain.
- The result page inside the modal never loads the merchant page into the iframe: returning to the merchant is done by the top-level page.
Example page
Section titled “Example page”docs/developers/examples/embed.html in the source repository is a complete example page. Replace the checkout domain and the order link in it with your own.
Related pages
Section titled “Related pages”- Integration guide: creating orders, verifying the return signature and deciding when to ship.
- Webhooks: events and signature verification.
- Payment flow: the payer’s steps at the checkout.