RANTANDocs
Open RANTAN
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.

HTML
<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.

Browser
<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

OptionRequiredDescription
productIdRequiredRANTAN product ID bound to the session.
sessionIdRequiredServer-created Checkout Session UUID.
clientReferenceIdOptionalMerchant reference used for an additional browser-side match.
timeoutMsOptionalWait time in milliseconds. Defaults to 30 minutes and is bounded to 60 minutes.
closeOnCompleteOptionalSet false to keep the popup open after completion.
onComplete / onClose / onTimeoutOptionalOptional 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.

Hosted URL
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.

postMessage
{
  "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

CodeDescription
CHECKOUT_SESSION_REQUIREDNo server-created sessionId was provided.
CHECKOUT_ALREADY_OPENThe same Checkout Session is already open.
CHECKOUT_CLOSEDThe buyer closed the popup before completion.
CHECKOUT_TIMEOUTThe bounded wait ended before completion.