Behio Storefront SDK
Cart & Checkout

Checkout

Create orders from the cart

Create Order

const order = await client.checkout.createOrder({
  email: '[email protected]',
  phone: '+420123456789',
  shippingAddress: {
    firstName: 'Jan',
    lastName: 'Novak',
    street: 'Vodickova 12',
    city: 'Praha',
    zip: '11000',
    country: 'CZ',
  },
  billingAddress: {
    firstName: 'Jan',
    lastName: 'Novak',
    street: 'Vodickova 12',
    city: 'Praha',
    zip: '11000',
    country: 'CZ',
  },
  customerNote: 'Ring the bell twice',
  redeemLoyaltyPoints: 500, // optional — redeem loyalty points
});

After a successful checkout:

  • Cart is automatically cleared
  • order:created and cart:cleared events are emitted
  • Cart session is reset

Checkout Input

FieldTypeRequiredDescription
emailstringYesCustomer email
phonestringNoCustomer phone
shippingAddressAddressYesShipping address
billingAddressAddressNoBilling (defaults to shipping)
customerNotestringNoNote from customer
redeemLoyaltyPointsnumberNoPoints to redeem (1-1,000,000)

Security

All financial operations are atomic and race-condition safe:

  • Stock is decremented atomically — overselling is impossible
  • Gift cards use conditional balance check — double-spend blocked
  • Discount codes with usage limits are claimed atomically
  • Loyalty points are deducted inside the same transaction
  • Cart is verified non-empty inside the transaction

Guest checkout may be disabled by the shop admin. If allowGuestCheckout is false, customers must register before checking out.

Events

client.on('order:created', (order) => {
  router.push(`/thank-you?order=${order.orderNumber}`);
});

On this page