Skip to main content
Embedded Checkout renders Alguna’s checkout inside your own pages — a pricing page, an in-app upgrade flow, or any purchase surface — while payment collection stays on Alguna’s secure origin. Your server mints a checkout session with the API; the browser mounts it with the @alguna/checkout-sdk package.

How it works

  1. Your server calls POST /beta/checkout-sessions with your secret API key and receives a session containing a browser-safe session_token and a hosted url.
  2. Your page passes that url to the Checkout SDK, which mounts the checkout in an iframe and keeps its size, theme, and lifecycle in sync with your page.
  3. The customer pays inside the embedded component. Card details never touch your site or ours — they go directly to the payment processor.
  4. Alguna fulfills the purchase server-side and notifies you via the checkoutsession.completed webhook (or you poll the session).
The secret API key must never reach the browser. Only the session url and session_token are browser-safe.

Creating a session

The response includes id, session_token, url, amount, currency, and expires_at. Sessions expire after expires_in_seconds (default 24 hours, minimum 5 minutes, maximum 7 days); an expired session can no longer be rendered or paid.

What the session charges

Provide exactly one of: To store a payment method without charging, set "checkout_intent": "vault" and omit all three — the checkout collects and vaults a card for later use (for example, invoice autopay). One-off invoices are created with zero tax so the invoice total always equals the amount the customer was charged. If you need tax on one-off purchases, calculate it before creating the session and include it in your line items.

Who the customer is

Three identity modes, chosen by what you pass: The component adapts automatically — there is no client-side configuration for identity. The session is the source of truth. client_reference_id is your own reference (order ID, cart ID). It is echoed on the session and on the checkoutsession.completed webhook so you can correlate completions with your records.

Mounting the checkout

Install the SDK:

React

Any framework

Options

Appearance

All appearance changes apply live via update() (or by changing the React prop) without remounting or losing form state.

Handling completion

onComplete fires in the browser the moment payment succeeds — use it to update your UI (show a success state, unlock a feature optimistically). Do not treat it as proof of purchase: browser events can be spoofed or lost. Fulfill from the server using either:
  • Webhook — subscribe to checkoutsession.completed. The payload carries the session id, amount, currency, accountId, paymentId, invoiceId, subscriptionId (plan sessions), and your clientReferenceId.
  • PollingGET /beta/checkout-sessions/{id} returns the session status plus payment_id, subscription_id, and invoice_id once fulfillment completes.
Fulfillment is asynchronous: the payment, account, and subscription or invoice attach within seconds of completion, not in the same instant the customer sees the success state.

Session expiry

When a session expires before payment, the component reports onError({ code: "session_expired" }). Mint a fresh session from your server and update the component’s url. Short-lived sessions (for example expires_in_seconds: 3600) are recommended for checkout links tied to a specific cart or price.

Restricting where checkout can be embedded

Under Settings → Workflows → Payments → Embedded checkout, you can list the origins (e.g. https://app.example.com) allowed to embed your checkout. An empty list allows any origin. This is a safeguard against accidental embedding — for example, a stale integration on a deprecated domain. It is not the security boundary: sessions are protected by their unguessable, expiring session tokens, and payment credentials never pass through the embedding page.

Example: in-app upgrade

On completion, the customer account exists in Alguna with an active subscription and a paid invoice, and your webhook endpoint receives checkoutsession.completed with clientReferenceId: "upgrade_<id>".

FAQ

Can I change what a session charges after creating it? No. Sessions are immutable snapshots of what’s being sold. Create a new session instead — they are cheap and expire on their own. How do saved payment methods work? Sessions created with customer_id for a customer with vaulted payment methods offer them automatically alongside new-card entry. What payment methods appear? The same methods as your hosted checkout, driven by your payment processor configuration and routing rules. Does the embedded component handle 3-D Secure? Yes — processor-driven authentication runs inside the component. Can I use this without the SDK? Yes. The session url is a standard hosted checkout page; you can redirect to it directly instead of embedding. The SDK adds embedding, theming, resizing, and lifecycle events.