Cart Operations & Checkout Create shopping carts, manage customer info and discounts, and process checkout with Stripe payments using the ResytechApi client.
This page covers the transactional side of the booking flow: building a cart, applying discounts, and completing checkout. It also covers gift card purchasing.
All examples assume you have initialized the API client and selected an activity, date, and time slot .
Create a new cart or update an existing one. The server validates availability and returns pricing details.
const result = await api.cart. createOrUpdateCart ({
cart: {
activity: 'activity-uuid' ,
duration: 'duration-uuid' ,
date: '2025-07-15' ,
timeSlotStart: '10:00' ,
timeSlotEnd: '11:00' ,
equipment: [
{
equipmentUuid: 'equipment-uuid' ,
quantity: 1 ,
seats: 2 ,
addons: [
{
addonUuid: 'addon-uuid' ,
quantity: 1 ,
equipmentUuid: 'equipment-uuid'
}
]
}
]
}
});
if (result.success) {
console. log ( 'Cart ID:' , result.cartId);
console. log ( 'Total:' , result.cart.total);
console. log ( 'Stripe account:' , result.operatorAccountId);
}
To update an existing cart, pass the cartId:
const updated = await api.cart. createOrUpdateCart ({
cartId: 'existing-cart-id' ,
cart: {
activity: 'activity-uuid' ,
duration: 'duration-uuid' ,
date: '2025-07-15' ,
timeSlotStart: '14:00' ,
timeSlotEnd: '15:00' ,
equipment: [
{ equipmentUuid: 'equipment-uuid' , quantity: 1 , seats: 4 }
]
}
});
Field Type Required Description cartClientShoppingCartYes Cart contents (see below) cartIdstringNo Existing cart ID to update; omit to create new
Field Type Description successbooleanWhether the operation succeeded cartIdstringCart identifier for subsequent operations cartServerShoppingCartOverviewServer-calculated pricing and line items errorCodeShoppingCartErrorCodeNumeric error code (if failed) removalsShoppingCartRemoval[]Items removed due to validation (e.g., sold out equipment) clientSecretstringStripe PaymentIntent client secret (for deferred payment setup) operatorAccountIdstringStripe connected account ID
The core cart object sent to the server. Used by both createOrUpdateCart and checkout.
Field Type Required Description activitystringYes Activity UUID durationstringYes Duration UUID datestringYes Booking date (YYYY-MM-DD) timeSlotStartstringYes Start time (HH:mm) timeSlotEndstringYes End time (HH:mm) equipmentClientShoppingCartEquipment[]No Equipment selections customerClientShoppingCartCustomerNo Customer info (required for checkout) downPaymentRequestedbooleanNo Request down payment instead of full payment isPrivateTourbooleanNo Book as a private tour durationMinsnumberNo Dynamic duration in minutes tripProtectionSelectedbooleanNo Opt into trip protection
Field Type Required Description equipmentUuidstringYes Equipment UUID quantitynumberYes Number of units seatsnumberYes Number of seats (guests) addonsClientShoppingCartEquipmentAddon[]No Add-ons for this equipment
Field Type Required Description addonUuidstringYes Add-on UUID quantitynumberYes Quantity equipmentUuidstringYes Equipment UUID this add-on is for
Field Type Required Description fullNamestringNo Customer full name emailstringNo Email address (required for checkout) countryCodestringNo Phone country code (e.g., "1" for US) countrystringNo Country name or code phonestringNo Phone number
The server-side cart returned in responses. Contains calculated pricing, fees, and applied discounts.
Field Type Description lineItemsCartLineItem[]Itemized charges feesFee[]Taxes and fees subtotalnumberSubtotal before fees and discounts totalnumberTotal after all calculations feesTotalnumberSum of all fees discountTotalnumberSum of all discounts paidnumberAmount already paid balancenumberRemaining balance couponCodestringApplied coupon code giftCardCodestringApplied gift card code giftCardAmountAppliednumberGift card amount used giftCardBalancenumberRemaining gift card balance dueNownumberAmount due at checkout dueLaternumberAmount due later (for down payments) tripProtectionSelectedbooleanWhether trip protection is selected tripProtectionPricenumberTrip protection price equipmentServerShoppingCartEquipment[]Confirmed equipment selections
Field Type Description namestringLine item description pricenumberAmount typestringItem type identifier
Field Type Description uuidstringFee identifier namestringFee display name amountnumberFee amount typeTaxesAndFeesType0 = tax, 1 = fee
Update customer information on an active cart.
const result = await api.cart. updateCustomer ({
customer: {
fullName: 'Jane Smith' ,
email: 'jane@example.com' ,
phone: '5551234567' ,
countryCode: '1' ,
country: 'US'
},
cartId: 'cart-id' // optional if using session-based cart
});
Field Type Required Description customerClientShoppingCartCustomerYes Customer details cartIdstringNo Cart ID
const result = await api.cart. applyCoupon ({
couponCode: 'SUMMER20' ,
cartId: 'cart-id'
});
const result = await api.cart. removeCoupon ({
cartId: 'cart-id'
});
Field Type Required Description couponCodestringNo Coupon code to apply cartIdstringNo Cart ID
const result = await api.cart. applyGiftCard ({
giftCardCode: 'GC-ABC123' ,
cartId: 'cart-id'
});
if (result.success) {
console. log ( 'Balance available:' , result.availableBalance);
}
const result = await api.cart. removeGiftCard ({
cartId: 'cart-id'
});
Field Type Required Description giftCardCodestringNo Gift card code cartIdstringNo Cart ID
Field Type Description successbooleanWhether the operation succeeded errorCodeGiftCardErrorCodeError code (if failed) availableBalancenumberRemaining gift card balance
Preview trip protection pricing before the customer opts in.
const preview = await api.cart. getTripProtectionPreview ({
cartId: 'cart-id'
});
if (preview.success && preview.available) {
console. log ( `${ preview . title }: $${ preview . price }` );
console. log (preview.description);
}
Field Type Required Description cartIdstringNo Cart ID
Field Type Description availablebooleanWhether trip protection is offered pricenumberPrice for trip protection titlestringDisplay title descriptionstringDisplay description coverageTypenumberCoverage type identifier coverageAmountnumberCoverage amount
Process the booking. Requires a complete cart with customer email, and typically a Stripe confirmation token for payment.
const result = await api.checkout. checkout ({
cart: {
activity: 'activity-uuid' ,
duration: 'duration-uuid' ,
date: '2025-07-15' ,
timeSlotStart: '10:00' ,
timeSlotEnd: '11:00' ,
equipment: [
{ equipmentUuid: 'equip-uuid' , quantity: 1 , seats: 2 }
],
customer: {
fullName: 'Jane Smith' ,
email: 'jane@example.com' ,
phone: '5551234567'
},
tripProtectionSelected: false
},
stripeConfirmationToken: 'tok_xxx' , // from Stripe.js
agreements: [ 'agreement-uuid-1' ],
customFields: [
{ uuid: 'field-uuid' , answer: 'Some answer' }
],
demographics: [
{ demographicUuid: 'demo-uuid' , uuid: 'value-uuid' , value: 2 }
],
smsOptIn: true
});
if (result.success) {
console. log ( 'Confirmation:' , result.confirmation);
} else if (result.clientSecret) {
// Stripe requires additional action (3D Secure, etc.)
// Use Stripe.js to handle the next action, then retry
console. log ( 'Payment requires additional action' );
}
Field Type Required Description cartClientShoppingCartYes Complete cart with customer info stripeConfirmationTokenstringNo Stripe confirmation token for payment handledNextActionstringNo Stripe PaymentIntent ID after handling 3DS customFieldsCustomFieldAnswer[]No Answers to custom fields demographicsDemographicValue[]No Guest demographic breakdown agreementsstring[]No UUIDs of accepted agreements smsOptInbooleanNo Whether customer opts into SMS cartIdstringNo Cart ID
Field Type Description uuidstringCustom field UUID answerstringCustomer's answer
Field Type Description demographicUuidstringDemographic UUID uuidstringValue UUID valuenumberCount (e.g., 2 adults, 1 child)
Field Type Description successbooleanWhether checkout completed confirmationstringBooking confirmation number cartServerShoppingCartOverviewFinal cart summary cartActionCreateOrUpdateShoppingCartResponseCart validation result clientSecretstringStripe client secret (if further payment action needed) paymentIntentIdstringStripe PaymentIntent ID
These endpoints let customers purchase new gift cards (separate from applying a gift card to a cart).
Get the gift card purchase configuration for the location.
const settings = await api.giftCardPurchase. getSettings ();
if (settings.success && settings.isAvailable) {
console. log ( 'Flat amounts:' , settings.flatAmounts);
console. log ( 'Variable:' , settings.allowVariableAmounts,
`$${ settings . variableMinAmount }-$${ settings . variableMaxAmount }` );
}
Field Type Description isAvailablebooleanWhether gift card purchasing is enabled allowFlatAmountsbooleanWhether preset amounts are offered flatAmountsnumber[]Preset dollar amounts allowVariableAmountsbooleanWhether custom amounts are allowed variableMinAmountnumberMinimum custom amount variableMaxAmountnumberMaximum custom amount requireRecipientEmailbooleanWhether recipient email is required allowCustomMessagebooleanWhether a custom message is allowed expirationDaysnumberNumber of days until the gift card expires
Purchase a gift card with Stripe payment.
const result = await api.giftCardPurchase. purchase ({
amount: 50 ,
purchaserName: 'John Doe' ,
purchaserEmail: 'john@example.com' ,
recipientName: 'Jane Smith' ,
recipientEmail: 'jane@example.com' ,
customMessage: 'Happy birthday!' ,
stripeConfirmationToken: 'tok_xxx'
});
if (result.success) {
console. log ( 'Gift card code:' , result.giftCardCode);
console. log ( 'Amount:' , result.giftCardAmount);
console. log ( 'Expires:' , result.expiresAt);
}
Field Type Required Description amountnumberYes Gift card amount in dollars purchaserNamestringNo Buyer's name purchaserEmailstringNo Buyer's email purchaserPhonestringNo Buyer's phone purchaserPhoneCountryCodestringNo Phone country code recipientNamestringNo Recipient's name recipientEmailstringNo Recipient's email customMessagestringNo Personal message stripeConfirmationTokenstringNo Stripe token for payment handledNextActionstringNo Stripe PaymentIntent ID after 3DS
Field Type Description successbooleanWhether the purchase succeeded giftCardCodestringThe gift card code giftCardAmountnumberAmount loaded expiresAtDateExpiration date recipientEmailstringWhere the gift card was sent clientSecretstringStripe client secret (if 3DS required) paymentIntentIdstringStripe PaymentIntent ID
End-to-end flow from creating a cart through successful checkout.
const api = new ResytechApi ();
// 1. Initialize
const init = await api.initialization. initialize ({
identifier: 'checkout-flow'
});
const activity = init.activities[ 0 ];
const equipment = activity.equipment[ 0 ];
const duration = activity.durations[ 0 ];
// 2. Create cart
const cartResult = await api.cart. createOrUpdateCart ({
cart: {
activity: activity.uuid,
duration: duration.uuid,
date: '2025-07-15' ,
timeSlotStart: '10:00' ,
timeSlotEnd: '11:00' ,
equipment: [
{
equipmentUuid: equipment.uuid,
quantity: 1 ,
seats: 2
}
]
}
});
if ( ! cartResult.success) {
console. error ( 'Cart failed:' , cartResult.message, 'Code:' , cartResult.errorCode);
return ;
}
const cartId = cartResult.cartId;
console. log ( 'Cart created:' , cartId);
console. log ( 'Subtotal:' , cartResult.cart.subtotal);
// 3. Update customer info
await api.cart. updateCustomer ({
cartId: cartId,
customer: {
fullName: 'Jane Smith' ,
email: 'jane@example.com' ,
phone: '5551234567' ,
countryCode: '1'
}
});
// 4. Apply a coupon
const couponResult = await api.cart. applyCoupon ({
cartId: cartId,
couponCode: 'SUMMER20'
});
if (couponResult.success) {
console. log ( 'Coupon applied!' );
}
// 5. Check trip protection
const tripPreview = await api.cart. getTripProtectionPreview ({
cartId: cartId
});
// 6. Process checkout
// In a real app, collect the Stripe token via Stripe.js/Elements
const checkout = await api.checkout. checkout ({
cart: {
activity: activity.uuid,
duration: duration.uuid,
date: '2025-07-15' ,
timeSlotStart: '10:00' ,
timeSlotEnd: '11:00' ,
equipment: [
{ equipmentUuid: equipment.uuid, quantity: 1 , seats: 2 }
],
customer: {
fullName: 'Jane Smith' ,
email: 'jane@example.com' ,
phone: '5551234567'
},
tripProtectionSelected: tripPreview.available
},
cartId: cartId,
stripeConfirmationToken: 'tok_from_stripe_js' ,
agreements: [ 'agreement-uuid-1' ],
smsOptIn: true
});
if (checkout.success) {
console. log ( 'Booking confirmed!' , checkout.confirmation);
console. log ( 'Total charged:' , checkout.cart.total);
} else if (checkout.clientSecret) {
// Handle Stripe 3D Secure or other next actions
// After handling, retry with handledNextAction
console. log ( 'Additional payment verification required' );
} else {
console. error ( 'Checkout failed:' , checkout.message);
}