ResytechResytech Docs

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.

Shopping Cart

createOrUpdateCart

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 }
    ]
  }
});

CreateOrUpdateCartRequest

FieldTypeRequiredDescription
cartClientShoppingCartYesCart contents (see below)
cartIdstringNoExisting cart ID to update; omit to create new

CreateOrUpdateShoppingCartResponse

FieldTypeDescription
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

ClientShoppingCart

The core cart object sent to the server. Used by both createOrUpdateCart and checkout.

FieldTypeRequiredDescription
activitystringYesActivity UUID
durationstringYesDuration UUID
datestringYesBooking date (YYYY-MM-DD)
timeSlotStartstringYesStart time (HH:mm)
timeSlotEndstringYesEnd time (HH:mm)
equipmentClientShoppingCartEquipment[]NoEquipment selections
customerClientShoppingCartCustomerNoCustomer info (required for checkout)
downPaymentRequestedbooleanNoRequest down payment instead of full payment
isPrivateTourbooleanNoBook as a private tour
durationMinsnumberNoDynamic duration in minutes
tripProtectionSelectedbooleanNoOpt into trip protection

ClientShoppingCartEquipment

FieldTypeRequiredDescription
equipmentUuidstringYesEquipment UUID
quantitynumberYesNumber of units
seatsnumberYesNumber of seats (guests)
addonsClientShoppingCartEquipmentAddon[]NoAdd-ons for this equipment

ClientShoppingCartEquipmentAddon

FieldTypeRequiredDescription
addonUuidstringYesAdd-on UUID
quantitynumberYesQuantity
equipmentUuidstringYesEquipment UUID this add-on is for

ClientShoppingCartCustomer

FieldTypeRequiredDescription
fullNamestringNoCustomer full name
emailstringNoEmail address (required for checkout)
countryCodestringNoPhone country code (e.g., "1" for US)
countrystringNoCountry name or code
phonestringNoPhone number

ServerShoppingCartOverview

The server-side cart returned in responses. Contains calculated pricing, fees, and applied discounts.

FieldTypeDescription
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

CartLineItem

FieldTypeDescription
namestringLine item description
pricenumberAmount
typestringItem type identifier

Fee

FieldTypeDescription
uuidstringFee identifier
namestringFee display name
amountnumberFee amount
typeTaxesAndFeesType0 = tax, 1 = fee

updateCustomer

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
});

UpdateShoppingCartCustomerRequest

FieldTypeRequiredDescription
customerClientShoppingCartCustomerYesCustomer details
cartIdstringNoCart ID

Coupons

applyCoupon

const result = await api.cart.applyCoupon({
  couponCode: 'SUMMER20',
  cartId: 'cart-id'
});

removeCoupon

const result = await api.cart.removeCoupon({
  cartId: 'cart-id'
});

ApplyCouponRequest

FieldTypeRequiredDescription
couponCodestringNoCoupon code to apply
cartIdstringNoCart ID

Gift Cards (on Cart)

applyGiftCard

const result = await api.cart.applyGiftCard({
  giftCardCode: 'GC-ABC123',
  cartId: 'cart-id'
});

if (result.success) {
  console.log('Balance available:', result.availableBalance);
}

removeGiftCard

const result = await api.cart.removeGiftCard({
  cartId: 'cart-id'
});

ApplyGiftCardRequest

FieldTypeRequiredDescription
giftCardCodestringNoGift card code
cartIdstringNoCart ID

ApplyGiftCardResponse

FieldTypeDescription
successbooleanWhether the operation succeeded
errorCodeGiftCardErrorCodeError code (if failed)
availableBalancenumberRemaining gift card balance

Trip Protection

getTripProtectionPreview

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);
}

TripProtectionPreviewRequest

FieldTypeRequiredDescription
cartIdstringNoCart ID

TripProtectionPreviewResponse

FieldTypeDescription
availablebooleanWhether trip protection is offered
pricenumberPrice for trip protection
titlestringDisplay title
descriptionstringDisplay description
coverageTypenumberCoverage type identifier
coverageAmountnumberCoverage amount

Checkout

checkout

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');
}

CheckoutRequest

FieldTypeRequiredDescription
cartClientShoppingCartYesComplete cart with customer info
stripeConfirmationTokenstringNoStripe confirmation token for payment
handledNextActionstringNoStripe PaymentIntent ID after handling 3DS
customFieldsCustomFieldAnswer[]NoAnswers to custom fields
demographicsDemographicValue[]NoGuest demographic breakdown
agreementsstring[]NoUUIDs of accepted agreements
smsOptInbooleanNoWhether customer opts into SMS
cartIdstringNoCart ID

CustomFieldAnswer

FieldTypeDescription
uuidstringCustom field UUID
answerstringCustomer's answer

DemographicValue

FieldTypeDescription
demographicUuidstringDemographic UUID
uuidstringValue UUID
valuenumberCount (e.g., 2 adults, 1 child)

CheckoutResponse

FieldTypeDescription
successbooleanWhether checkout completed
confirmationstringBooking confirmation number
cartServerShoppingCartOverviewFinal cart summary
cartActionCreateOrUpdateShoppingCartResponseCart validation result
clientSecretstringStripe client secret (if further payment action needed)
paymentIntentIdstringStripe PaymentIntent ID

Gift Card Purchasing

These endpoints let customers purchase new gift cards (separate from applying a gift card to a cart).

getSettings

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}`);
}

GetGiftCardPurchaseSettingsResponse

FieldTypeDescription
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

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);
}

PurchaseGiftCardRequest

FieldTypeRequiredDescription
amountnumberYesGift card amount in dollars
purchaserNamestringNoBuyer's name
purchaserEmailstringNoBuyer's email
purchaserPhonestringNoBuyer's phone
purchaserPhoneCountryCodestringNoPhone country code
recipientNamestringNoRecipient's name
recipientEmailstringNoRecipient's email
customMessagestringNoPersonal message
stripeConfirmationTokenstringNoStripe token for payment
handledNextActionstringNoStripe PaymentIntent ID after 3DS

PurchaseGiftCardResponse

FieldTypeDescription
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

Full Example: Cart to Checkout

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);
}

On this page