Hosted Checkout
Popup SDK
Open RANTAN Checkout from a browser with the hosted JavaScript SDK.
The Checkout V2 SDK opens a session-specific RANTAN Checkout popup. It is designed for a popup or direct navigation, not iframe embedding.
#Load the hosted SDK
Load the versioned Checkout contract from the RANTAN application domain. It exposes the immutable RantanCheckout global.
<script src="https://app.rantan.xyz/checkout-v2.js"></script>#Open a Checkout popup
Call open from a user gesture so browser popup blockers do not reject it. A server-created sessionId is required.
<button id="buy">Buy with RANTAN</button>
<script src="https://app.rantan.xyz/checkout-v2.js"></script>
<script>
document.querySelector("#buy").addEventListener("click", async () => {
const result = await RantanCheckout.open({
productId: 123,
sessionId: "c8a9d48e-68b2-48dd-a754-75635cae71d6",
clientReferenceId: "order_20260730_001",
});
// UI notification only. Verify this session from your backend.
await fetch("/api/orders/20260730_001/verify", { method: "POST" });
});
</script>#Options
| Option | Required | Description |
|---|---|---|
productId | Required | RANTAN product ID bound to the session. |
sessionId | Required | Server-created Checkout Session UUID. |
clientReferenceId | Optional | Merchant reference used for an additional browser-side match. |
timeoutMs | Optional | Wait time in milliseconds. Defaults to 30 minutes and is bounded to 60 minutes. |
closeOnComplete | Optional | Set false to keep the popup open after completion. |
onComplete / onClose / onTimeout | Optional | Optional UI callbacks for complete, close, and timeout. |
#Build a direct URL
RantanCheckout.url(options) returns the hosted URL without opening a window. Use it for full-page redirects or links.
https://app.rantan.xyz/checkout/123?session_id=c8a9d48e-68b2-48dd-a754-75635cae71d6#Completion result
The SDK checks event.origin, popup window identity, protocol version, product, session, and optional client reference before resolving.
{
"type": "rantan:checkout:complete",
"version": "v2",
"product_id": 123,
"purchase_id": "bfaf2aa4-dd86-4356-92db-ae0431806867",
"status": "completed",
"client_reference_id": "order_20260730_001",
"checkout_session_id": "c8a9d48e-68b2-48dd-a754-75635cae71d6"
}#SDK errors
| Code | Description |
|---|---|
CHECKOUT_SESSION_REQUIRED | No server-created sessionId was provided. |
CHECKOUT_ALREADY_OPEN | The same Checkout Session is already open. |
CHECKOUT_CLOSED | The buyer closed the popup before completion. |
CHECKOUT_TIMEOUT | The bounded wait ended before completion. |