The checkout reports what it is doing back to your page. Subscribe with on():
entase.on('checkout.ready', payload => {
console.log('checkout open for', payload.context.eventID);
});One listener per event name
on() stores one callback per event name. Registering a second callback for the same name replaces the first — it does not add to it:
entase.on('checkout.closed', a);
entase.on('checkout.closed', b); // a is gone; only b runsoff() removes whatever is registered for a name. It ignores any callback you pass it, so off('checkout.closed', b) and off('checkout.closed') do the same thing.
If several parts of your page need to react to the same event, register one callback and fan out from inside it.
Subscribing to several events at once
Both methods accept a space-separated string or an array of names, registering the same callback for each:
entase.on('checkout.ready checkout.closed', payload => {
console.log(payload.name);
});
entase.off(['checkout.ready', 'checkout.closed']);The payload
Every callback receives one object:
| Field | Type | Description |
|---|---|---|
name | string | The event name, useful when one callback handles several. |
context | object | Contains eventID — the event this checkout belongs to. |
data | object | Event-specific detail. |
Available events
| Name | When it fires |
|---|---|
checkout.ready | The checkout has loaded and is ready to interact with. This is also when the client hands over the clientContext you passed to book(). |
checkout.closed | The checkout has closed. The client tears down the panel or window and clears the backdrop. |
checkout.consent | The visitor answered the terms notice. data.consent is true when they accepted, and the client remembers it so the step is skipped next time. |
entase.on('checkout.closed', () => {
document.body.classList.remove('checkout-open');
});
entase.on('checkout.consent', payload => {
if (payload.data.consent) console.log('terms accepted');
});Listeners survive individual bookings
Listeners belong to the instance, not to a booking. Register them once, after creating the client, and they apply to every book() call. Use payload.context.eventID to tell bookings apart:
const entase = new Entase({ pk: 'YOUR_PUBLISHABLE_KEY' });
entase.on('checkout.closed', payload => {
refreshAvailability(payload.context.eventID);
});Calling destroy() stops all of them — the instance stops listening for messages from the checkout entirely.
Messages from other sources are ignored
The client only accepts messages from the Entase checkout origin, so unrelated postMessage traffic on your page will never reach your callbacks.