Skip to main content

Storefront + Cart Checkout

Use the storefront flow when customers need to browse products, build a basket, and pay for several items at once. Three components work together:
  • <khaime-storefront> — product grid with filtering, currency switching, and an add-to-cart drawer.
  • <khaime-cart-page> — optional standalone cart page (for a dedicated /cart route).
  • sdk.openCartCheckout() — opens the checkout modal with the current cart contents.
The cart is persisted client-side (UUID in localStorage) and mirrored server-side in Redis with a 14-day TTL, so customers keep their basket across sessions and devices (as long as the UUID is on the same browser).
Only physical products can be added to the cart. Digital downloads, event tickets, and subscriptions use direct checkout — render them with a Pay Button instead.

Minimal setup

That’s it — product clicks, add-to-cart, the checkout modal, and payment confirmation are all handled by the component.

The full purchase flow

1

Customer lands on your page

<khaime-storefront> calls GET /api/v1/sdk/storefront/bootstrap (merchant branding, currencies, gateways) and GET /api/v1/sdk/storefront/products (the catalog).
2

Customer adds items

Clicking “Add to cart” on a product card dispatches khaime:add-to-cart. The SDK’s CartManager updates localStorage and syncs to the server via POST /api/v1/sdk/storefront/cart/items.
3

Customer opens the cart

Depending on the cart-display attribute, the drawer slides open or the page navigates to cartUrl. Cart contents are re-hydrated from GET /api/v1/sdk/storefront/cart/{cart_id}.
4

Customer clicks Checkout

The SDK calls sdk.openCartCheckout() internally (or you can call it yourself from a custom button). This opens the cart-checkout modal.
5

Modal collects customer info + payment

The modal shows an email/name form, a shipping-address form (for physical goods), and then the Stripe Elements or Paystack UI based on the transaction currency.
6

Payment confirmed

The SDK calls POST /api/v1/sdk/checkout/session/{sessionToken}/confirm, emits khaime:payment-success, clears the cart, and fires your onPaymentSuccess callback.

Storefront configuration

Cart display modes

  • drawer — Cart opens as a slide-out overlay on the current page. Best for single-page experiences.
  • page — “View cart” links navigate to cart-url. Pair with a dedicated <khaime-cart-page> on that route.
  • both — Drawer opens for quick reviews, but the “Checkout” CTA routes to cart-url as a pre-checkout review step.

Standalone cart page

For a dedicated cart route, render <khaime-cart-page> on /cart:
Or render a mini cart in a sidebar:

Programmatic cart access

The SDK exposes CartManager so you can read or mutate the cart from your own UI:

Events you’ll want to handle

See the events reference for the full payload shapes.

Next steps