Checkout Flows
Open a custom checkout flow that you authored in Loby Cloud. A flow can mix memberships, gift cards, tickets, events, products, donations, and marketing consent in the order you defined.
Membership add-ons on a MEMBERSHIP step work the same way as on the hosted checkout flow page.
Basic Usage
await Loby.waitForCheckoutReady() Loby.checkout({ type: 'CHECKOUT_FLOW', checkoutFlowId: '08b0a9fb-6696-48c9-a9dd-6accd3c7ecaf' })
Call waitForCheckoutReady() before checkout. If checkout is not ready, checkout returns without opening a dialog and without throwing.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be 'CHECKOUT_FLOW' |
checkoutFlowId | string | Yes | UUID of the checkout flow. |
The id is the last segment of the checkout flow URL in Loby Cloud:
/manage/:museumId/checkout-flows/:checkoutFlowId
The flow must belong to the museum of your SDK clientId, and its test mode must match Loby.init({ testMode }). A live SDK cannot open a test-mode flow, and a test-mode SDK cannot open a live flow.
If the id is missing, the flow is not found, it belongs to another museum, test mode does not match, or no sellable steps remain, the SDK logs an error to the console and does not open checkout.
Example: Buy Button for a Named Flow
<button id="buy-combo">Buy tickets and membership</button> <script> document.getElementById('buy-combo').addEventListener('click', async () => { await Loby.waitForCheckoutReady() Loby.checkout({ type: 'CHECKOUT_FLOW', checkoutFlowId: '08b0a9fb-6696-48c9-a9dd-6accd3c7ecaf' }) }) </script>
Handling Completed Orders
Listen for the orderCompleted event to respond when a purchase is completed:
Loby.addEventListener('orderCompleted', () => { console.log('Order completed!') })
User Flow
- User clicks your button
- You call
Loby.checkout({ type: 'CHECKOUT_FLOW', checkoutFlowId }) - SDK loads that checkout flow and displays the checkout modal
- User completes the steps in the flow and pays
- SDK emits
orderCompleted