Booking Data as a Query Parameter for Booxi Booking Widget (v2)

This article explains how to extract and use the query parameter booking_data. For use with Booxi Booking Widget v2 only.

Query Parameter

When using the URL redirection feature, booking_data gets passed as the query parameter attached to its corresponding URL. The content of booking_data may be complete or partial depending on the booking status.

Here’s how booking_data will appear in the address bar of your web browser.

 

http://.../booked.html?booking_data=eyJzZXJ2aWNlSWQiOjk3MzY2LCJzZXJ2aWNl...hbHNlfX0%3D

 

Extraction, Decoding and Parsing

The value of booking_data is a JSON object encoded as a base 64 UTF-8 string. In order to access its content, it must be extracted, decoded and parsed appropriately.

Depending on your development environment, choose one of the following solutions:

Using atob

// extract query from URL
const urlParams = new URLSearchParams(window.location.search);


// extract booking_data and decode to string
const decodedData = atob(urlParams.get('booking_data'));        


// parse decoded string as JSON
const booking = JSON.parse(decodedData);

 


Using Buffer from node.js

// assuming query is parsed


// decode query
const buffer = Buffer.from(query, "base64");


// parse decoded string to JSON object
const booking = JSON.parse(buffer.toString("utf-8"));

 


Once extracted, decoded and parsed, booking_data will contain a list of properties. See below for its entire list.

Properties

Here is a complete list of properties found in booking_data. Be reminded that its content will vary depending on the booking status. “Book Now” will return any information the customer has entered so far for an incomplete or abandoned booking.  Consequently, the information may be partial. 

Properties

Type

Description

apiBookingId

String

ID of the successful booking that is used in the Booking API. This value is only set if bookingSuccessful is true.

attendeeCount

Integer

Number of attendee.

bookingId

Integer

ID that is associated with a successful booking. This value is only set if bookingSuccessful is true.

bookingStatus

String

Textual status indicator, possible values :

  • Booking Success: Booking successfully completed, expect bookingSuccessful to be true
  • Booking Canceled: Booking was terminated prior to completion, expect bookingSuccessful to be false
  • Not Available: Book Now was not able to complete its loading process, various reasons such as invalid api key.

bookingSuccessful

Boolean

True if booking was successfully complete, otherwise false.

bookingType

String

If bookingSuccessful is true then this value will contain the type of booking. Can be “appointment”, “reservation” or “rental”.

clientData

Object

Client data object

clientData.address

String

Client's address (not validated).

clientData.city

String

Client's city (not validated)

clientData.country

String

Client's country

clientData.customRequest

String

Client's postal code or zip code

clientData.email

String

Client's email (validated)

clientData.emailReminder

Boolean

Client is requesting reminder notification by email.

clientData.firstname

String

Client's first name (not validated).

clientData.lastname

String

Client's last name (not validated).

clientData.pczip

String

Client's postal code or zip code (validated)

clientData.phone

String

Client's phone number in E.164 format (validated)

clientData.phoneCC

String

Client's phone country code (validated).

clientData.provState

String

Client's province or state (validated).

clientData.smsReminder

Boolean

Client is requesting reminder notification by sms.

datetime

Date

Appointment date and time in RFC 3339 format.

eventCalId 

Integer

ID of a valid group event that is available for booking

serviceCategoryName

String

Category name.

serviceCurrencyCode

String

Currency code per ISO 4217 format

serviceDuration

Integer

Service duration in minutes. 

serviceId

Integer

Service ID associated with a selected appointment or reservation.

serviceName

String

Service associated with a selected appointment or reservation.

servicePrice

String

String representation of a service price, formatted according to the merchant country and language, with 2 fixed digits. Available after choosing a service. 

staffFirstname

String

First name of staff member  associated with a selected appointment or reservation.

staffId

Integer

ID of staff member  associated with a selected appointment or reservation.

staffLastname

String

Last name of staff member  associated with a selected appointment or reservation.

totalPay

String

Decimal string of a total amount to pay online, formatted according to the merchant country and language, with 2 fixed digits. Appears only if online payment is set for the service. 

totalPrice

String

Decimal string of a total cost, formatted according to the merchant country and language, with 2 fixed digits. Available after the contact information section.