Skip to main content
Let your customers securely add a payment method without leaving your site.

Getting a session token

Every embed is authenticated with a short-lived customer session token. Create it on your server to keep the Polar access token secret, then hand the token to the client.
The token expires after one hour and is scoped to that single customer.

Implementation

Start by installing the SDK.
PolarEmbedPaymentMethod.create() opens the embed as a full-screen modal overlay.
create() options: Open the modal from a Client Component event handler:

Inline embed (vanilla JS)

Mount a chrome-less, auto-resizing iframe into an element you control:
createInline() accepts the same options as create() (except returnUrl) plus a required element (the container to mount into).

Inline embed (React)

Use the <PolarPaymentMethod /> component:

Code Snippet

The simplest integration: add the script and a trigger element with data-polar-payment-method. Clicking the element opens the modal.
The same script also powers embedded checkout triggers — one tag covers every Polar embed.

Localization

The embed is fully localized, pass a BCP47 code via the locale option (or data-polar-payment-method-locale attribute):
When omitted, the embed defaults to English. Unsupported locales also fall back to English. See Localization for the full list of supported languages.

Events

All events are dispatched as cancelable CustomEvents on the embed instance. Call event.preventDefault() to opt out of the SDK’s default action.

Redirect-based payment methods

Some payment methods authorise on the provider’s own site. The browser navigates the whole tab away and back to returnUrl (defaults to the page the SDK was opened from), so the modal can’t survive the round-trip. Read the outcome on the returned page with the static getRedirectResult():
In React, use the usePaymentMethodRedirectResult hook to avoid writing your own effect:
Either way, the status query param is stripped from the URL so a refresh won’t surface a stale result. Card payments (3DS) complete inside the modal and never trigger this path.