Live events

Use FlowHandle events and DOM events to observe checkout starts, purchases, completions, and cancellations.

plandalf.present() and plandalf.mount() return a FlowHandle: an awaitable Promise with an .events async iterable and .close() method.

Observe a checkout

const handle = plandalf.present("pro-plan");

(async () => {
  for await (const event of handle.events) {
    if (event.type === "start") console.log("Checkout opened");
    if (event.type === "purchase") console.log("Paid invoice", event.invoice_total);
    if (event.type === "complete") console.log("Flow complete", event.session?.uuid);
    if (event.type === "cancel") console.log("Dismissed", event.reason);
  }
})();

const result = await handle;

Event listener explained

const handle = plandalf.present("pro-plan")
Starts checkout and returns a FlowHandle immediately. You can listen to events before the customer finishes.
for await (const event of handle.events)
Reads live checkout events in order. This is useful for analytics, frontend unlocks, and handoffs to your own backend.
event.type === "purchase"
Runs when a paid invoice is created. This can happen before the whole flow is complete if the checkout includes upsells.
const result = await handle
Waits for the final state: completed checkout or customer dismissal.

Event types

EventWhen it fires
startThe checkout frame opens or an inline checkout mounts.
purchaseA paid invoice is created, including main purchase or upsell.
completeThe checkout flow reaches its final completion state.
cancelThe customer dismisses the frame before completing.

Close a flow

const handle = plandalf.present("pro-plan");

document.querySelector("#cancel").addEventListener("click", () => {
  handle.close();
});

Get a handle from an element

Declarative elements are tracked by the SDK. Use from() to retrieve the current handle.

<button id="buy" data-plandalf-present="pro-plan">
  Buy
</button>
const button = document.getElementById("buy");
const handle = plandalf.from(button);

from() returns the most recent open handle for that element or null.

Builder context

Move from SDK setup to the commerce surface.

SDK docs cover install, identity, gates, events, and React integration. The linked product surfaces show what the SDK is presenting or listening for.

The Numi API Keys settings page used to create organization API keys.
API keys and SDK configuration should be set before wiring checkout into an app.
The Numi Developer API documentation with sidebar navigation and SDK method reference.
SDK reference owns method details; builder resources explain the business path.
The Numi checkout requirements screen showing gate controls.
Gates decide when an offer or buying surface should be available.

Feature detail