Widget Custom E-commerce - Developer Guide
- 1 Introduction and Concepts
- 2 Get Content to Build the Widget
- 2.1 Url to use iframe
- 2.2 General url to implement custom widget
- 2.3 Services to use
- 2.3.1 Get sessions
- 2.3.1.1 Url:
- 2.3.1.2 Implementation:
- 2.3.1.3 Response:
- 2.3.1.4 Response dictionary:
- 2.3.2 Get configs
- 2.3.2.1 Url:
- 2.3.2.2 Implementation:
- 2.3.2.3 Response:
- 2.3.2.4 Response dictionary:
- 2.3.3 Get Dates
- 2.3.3.1 Parameters:
- 2.3.3.2 Url:
- 2.3.3.3 Implementation:
- 2.3.3.4 Response:
- 2.3.3.5 Response dictionary
- 2.3.4 Post action
- 2.3.4.1 Parámetros:
- 2.3.4.2 Url:
- 2.3.4.3 Implementación:
- 2.3.4.4 Respuesta:
- 2.3.1 Get sessions
- 3 Implementation of the form
- 3.1 HTML
- 3.1.1 Header:
- 3.1.2 Form:
- 3.1.3 Script Javascript:
- 3.2 Demo project to start
- 3.1 HTML
- 4 Required validations
Introduction and Concepts
Throughout this tutorial, users will be able to create their own widgets to embed in web pages and from there access via parameters to the functionalities of E-COMMERCE searchflight.
This document is a guide for the web developer, which explains how to obtain and connect the Widget developed with the booking engine.
This guide goes into how to create the widget, detailing the services and fields that you must have in order to build the tool and manage to perform the searches to be later displayed in E-COMMERCE flightresults.
What is a widget?Â
It is a small application that is included on the client's website, with the aim of expanding the functionality offered by E-COMMERCE searchflight.
Does KIU offer a widget?
Yes. KIU provides a widget usable in an embedded way through an iframe when the E-COMMERCE product is created, but, possibly it does not cover all the aspects that the client requires therefore, it can develop its own widget and connect with E-COMMERCE , with the help of our API REST services, which provide all the data necessary to put together a personalized form and guarantee compatibility with the rest of the reservation flow.
The developed widget must consider the general configuration of E-COMMERCE?
Yes. The Widget must contemplate and obtain the content based on the configuration provided by kiu, in order to carry out searches according to the commercial requirements of the client. This information resides in Backoffice and must be fully configured when developing and implementing the widget. This guide explains how to connect and get the content to be displayed according to the mentioned configuration.
Get Content to Build the Widget
When the developer creates the HTML form to generate the widget, there are certain mandatory fields that must exist in order to send the minimum necessary information to the E-COMMERCE flightresults or corresponding screen according to the flow, and in this way obtain results.
Url to use iframe
This is to be used in case you prefer to use the widget that Kiu offers, within an iframe on the client's website.
https://ecommerce-xx-stage.kiusys.net/searchflight/widget/
Using this option, you only need to add this url to an iframe, like the following example:<iframe src="https://ecommerce-xx-stage.kiusys.net/searchflight/widget/"</iframe>
General url to implement custom widget
The url to use in order to consume the necessary services to implement and use the custom widget, for example, carrier XX and stage environment:
https://ecommerce-xx-stage.kiusys.net/
Services to use
Get sessions
It is the first service to use, its function is to obtain a session key and the configuration of the flow that the application must follow. It is important that it is implemented first, since with the key session is that we can issue request to ... / configs.
Url:
https://ecommerce-xx-stage.kiusys.net/searchflight/api/v1/sessions/
Implementation:
Response:
Response dictionary:
Get configs
It is the main service, provider of all the configuration of the carrier.
Url:
https://ecommerce-xx-stage.kiusys.net/searchflight/api/v1/configs/
Implementation:
Response:
Response dictionary:
Get Dates
Returns the list of dates with flight availability from the current day to the subsequent 330 days. This service must be used having implemented the inputs of origin and destination. So once the value for the two fields specified above is selected, you can execute the http request.
Parameters:
origin: The code of the airport of origin. Example: 'AEP'.
destination: The code of the airport of destination.. Example: 'BUE'.
Url:
https://ecommerce-xx-stage.kiusys.net/searchflight/api/v1/dates/?origin=${origin}&destination=${destination}
Implementation:
Response:
Response dictionary
In this answer we obtain all the dates with availability from the current day to 330 days later.
ow: Represents the dates available for flights one_way
rt: Represents the dates available for flights round_trip.
The idea of this information is to have what it takes to start any "datepicker" component, indicating which dates you should enable. In the event that the component used does not have this attribute and on the contrary admit dates to disable, this list can be used, comparing it against 330 days, so that we would obtain the days without availability that we would need, (depending on the component used).
Post action
Este servicio es responsable de enviar los datos para la búsqueda de disponibilidad, una vez que el usuario haya completado todos los campos mÃnimos requeridos. La solicitud debe hacerse a través de POST AJAX y al obtener la respuesta, simplemente redirija a la siguiente url de acuerdo con el flujo obtenido, utilizando el servicio get_sessions.
Parámetros:
country_setting: Country setting selected by usrr.
session_key: session_key from get_sessions.
journey_type: Journey type selected by user.
origin: Origin code selected by user.
destination: Destination code selected by user.
departure_date: Departure date selected by user.
return_date: Return date selected by user (In case round as journey type).
adults: Adult passenger quantity selected by user.
minors: Minor passenger quantity selected by user.
infants: Infant passenger quantity selected by user.
cabin: Cabin selected by user.
promo: Promo code inserted by user.
Url:
https://ecommerce-xx-stage.kiusys.net/searchflight/api/v1/action/
Implementación:
Respuesta:
Based on this answer, the developer has enough information to display within the different fields of the widget:
Departure and arrival airports
Allowed rutes
Passenger types supported
Passenger max quantity allowed for search
Journey type supported (One way and round trip)
Currencies supported by country
Temporary messages and privacy politics
Promo codes
Cabin list
Translations
Also based on this information you can generate filters and validators on the client side.
Implementation of the form
El objetivo de esta sección es aprovechar el contenido obtenido en los servicios disponibles para armar el formulario de búsqueda, llevar a cabo las validaciones pertinentes y finalmente poder enviar información a los resultados de vuelo de E-COMMERCE.
What will be shown below is based on a simple development, using bootstrap, javascript and jquery.
HTML
Header:
Form:
Script Javascript:
Demo project to start
IMPORTANT NOTE
This is meant to be used an implementation guideline for developers; it is not meant to be used within the development.
This HTML should not be used as it is. It is not adapted to work on all browsers, devices, or their versions.
This widget needs to be adjusted and a certification process is required before going live where all parties must be involved (airline, website developer, Kiu)
In the following .zip file, you can get a startup version to implement a widget from scratch, in addition, it also has the widget that E-COMMERCE provides to be embedded directly into an iframe without further effort:
Required validations
Beyond that the E-COMMERCE application has its own validations in the backend, we must make certain recommendations to the developers about some validations to be performed on the client side (Front-end) in order to avoid inconsistent search errors and generate a process more efficient.
Origin - Destination:
The Get_config response returns the list of search-enabled routes configured in the backoffice. Based on this information, the developer can filter and validate the related options and thus optimize the search results. This filter is done for example in the javascript function filterRoute(), This must be used in an onkeyup event
Dates:
The supported date format is YYYY-MM-DD (example: 2020-04-06). The developer can display the form in different formats according to the zone he is in, but he should consider doing the transformation to respect the supported format and thus avoid E-COMMERCE returning format error.
Departure date:
The departure date should be considered from the current date to the future and not beyond 330 days in the future. The industry standard application supports availability searches up to 330 days into the current date. We specify this in the Get_dates section, and we use it in the manageDates () javascript function.
Return date:
The return date must be validated against the departure date. This cannot be earlier than the date set for departure and must not exceed 330 days in the future.
Adult passengers:
We recommend that the default value be 1. Do not accept 0, to avoid requests via the unaccompanied minors web sales channel that involves an internal process for authorization by the airline. Similarly, these settings are included in the Get_configs response, passenger_types field.
Infant passengers
By industry logic, an adult must previously exist before adding an infant. If there is more than one infant passenger, the same number of adults must exist since only one infant passenger can be associated and only one can be associated with one adult passenger.
Sending data to E-COMMERCE:
The Post action service is used for sending search data by AJAX, it should not be used in a form submit event, since it does not support re-addresses. The correct use of this service is: once the response with status 200 has been obtained, we must redirect to the next screen E-COMMERCE, This information is provided by the Get sessions service, used first in the integration flow , whose information must be saved in the client (Front End).
To do the redirection, based on the flow, we can make use of the handlePostResponse () function, or directly, taking into account the general url, the session data previously obtained and the Post Action response, use something like the following :
Â