Skip to main content
A checkout link can open inside your own page instead of sending the buyer away. Add one script and point it at the link’s URL: the checkout loads in a frame, the buyer pays without leaving your site, and your page is told when the payment finishes.

Happy path

  1. Your server creates the link with POST /v2/checkout-links (see Create Checkout Links), with the cart total and your order id in reference.
  2. Your page receives the returned data.url and renders one of the two snippets below.
  3. The buyer pays inside your page.
  4. Your server confirms the order on the transaction.paid webhook, where data.checkout_link.reference is your order id.
Treat the browser events as a hint for the interface. The order is paid when your server receives transaction.paid.

Inline

The checkout takes the place of a div in your page and grows with its content.
  • data-checkout takes the link’s url (or just its slug).
  • The script follows the page: a div rendered later, as in React or Next, mounts when it appears, and changing its data-checkout loads the new link.
  • Optional: data-locale="en" sets the checkout language.
To mount into an element of your own instead of #pagou-checkout, give it the same attributes and call PagouCheckout.mount(element):
The checkout opens over your page when the buyer clicks a button.
PagouCheckout.close() closes it from your code. Opening a second modal closes the first one.

Knowing the payment finished

It fires once per transaction, when the transaction reaches a final status (paid or refused), and status is the transaction status in lowercase. On a subscription sale it fires when the subscription starts (active, trialing or cancel_scheduled), and transaction_id is the subscription id. No buyer data comes with it.

After the payment

When the link has a success_url:
  • Same domain as your page: your page navigates to it.
  • Another domain: the checkout shows a Continue button, and the buyer clicks it to go on.

Requirements and limits

  • Your page must be served over HTTPS. The checkout refuses to load inside an http:// page.
  • Payment methods: Pix and cards (with 3-D Secure) work. Apple Pay is not offered inside an embedded checkout.
  • Custom domain: when the link URL carries your custom checkout domain, data-checkout and checkout accept it as is.
  • Custom CSS: the checkout’s custom CSS applies here too. Inline, avoid viewport heights such as 100vh, because the frame grows with its content.

Where the checkout was embedded

Every checkout session records the origin of the page that embedded it (for example, https://shop.com), and the sale carries it in attribution.embed_origin on the transaction and its webhooks. It is unknown when the browser hides the embedding page, and null when the checkout was opened on its own page. It is a record, not an access control: any HTTPS site can embed a checkout link.

Sandbox

Use https://checkout.sandbox.pagou.ai/embed.js with links created on the sandbox API.

Next steps