Events
The SDK reports every step of the purchase flow as:- DOM custom events — bubble up from each
<khaime-*>component, composed across Shadow DOM. Listen withaddEventListener. - SDK callbacks — registered via
sdk.on({ … }). Easier when you’ve initialized the SDK programmatically.
Two ways to listen
timestamp (ms since epoch) and merchantId.
Purchase-flow events
khaime:product-click
Fired when a customer clicks a product card or tile.
onProductClick(product)
khaime:add-to-cart
Fired when a customer adds an item to the cart.
onAddToCart(product, quantity)
khaime:cart-updated
Fired on every cart mutation — add, remove, quantity change, clear, or hydrate from storage.
onCartUpdated(items, action)
Use this to update a header badge, drawer count, or analytics.
khaime:cart-open / khaime:cart-close
Fired when the cart drawer (or cart page) opens or closes.
Callbacks: onCartOpen(), onCartClose()
khaime:currency-change
Fired when the customer picks a different currency from the switcher.
onCurrencyChange(newCurrency)
khaime:checkout-init
Fired right after the SDK creates a checkout session (before the payment modal opens).
onCheckoutInit(sessionToken)
Use this to log checkout starts for funnel analysis.
khaime:payment-success
Fired after the customer’s payment is confirmed.
onPaymentSuccess(result)
khaime:payment-error
Fired when the payment fails (declined card, expired session, gateway error, etc.).
onPaymentError(error)
Full callback signature
All purchase-related callbacks accepted bysdk.on(…):
sdk.on(...) multiple times merges into the existing handler map (later calls override same-named keys).
Analytics example
Wire every purchase step into your analytics tool:See also
- Pay Button quickstart
- Storefront + Cart
- Webhooks for server-side order verification
