docs
  1. Checkout-guide
  2. Integration
  3. Standard Checkout

Standard Checkout

Make sure all of the steps from the initial checkout setup are completed before you start

Follow these steps to start the integration:

  1. Web Component Integration
    1. Loading the JavaScript bundle
    2. Initialising the web component
  2. Attributes
  3. Methods
  4. Configuration
  5. Tracking
  6. Loading Indicator
  7. Events

Web Component Integration

How to integrate the checkout web component into your shop frontend

Loading the JavaScript bundle

Begin by either creating a static page or modifying the existing start page of your shop application. Then, insert the following JavaScript snippet into the head element to load the Checkout bundle.

This script registers the web component with the browser and loads necessary assets (CSS, images).

Initialising the web component

To initialise and display the web component, add the <scayle-checkout> tag at a desired place where the content needs to appear. Any additional element like a header or footer must be defined in the root document.

Example code how to set up the web component:

Attributes

jwtContains basketId, etc. as encoded and signed parameter. Find out how to generate the token here. More details about the JWT .required
access-tokenThe access token you receive after successful user authentication. Find out how to generate the token here.required
originDefines where the user is coming from, can be app or web. Passing the correct value is mandatory, otherwise users might encounter problems with e.g. payment processing.required
header-elementCSS selector pointing to the header element of the site (e.g. #header), used to display Checkout notifications with the correct top offset (under the header)required
has-cookie-consentContains the value of the user's cookie consent. Only enabled when the value resolves to 'true'. It unlocks in-depth error tracking, A/B testing, etc. We strongly recommend adding it to the web component and passing in the correct cookie consent value.required

Note: All these attributes need to be set on the web component from the very start. If you mount the component first and then set e.g. the basket-id attribute afterward, it will not be considered and not work correctly.

JWT attribute

To ensure integrity, you need to provide the jwt attribute containing an encoded JSON payload. The value of the jwt attribute has to be a common JWT (JSON web token) string. The payload of the JWT contains the properties likes basketId to initialise the checkout. The JWT is then signed with the shopSecret. Find the example here.

NameDescriptionType
issIdentifies the principal that issued the token. It is typically a unique identifier or URL of the service responsible for generating the token. The recipient of the token can use this field to verify the authenticity of the issuer. See example.optional
audIntended recipients of the token. It is used to ensure that the token is only accepted by the services or users that are authorized. The value is typically a unique identifier or URI representing the audience. See example.optional
iatissued at / current unix timestamprequired
nbfnot-valid-before unix timestampoptional
expexpiry unix timestamprequired
basketIdsets the current basket id of the active sessionrequired
rBasketIdsalted hash of basketId for rate-limiting purposesoptional
customDatasets order-level custom data, must be a JSON stringoptional
carriersets preferred Carrier Groupoptional
campaignKeyset an active campaign, so that corresponding price-reductions are displayed in the checkout cartoptional
preferredCollectionPointsets preferred collection point data as objectoptional
preferredCollectionPoint.idcollection point idoptional
preferredCollectionPoint.typecollection point type. e.g. dhl_packstationoptional
vouchersets an pre-applied voucher codeoptional

If you require a more advanced configuration of your JWT parameters, please view the documentation.

Configuration

You can customise Checkout for your shops via the SCAYLE Panel. For details, follow the Configure & Customization section of this guide.

Checkout settings in the SCAYLE Panel

Tracking

Tracking events will be sent to the same Google Tag Manager (GTM) instance as the frontend application and the events will be attached to the same data layer object (window.dataLayer).

This section is important for the customers hosting their own storefront. For all other clients, this step is done by SCAYLE.

Your shop frontend is responsible for implementing the connection with the GTM (Google Tag Manager) and the corresponding data layer. It's crucial to ensure the correct data layer setup. To achieve this, insert the given code segment at the top of the page, just before initializing the checkout.

Add the following into your code to forward the events:

For more details and available events see the tracking overview.

Loading Indicator

You can optionally improve the UX for customers with slow internet connection by implementing a custom loading indication on the page that renders the checkout application, within the <body> tag.

SCAYLE does not provide a custom loading animation, so it's up to you to design and implement the loading-indicator. Below, we only show how a sample implementation could look like.

Example HTML Code:

Example JS Code

The code below does two things:

  1. It listens for the load event emitted by the checkout application upon successful initialization, while also monitoring for the error event in case anything goes wrong during app bootstrap.
  2. It sets the display CSS property of both <scayle-checkout> and #loading-indicator elements to show the checkout and hide custom loading indicator.

The script below can be added at the bottom of your body tag:

Methods

The Checkout web component provides a method to update the used basket ID (string) via setBasketId:

Events

You can find the event details in the table below. The list of event types may be extended in the future.

Event NameDescriptionTrigger
loadUse this if you want to show your own loading indicator until the component is readyCheckout has loaded all data for initial render
errorAn error state will be rendered by the Webcomponent. The load event will not be triggered in this caseCheckout has loaded all data for initial render, but there was an unrecoverable error
intentConfirmationCustomer has made the decision to buy / intents to confirm the orderCustomer clicks the "Pay Now" button
invalid-access-tokenWhen this event is sent, the storefront should refresh the access token and replace the access-token attribute on the web component with the new one. The checkout will then retry the failed request with the newly injected token.The access token used to authenticate the user is expired
authenticateDeprecated This event is fired to inform the shop frontend that a user has logged in or registered during checkoutUser logs in or signs up via Checkout

Examples

Authenticate

The Checkout web component can notify the parent shop frontend about specific events or user actions. Your application can subscribe to these events by adding a listener, as shown in the below example:

The event listener needs to be added within the page where you load your Checkout bundle.

This is connected to legacy flow and should be deprecated after all tenants are moved to token based auth

Invalid access token event

Checkout dispatches the event invalid-access-token to window.ayCheckoutFunctions . This event signals to the storefront that the current access token is no longer valid and needs to be refreshed. Storefront in this case should get a new access token and provide it back to Checkout.

Example/default
Checkout/checkout
Order Success Page (OSP)/order/success
Example URLhttps://<shopName.domain>/order/success?cbd=<base64EncodedToken>