@alguna/checkout-sdk package.
How it works
- Your server calls
POST /beta/checkout-sessionswith your secret API key and receives a session containing a browser-safesession_tokenand a hostedurl. - Your page passes that
urlto the Checkout SDK, which mounts the checkout in an iframe and keeps its size, theme, and lifecycle in sync with your page. - The customer pays inside the embedded component. Card details never touch your site or ours — they go directly to the payment processor.
- Alguna fulfills the purchase server-side and notifies you via the
checkoutsession.completedwebhook (or you poll the session).
url and session_token are browser-safe.
Creating a session
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
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 sessionid,amount,currency,accountId,paymentId,invoiceId,subscriptionId(plan sessions), and yourclientReferenceId. - Polling —
GET /beta/checkout-sessions/{id}returns the sessionstatuspluspayment_id,subscription_id, andinvoice_idonce fulfillment completes.
Session expiry
When a session expires before payment, the component reportsonError({ 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
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 withcustomer_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.