Skip to main content

Example: Identity code in kiosk

This page describes an example of what could be done by combining a Code Interpreter, a discount calculator handling deals and a frontend plugin showing membership information.

The example case supports a guest scanning a QR code in a kiosk. This code is used to authenticate to a loyalty integration (not a full login of the user, only a loyalty identity) and connecting the order to the guest identity for discounts and loyalty points perspective.

info

Example of the below is available in demo code on GitHub at https://github.com/Future-Ordering/loyalty-integration-sample.

Scanning a QR code for identity

When scanning the QR code for identity, the code will be sent to the Code Interpreter. If the Code Interpreter identifies that this code is a valid identity code, the Code Interpreter will call the Future Ordering APIs to create a deal for the order, then reserve the deal on the order and will finally respond with an action for the UI to welcome the person by name.

The Code Interpreter, when it creates the deal, attaches the identity of the user on the deal itself, so that the identity can be used in discount calculations later.

Discount calculation

Once the user has scanned the QR code for identity, each change to the order will trigger the reserved deal to have fulfillment requested. The fulfillment of a deal is to set which discounts it should provide.

Since the Code Interpreter part of the loyalty integration has attached the loyalty identifier of the user on the Deal, the discount calculation can use that identity to check which discounts the user should get. To see more about calculating discounts, please refer to the article on handling deals.

Accumulate loyalty points (earn points)

In order to let guests earn points on their purchases, the loyalty integration can also subscribe a webhook for the event that occurs when the deal is captured. A captured deal means that the order is placed in POS correctly and that the deal is reserved on the order. For more detailed information about handling a captured deal, please refer to the article about handling deals.

Show loyalty points

Given that the loyalty integration also exposes an endpoint for retrieving the number of accrued loyalty point, a frontend plugin can be made to show the loyalty identity and the number of points the user has.

The plugin could also provide ways for the user to burn points to apply discounts or similar, by calling the loyalty integration APIs which in turn sets new discounts on the order. This last case is not included in the below sequence diagram.