Rail Pass Modal Embed
The Rail Pass Modal embed is a pop-up where the user enters their passengers, sees the right passes for them, and continues to checkout.
The price of a rail pass can depend on who travels together. A child may travel for free with an adult, for example, and a senior may get a discount. The All Aboard API finds the cheapest combination of passes for a set of passengers, and the modal shows it. When the user has entered the passengers and selected a pass class, they are redirected to our hosted checkout, where they complete the purchase.
The Rail Pass Modal is responsive and adapts to the user's screen size. Scroll down to see an example.
Getting started
First load the script. It is a standard JavaScript module, so the script tag needs type="module".
<script
src="https://allaboard.eu/embed/aa-passbundle-modal.js"
type="module"></script>The script registers the custom element aa-passbundle-modal. You can then use it like any other HTML element.
<aa-passbundle-modal
publicApiKey="your-api-key-here"
travelDayCount="7"
validityPeriod="P1M"
product="interrail-global-pass"></aa-passbundle-modal>Cost centers and API keys
This embed runs on public web pages, so anyone who views the page can see its publicApiKey. Give it a key with only the base scope and the payment gateway scope: live and live:payments:stripe, or test and test:payments:stripe when testing. Never use a key that can read your orders or spend your wallet. Configuring embeds safely explains why.
Orders made through the embed are billed to a cost center. That cost center must have the payment gateway as a payment method, so that it matches the key's scope.
Attributes
Set these attributes on the <aa-passbundle-modal> element to tell it which rail pass to show.
Which attributes are required depends on the PassBundle product. product, validityPeriod and travelDayCount together identify one PassBundle, and passClass then selects the class.
At least one of validityPeriod and travelDayCount must be set, or the modal has no pass to show. Interrail passes need product and validityPeriod. Interrail "Flexi" passes, which have a set number of travel days, also need travelDayCount. "Continuous" passes are valid on every day of the validity period, and don't.
| Name | Description | Required |
|---|---|---|
publicApiKey |
Your public API key. You can find your API key in the Dashboard. | Yes |
product |
Identifier of the PassBundle product to display. For example, interrail-global-pass. |
Yes |
passClass |
The class of the pass. For example, 1stclass or 2ndclass. |
No |
travelDayCount |
The number of travel days the pass is valid for. For example, 5 or 15. |
One of the two |
validityPeriod |
The Duration of the pass to display. For example, P22D or P2M. |
One of the two |
campaignCode |
The campaign code to use when fetching the PassBundle. For example, black-friday-2027. |
No |
costCenter |
The id of the CostCenter to bill each passenger's travel against. Defaults to the agent's default cost center. | No |
sessionId |
The session ID to use when calling the API. Can be any unique string that identifies the session. Used for analytics and troubleshooting. | No |
currency |
The currency to display prices in. For example, EUR or GBP. Defaults to the currency of the language. For example, DKK for da and SEK for sv. |
No |
language |
The language of the modal: en (the default), da, de, es, fr, nb or sv. |
No |
theme |
The color theme: light (the default), dark, or auto, which follows the visitor's light or dark system setting. |
No |
open |
Opens the modal. This is a boolean attribute: add it to open the modal, and remove it to close it. | No |
passengers |
The default set of passengers to use for finding availability. See below for details. | No |
The passengers attribute
There are two ways to set the passengers:
- As an attribute value: a comma-separated list of passenger types, each optionally followed by a dot and an age, such as
ADULT,YOUTH.8. - As a property, set directly on the
<aa-passbundle-modal>element using JavaScript.
<aa-passbundle-modal
publicApiKey="your-api-key-here"
product="interrail-global-pass"
passengers="ADULT,YOUTH.8"></aa-passbundle-modal>const modal = document.querySelector('aa-passbundle-modal')
modal.passengers = [{ type: 'ADULT' }, { type: 'YOUTH', age: 8 }]Events
Listen for the Rail Pass Modal's events with addEventListener.
| Name | Description |
|---|---|
aa-passbundle-modal-close |
Emitted when the user closes the modal. The open attribute is removed at the same time. |
Example
The button below toggles the open attribute of an <aa-passbundle-modal> element with the attributes you set here. Change the product, class, validity, currency and language, then open the modal to see the result.