Membership Gift Card Checkout
Open a checkout where the user buys a membership as a gift for someone else.
Basic Usage
Open the gift checkout for the first membership type that is sold online as a gift (sorted by order):
await Loby.waitForCheckoutReady() Loby.checkout({ type: 'MEMBERSHIP_GIFTCARD' })
Specific Membership Type
To open the gift checkout for a specific membership type:
Loby.checkout({ type: 'MEMBERSHIP_GIFTCARD', membershipTypeId: '08b0a9fb-6696-48c9-a9dd-6accd3c7ecaf' })
This is useful when you have a "Give as a gift" button next to each membership tier.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be 'MEMBERSHIP_GIFTCARD' |
membershipTypeId | string | No | UUID of the membership type to give. It must be sold online as a gift (see below). If omitted, the first type that is sold online as a gift (sorted by order) is used. |
Call waitForCheckoutReady() before checkout. If checkout is not ready, checkout returns without opening a dialog and without throwing.
Which Membership Types Can Be Given
A membership type is sold online as a gift when these settings are turned on for it in Loby Cloud, under Membership Types and then the type:
- Make available online
- Sell online
- Sell as gift (only shown when gift cards are turned on for your museum)
These are the types the user can choose between in the gift checkout. If membershipTypeId belongs to another type, or no type is sold online as a gift, the SDK logs an error to the console and does not open checkout.
What the User Fills In
- The membership type, which the user can change to another type sold online as a gift
- The recipient's name
- A message to the recipient (optional)
- The user's own email address, which is the only contact detail asked for
The user receives the gift card by email as a printable PDF, with a code the recipient uses to activate the membership. The gift card is not sent to the recipient; the user passes it on.
When the membership type is also sold as a membership, the gift checkout has a link to buy it for yourself instead, and the membership checkout (type: 'MEMBERSHIP') has a link to buy it as a gift. Both switch the open checkout without closing it. See Memberships.
Example: Gift Buttons
<div class="membership-cards"> <div class="card"> <h3>Basic Membership</h3> <button onclick="giveMembership('basic-uuid')">Give as a gift</button> </div> <div class="card"> <h3>Premium Membership</h3> <button onclick="giveMembership('premium-uuid')">Give as a gift</button> </div> </div> <script> async function giveMembership(membershipTypeId) { await Loby.waitForCheckoutReady() Loby.checkout({ type: 'MEMBERSHIP_GIFTCARD', membershipTypeId: membershipTypeId }) } </script>
Handling Completed Orders
Listen for the orderCompleted event to respond when the gift card is bought:
Loby.addEventListener('orderCompleted', ({ orderId }) => { console.log('Gift card bought in order', orderId) })
User Flow
- User clicks your "Give as a gift" button
- You call
Loby.checkout({ type: 'MEMBERSHIP_GIFTCARD', membershipTypeId })(or omitmembershipTypeIdto use the first type sold online as a gift) - SDK displays the gift checkout modal
- User enters the recipient's name, an optional message, and their own email address, then pays
- SDK emits
orderCompletedevent - User sees the receipt and receives the gift card by email