Skip to main content
Every payment link can be served two ways:
  • Compago-hosted pagehttps://app.compago.com/checkout/pl/{id} (the canonical URL you share with customers).
  • Embeddable iframehttps://app.compago.com/checkout/pl/{id}/embed (renders only the checkout form so it fits inside your own site).
The embedded URL is opt-in per integration: the same payment link can be used in both modes. There’s no setting on the link itself — just point your <iframe> at the /embed URL.

Restrictions

Embedded mode is only available for fixed-amount and subscription payment links. Product-based and flexible-amount links can’t be embedded; opening their /embed URL emits a PAYMENT_LINK_NOT_FOUND iframe event and shows a “Link de pago no disponible” message.

Embed snippet

Drop this snippet into your page, replacing the id with your payment link:
These dimensions are sized to comfortably contain the standard 3DS challenge window the buyer’s bank may render during payment authorization. Smaller envelopes risk clipping the bank’s verification dialog. The embedded checkout never self-redirects. Your page decides what to render after a successful payment by listening for the iframe events below.

Customizing the button

The submit button inside the iframe can be customized via two optional URL query parameters on the embed URL. They override the default styling for that specific embed instance — they are not stored on the payment link.
URL-encode the values: spaces become +, # becomes %23.
The Compago dashboard’s payment link detail page includes a built-in embed snippet generator that produces a ready-to-paste <iframe> with the correct URL — including any button customizations you preview in the dialog.

Iframe events

The embedded checkout sends postMessage events to the parent window so you can react without a redirect.

Events reference

Listening for events

Error codes

The error.code field on COMPAGO_PAYMENT_LINK_ERROR events lets you distinguish failure modes:
Validate that event.data.type starts with COMPAGO_PAYMENT_LINK_ before processing. This filters out unrelated postMessage events from other scripts or browser extensions.
Always verify the payment status server-side before fulfilling the order. The COMPAGO_PAYMENT_LINK_SUCCESS event confirms the checkout completed in the iframe, but your backend should call your payment verification endpoint with the paymentId from the event payload to confirm the actual transaction state.

Sizing the iframe

The embedded checkout uses a single-column responsive layout. Recommended starting dimensions:
  • Width: 100% of a max ~600 px container.
  • Height: 760 px (covers both fixed-amount and subscription links).
These dimensions are sized to comfortably contain the standard 3DS challenge window the buyer’s bank may render during payment authorization. Smaller envelopes risk clipping the bank’s verification dialog. Adjust with your own page’s design language — the iframe content remains scrollable internally if it exceeds the height you set, but the 3DS challenge does not scroll gracefully on narrow viewports.

Best practices

The COMPAGO_PAYMENT_LINK_SUCCESS event confirms the iframe checkout completed, but a malicious actor could spoof a postMessage. Send the paymentId to your backend and verify with the Compago API before fulfilling.
Other scripts and browser extensions also emit postMessage events. Always check event.data.type.startsWith('COMPAGO_PAYMENT_LINK_') before handling.
Include allow="payment" on the <iframe> so 3DS challenges and the Payment Request API work correctly inside the embed.
The buttonText and buttonColor query params are intended for developer-controlled embeds. Don’t accept them as user-supplied input — that would let third parties rewrite the button copy on your checkout.