About the Basket API
Till-identical basket and receipt calculation, exposed as one stateless call.
Basket API, or 52API BASKET, is a REST interface over HTTP(S) that takes a basket and returns what it costs. Its value is that it makes discounts work exactly the way they do at a regular till.
It is part of the 52MASTERPRICER suite.
Characteristics
From the specification:
- Stateless REST interface
- No persistence of basket or receipt
- Multiple 52ViKING tills can serve calls, allowing load balancing and scale
- Each till has a single article import and database, with multiple execution threads
- Accepts and returns XML or JSON
Because it is stateless and free of side effects, Basket API doubles as a test harness: it is a good way to assert pricing behaviour automatically, which the spec calls out explicitly.
CalculateBasket
Called whenever a receipt is to be calculated. The calculation logic is controlled by 52ViKING, and all discounts are applied to articles eligible for discount.
Receipts are line-orientated
A line can hold one or more single articles. Articles may be sold one-by-one or by quantity, and either way the lines are neither collapsed nor expanded. A quantity of three is one line, not three.
Chain and store both matter. Promotions are configured per store, so the store number in the path determines the answer you get. A wrong-but-valid store number is the usual explanation for the API disagreeing with a till.