Membership Checkout
Open a checkout flow for membership purchases.
Basic Usage
Open checkout for the first membership type that is available in the online store (sorted by order):
Loby.checkout({ type: 'MEMBERSHIP' })
If you omit membershipTypeId, the SDK does not open a browse-all picker. It auto-selects that first eligible type and opens checkout for it.
Specific Membership Type
To open checkout for a specific membership type:
Loby.checkout({ type: 'MEMBERSHIP', membershipTypeId: '08b0a9fb-6696-48c9-a9dd-6accd3c7ecaf' })
This is useful when you have a "Buy Now" button for a specific membership tier.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be 'MEMBERSHIP' |
membershipTypeId | string | No | UUID of a specific membership type. If omitted, the first type that is availableInOnlineStore and availableAsProduct (sorted by order) is used. |
Call waitForCheckoutReady() before checkout. If checkout is not ready, checkout returns without opening a dialog and without throwing.
Example: Membership Purchase Buttons
<div class="membership-cards"> <div class="card"> <h3>Basic Membership</h3> <p>$49/year</p> <button onclick="buyMembership('basic-uuid')">Buy Now</button> </div> <div class="card"> <h3>Premium Membership</h3> <p>$99/year</p> <button onclick="buyMembership('premium-uuid')">Buy Now</button> </div> </div> <script> function buyMembership(membershipTypeId) { Loby.checkout({ type: 'MEMBERSHIP', membershipTypeId: membershipTypeId }) } </script>
Handling Completed Orders
Listen for the orderCompleted event to respond when a purchase is completed:
Loby.addEventListener('orderCompleted', () => { console.log('Order completed!') // Update UI, show confirmation, etc. })
User Flow
- User clicks your "Buy Membership" button
- You call
Loby.checkout({ type: 'MEMBERSHIP', membershipTypeId })(or omitmembershipTypeIdto use the first online membership) - SDK displays the checkout modal
- User selects membership options and enters payment details
- SDK processes the payment
- SDK emits
orderCompletedevent - User sees confirmation and modal closes