TicketMap SDK Integration
TicketMap SDK Integration
Section titled “TicketMap SDK Integration”Use the TicketMap SDK to render event seat maps and run checkout from external websites.
The SDK uses a local selection first model: tapping a seat only updates UI selection (selectedSeatIds); nothing is reserved on the server until your code calls sdk.hold() or sdk.checkout(). If hold() was used, checkout(...) only pays for accumulated holds.
Use onSeatClick when you want a hook that runs only on user taps (not during polling updates). onSeatSelect / onSelectionChange run after availability sync — see below.
Embed snippet (custom checkout)
Section titled “Embed snippet (custom checkout)”<div id="ticket-map"></div><button id="checkoutBtn" disabled>Checkout (0)</button><div id="summary">No seats selected</div><ul id="items"></ul>
<script src="https://cdn.yourapp.com/ticketmap.min.js"></script><script> ;(async () => { const auth = await TicketMap.authenticate({ siteKey: 'sdk_pub_demo_12345678' })
const sdk = await TicketMap.init({ container: '#ticket-map', eventId: 'evt_123', displayId: 'disp_456', authToken: auth.authToken, onSelectionChange: (selection) => { const checkoutBtn = document.getElementById('checkoutBtn') const summary = document.getElementById('summary') const items = document.getElementById('items')
checkoutBtn.disabled = selection.items.length === 0 checkoutBtn.textContent = `Checkout (${selection.items.length})` summary.textContent = selection.items.length === 0 ? 'No seats selected' : `${selection.items.length} seat(s) • ${selection.total} ${selection.currency ?? ''}`.trim()
items.innerHTML = '' selection.items.forEach((item) => { const li = document.createElement('li') li.textContent = `Row ${item.seatRow} Seat ${item.seatNumber} - ${item.effectivePrice} ${item.currency}` items.appendChild(li) }) } })
document.getElementById('checkoutBtn').addEventListener('click', async () => { await sdk.checkout() }) })()</script>Required options
Section titled “Required options”container: CSS selector or HTMLElement where widget mounts.eventId: AnyBiz event id.displayId: AnyBiz display id that belongs to the given event.authToken: token fromTicketMap.authenticate({ siteKey }).
Optional options
Section titled “Optional options”apiBaseUrl: defaults to/api/events/sdkon current origin.holdMinutes: hold TTL before checkout.pollMs: availability polling interval in milliseconds.customerName,customerEmail,customerPhone: optional customer details forwarded to/sdk/checkout(recommended for MSU).onSeatSelect(selection): fullSdkSelectionSnapshotafter every sync (first load, polling, seat taps). Useselection.seatIds/selection.items(includes row, section title, price, currency, hold metadata).onSeatClick(detail): tap-only —{ seatId, action: 'select' | 'deselect', seat, selection }. Callawait sdk.hold()here if you want immediate server holds per tap.onSelectionChange(selection): same snapshot asonSeatSelect; use either or both depending on whether you need deduplication.onCheckoutStart,onCheckoutResult,onError.
Instance methods
Section titled “Instance methods”TicketMap.init(...) resolves to an SDK instance with:
hold(options?):POST /reservefor current selection; merges reservation ids for a latercheckout().checkout(options?): ifhold()added ids, runsPOST /checkoutfor those only; otherwise reserves current selection then checks out (legacy one-shot).releaseHeldReservation(id),getHeldReservationIds().refreshAvailability(): manually reloads seat availability.getSelectedItems(): currently selected ticket items.getSelectionSnapshot(): full selection payload (seatIds,items,total,currency).destroy(): unmount SDK and cleanup listeners.
Selection payload shape
Section titled “Selection payload shape”onSelectionChange receives:
seatIds: string[]items: Array<{ seatId, sectionId, sectionTitle, seatRow, seatNumber, effectivePrice, currency, availability, reservationId, heldByMe, reservedUntil, reservationHolderName?, reservationHolderEmail?, reservationHolderPhone? }>total: stringcurrency: string | null
reservationId is the parent reservation group id (ev_reservation.id) when the seat is currently held.
Reservation ID semantics (important)
Section titled “Reservation ID semantics (important)”SDK APIs now treat reservation ids as group ids:
POST /api/events/sdk/reservereturns one row per seat and includesreservationId(parent id).idmay still be present in reserve response as a temporary compatibility alias; preferreservationId.POST /api/events/sdk/releaseexpects parentreservationId.POST /api/events/sdk/checkoutexpectsreservationIdsas parent group ids.
Isolation and compatibility
Section titled “Isolation and compatibility”SDK mounts using Shadow DOM so host CSS does not break the seat map.
- Styles are injected in shadow root.
- Konva rendering stays inside SDK container.
- Public surface is only
window.TicketMap.
Backend route family
Section titled “Backend route family”SDK uses these routes:
POST /api/events/sdk/authPOST /api/events/sdk/eventsPOST /api/events/sdk/displaysPOST /api/events/sdk/sessionPOST /api/events/sdk/initPOST /api/events/sdk/availabilityPOST /api/events/sdk/reservePOST /api/events/sdk/releasePOST /api/events/sdk/checkoutPOST /api/events/sdk/checkout/status
Checkout return flow (important)
Section titled “Checkout return flow (important)”For MSU checkout, keep callback processing on the API domain, then redirect users to a friendly website page:
- Browser is redirected to MSU HPP.
- MSU returns to fixed callback endpoint:
/api/events/sdk/msu/return. - Backend verifies payment (
QUERYTRANSACTION) and finalizes checkout. - Backend redirects user to organization-specific friendly page from SDK settings (
sdk_settings.returnUrl), forwarding callback fields like:msuAcceptedresponseCoderesponseMsgmerchantPaymentIdcheckoutId
Recommended website result page examples:
- Production:
https://merchant-a.com/payment-result
CORS and key config
Section titled “CORS and key config”Configure these values in AnyBiz Settings -> SDK for your organization:
siteKey(string): publishable key passed toTicketMap.authenticate({ siteKey })allowedOrigins(string[]): parent origins allowed for that key (empty array = allow any)sessionSecret(optional string): optional per-organization HMAC secret for SDK session tokensreturnUrl(optional string): friendly page URL where user lands after backend processed MSU callback
siteKey must be unique across organizations.