Koala Smartblock docs

This section is not public yet. Enter the password you received from Koala.

Skip to main content

Trip data and pricing

The bundles the widget shows are configured by Koala, but their prices are calculated for the specific trip. You provide the trip; Koala prices each configured bundle against it and the widget renders the result. This section explains that exchange and exactly what to put in window.CTStore.dataSource.

How the exchange works​

When the widget starts, or after a restart when calling window.CTStore.koala.restart(), it:

  1. reads the trip context from window.CTStore.dataSource,
  2. maps it to a quote request and sends it to Koala,
  3. receives a price for each bundle configured for your placement,
  4. renders those bundles as priced options.

What the traveller sees is specific to their booking and shown in their own currency, not a generic rate.

How the widget quotes a trip

Dates and time zones​

Every date-time in dataSource is a local ISO 8601 string with no UTC offset (for example 2028-07-11T06:25:00): the time on the clock at the place of departure, arrival, check-in or check-out. You never deal with offsets yourself.

Flights are quoted on those local times as they are. Stays are the exception: the quote needs an exact offset for check-in and check-out, so give each stay its IANA timezone. Without it the widget uses the browser's time zone, which is wrong whenever the traveller books from somewhere else.

The trip context​

You populate window.CTStore.dataSource with the trip context. The full field-by-field shape, with example values and complete payloads to start from, is documented in the reference page Trip context.

Send only what the trip has​

Beyond currency and travelers, you include only the parts of the trip that actually exist:

Trip shapeIncludeLeave out
Flights onlysegments (flights)stays
Accommodation onlystayssegments
Flight and accommodationsegments, staysnothing
Train, bus, or ferrysegments (generic)stays

A single trip can mix modes, for example a flight followed by a train, by listing different segment types in the segments array. Optional fields (residence, numberOfCheckedBags, stop coordinates, or a full address) can be left out when you do not have them; baggage cover needs numberOfCheckedBags.

When it re-quotes​

The widget quotes once at load. If the trip changes afterwards, for example the dates, travellers, or currency, update dataSource and call window.CTStore.koala.restart() so the widget re-reads it and re-quotes.

If quoting fails​

Two things can go wrong, and each surfaces on its own event:

  • The trip context is incomplete or malformed: no quote request is sent, and the widget emits onError with a message pointing at the dataSource property to fix. This is an integration problem to solve during development.
  • The quote request fails: the request was sent but Koala could not return quotes (the service rejected the trip or was unreachable). The widget does not render priced options and emits onAvail with status ERROR so your page can respond (hide the section, fall back, or log it).

A quote can also succeed without pricing a single bundle, for example when every bundle is inside its purchase cutoff. That is not a failure: onAvail fires with status SUCCESS and count: 0, the rejections and their reasons are in response.data.quotes, and the widget renders nothing. Nothing was offered, so no request is prepared either: basketPayload stays undefined and there is nothing to send after the booking.

The events surface is covered in Events and basket state.