For the complete documentation index, see llms.txt. This page is also available as Markdown.

Instore Checkout Flow

1. Overview

Instore checkout is a server-side state machine served by a single endpoint, /api/v1/orders/checkout/. Each step is a POST to that endpoint with a ?page=<PageName> parameter. Every response returns the pages the server will accept next and the current pre_order object.

The server owns the flow order. Skipping a step or resubmitting an earlier one directly affects the state of all later steps.

Request Conventions

Item
Value

Base URL

/api/v1/. The checkout path is orders/checkout/ ($U.CHECKOUT in the client).

Read current state

GET /orders/checkout/ with no parameters. LoyaltyMoneyUsagePage and LoyaltyCardPage can also be read with GET ?page=….

Submit a step

POST /orders/checkout/?page=<PageName>. The request body is application/x-www-form-urlencoded.

Headers

X-Requested-With: XMLHttpRequest, X-CSRFToken (from the csrftoken cookie), X-Store-CSRFToken (from the store_csrftoken cookie) and accept-language. Add x-currency when a segment currency is defined.

Session

Carried by cookies (withCredentials: true). Checkout runs on the session bound to the customer's basket.

Integration Rules

Apply these rules in every integration. They prevent ordering errors of the kind seen in APS-4430.

  1. Determine the next request from context_list[].page_name in the latest response. Never hardcode the page order in the client.

  2. Do not treat HTTP 200 as success. Check the errors field in every response; if it is populated, the step did not advance.

  3. Confirm that a step is complete by checking the matching pre_order field, for example pre_order.shipping_option.

  4. When an earlier step changes, resubmit every later step in order.

  5. Do not submit a new step before the previous response arrives. All steps modify the same session state.

2. State Diagram

The main flow runs linearly from IndexPage to PaymentOptionSelectionPage. The delivery type selects the address or store branch, and payment_type starts one of four payment sub-flows.

The dashed line shows that resubmitting an earlier step can invalidate later selections, which must then be resubmitted. The QR branch never reaches ThankYouPage: the order completes outside the checkout endpoint, and completion is known only from the status_url response.

3. Step and Endpoint Reference

Every step is POST /api/v1/orders/checkout/?page=<PageName>. The tables below list only the page value and the request body. The Response column shows the next page expected in context_list when the step succeeds, and the fields the client reads from it.

Main Flow

#

Step

page

Body

Response

0

Read state

None (GET)

—

IndexPage: is_user_logged_in, can_guest_purchase, has_gift_box, followed by every page currently open. On page reload, the flow resumes from here.

1

Guest customer

IndexPage

user_email, phone_number

Only when is_user_logged_in=false and can_guest_purchase=true. Errors return in errors.user_email / errors.phone_number.

2

Delivery type

DeliveryOptionSelectionPage or RemoteDeliveryOptionSelectionPage

delivery_option

delivery_options[] with delivery_option_type: customer (to address) or retail_store (to store). The next page is AddressSelectionPage or RetailStoreSelectionPage, depending on the type.

3a

Address

AddressSelectionPage

shipping_address, billing_address (address pk)

addresses[], country. On success, ShippingOptionSelectionPage opens.

3b

Store

RetailStoreSelectionPage

retail_store, billing_address

retail_stores[], addresses[] (for billing).

4

Shipping

ShippingOptionSelectionPage or RemoteShippingOptionSelectionPage

shipping_option

shipping_options[]. On success, PaymentOptionSelectionPage opens and pre_order.shipping_option is set.

5

Payment method

PaymentOptionSelectionPage

payment_option

payment_options[] (each with a payment_type), checkout_url (QR), status_url (order status). The next page depends on payment_type; see Payment sub-flows.

6

Completion

—

—

ThankYouPage: order_number, new_user. The order is created and the flow ends.

Remote variants. The Remote* pages are used in the remote sales flow. The client does not choose the variant: if the server returns RemoteDeliveryOptionSelectionPage, send the following delivery and shipping requests to the Remote* pages as well. The address step has no remote variant.

Payment Sub-Flows

After the payment method is selected, the remaining steps depend on payment_type.

cash_register (pay at till with a barcode)

  1. CashRegisterInstallmentSelectionPage: send installment=<pk> or no_installment=true. The context returns cards[] (installment options).

  2. CashRegisterPage: send agreement=true. Barcode generation starts.

  3. CashRegisterCompletePage: send an empty body and poll every 5 seconds. The context returns barcode and number. When the payment is taken at the till, the response returns ThankYouPage. The client polls for about 30 minutes; see section 4, step 8.

To send the barcode by SMS, call SendBarcodeSmsPage with phone_number, agreement and payment_option.

funds_transfer (bank transfer / EFT)

  1. FundsTransferChoicePage: send bank_account. The context returns bank_accounts[].

  2. FundsTransferPage: send agreement. The result is ThankYouPage.

pay_on_delivery (cash or POS on delivery)

  1. PayOnDeliveryPaymentChoicePage: send payment_choice. The context returns payment_choices[]; the client submits the first option automatically.

  2. card_pos only: OrderSelectionPage with extra_field={"authorization_code":"…"}.

  3. PayOnDeliveryPage: send agreement. The result is ThankYouPage.

qr (customer pays on their own device)

QR is not a standalone payment method. Instore selects a placeholder method; when the customer completes payment on the website or app, their chosen method overwrites it.

  1. Submit PaymentOptionSelectionPage with payment_option=<pk> of the first option in payment_options whose payment_type is not cash_register. The list is not filtered further, so this can be any type, such as card or bank transfer. If the list contains only cash_register, send payment_option empty.

  2. Display checkout_url as a QR code. Optionally send it by SMS with SendCheckoutUrlSmsPage.

  3. Poll status_url with GET every 5 seconds (see QR payment status service).

QR payment status service

This service tells the client whether the order has been created and whether payment is complete. Section 6 explains how the order is created through Commerce checkout. The QR option is shown only when the config_has_pay_with_qr UI setting is enabled and the PaymentOptionSelectionPage response contains status_url.

Property
Value

Endpoint

The status_url from the PaymentOptionSelectionPage response, for example /api/v1/orders/checkout-with-token/<token>/status/. It is not a fixed URL; the token is basket-specific.

Method

GET

Client note

Instore rebuilds the URL against its base URL from the part after /orders: 'orders' + status_url.split('/orders')[1]. The request uses the same HTTP client as checkout (cookies and CSRF headers).

Start

As soon as the QR option is selected.

Interval

5 seconds. The timer does not wait for responses; a pending previous request is cancelled.

Limit

Up to 359 requests (~30 min) until the order is created. When the order is first created, the counter resets and up to 59 more requests (~5 min) are sent for payment confirmation.

Response Example:

Field
Meaning

order_created

Whether the order has been created on the customer side.

order_number

Number of the created order.

status.label

Order status. payment_waiting and waiting_for_payment mean payment is pending; any other value (for example completed) means payment is complete.

status.value

Numeric status code (for example 300, 500).

How the client interprets the response:

Condition
Client behavior

order_created: false

Keep showing the QR code and countdown; polling continues.

order_created: true, payment pending

Show a waiting screen stating the payment is being processed; polling continues for confirmation.

order_created: true, any other status.label

Payment is complete. Show the thank-you screen with order_number; polling stops.

Request error

Ignored; polling continues at the next interval.

No order after 359 requests

The session has timed out. The user can return to payment options or restart the QR.

Order created, no confirmation after 59 requests

Confirmation not received. The order number is shown; the user can restart the check (the counter resets).

In the QR flow, ThankYouPage never comes from the checkout endpoint. Completion is known only from this service's response.

Auxiliary Pages

These pages can be called at any point in the flow. They do not advance the flow; they only update pre_order.

page

Body

Effect

GiftBoxPage

note

Adds a gift box (when IndexPage.has_gift_box=true).

GiftBoxIndexPage

—

Removes the gift box.

OrderNotePage

notes

Adds an order note; an empty value deletes it.

LoyaltyMoneyUsagePage

GET, or POST loyalty_amount_to_use

GET returns balance. POST 0 resets the loyalty money used.

LoyaltyCardPage

GET

Returns loyalty_total_amount, loyalty_amount, applied_amount, card_number, minimum_basket_amount.

SampleProductPage

Sample product selection

Context: sample_products[], allowed_quantity. Errors in errors.sample_products.

AddressClearPage

—

Clears the selected addresses after the last address is deleted.

Address management. Creating and updating addresses is not part of the checkout flow. Use POST /address/ and PATCH /address/<pk>/. Afterwards, refresh the state with GET /orders/checkout/ and resubmit AddressSelectionPage with the new address pk.

4. End-to-End Example: Delivery To Address, Payment at Till

This example shows a logged-in customer completing checkout with delivery to an address and barcode payment at the till. The pk values and labels are illustrative, and responses show only the relevant fields. Every response has the same structure: context_list, pre_order, errors.

Step 1: Read the current state

Step 2: Select the Delivery Type

Step 3: Select the Address

Step 4: Select the Shipping Option

Step 5: Select the Payment Method

Step 6: Select Installments (Single Payment)

Step 7: Generate the Barcode

If agreement is missing, the same page returns with errors: { "agreement": ["…"] } and HTTP 200.

Step 8: Retrieve the Barcode and Wait For Payment (Polling)

Polling starts as soon as the cash_register payment method is selected and repeats on a 5-second client-side timer. The barcode arrives in this request's response; there is no separate call.

  • Interval: A request starts every 5 seconds; the timer does not wait for responses. When a new request starts, any pending previous request is cancelled on the client. A response that takes longer than 5 seconds therefore never reaches the client.

  • Limit: The client sends at most 359 requests (about 30 minutes), matching the 30-minute on-screen countdown. When time runs out, polling stops; the user can reset the counter and restart with the retry button.

  • End: When the response returns ThankYouPage, the order is complete.

Response while payment is pending:

Response after payment is taken at the till:

Store pickup variant. Send delivery_option=2 in step 2 and run step 3 as RetailStoreSelectionPage with retail_store=<pk>&billing_address=<pk>. The remaining steps are unchanged.

5. Error Handling

The checkout API returns errors in two forms. Handle each one separately.

  • Validation error (HTTP 200). The response has the standard structure with errors populated. context_list still points to the page the server expects, so the step has not advanced. An integration that checks only the HTTP status treats this as success.

  • HTTP error (4xx/5xx). The request is rejected. The Instore client shows error.message to the user. For infrastructure status codes such as 503, it redirects the user to the /503 page.

Error Fields

The table lists the error fields the Instore client handles, by step.

Step
Field
When

IndexPage (guest)

errors.user_email, errors.phone_number

Email or phone number is missing or invalid.

Payment completion (CashRegisterPage, FundsTransferPage, PayOnDeliveryPage)

errors.agreement

Agreement consent was not sent.

All steps

errors.non_field_errors (array or string)

Business rule error not tied to a field. The client shows the first array item.

SampleProductPage

errors.sample_products

Allowed quantity exceeded, or an invalid sample product was selected.

OrderSelectionPage (card POS)

errors.non_field_errors (HTTP 200) or errors in the HTTP error body

Invalid authorization code.

POST /address/

Per field: first_name, last_name, line, phone_number, country, city, township, district, identity_number, short_address, title. General: detail, non_field_errors

Address form validation error, returned with HTTP 4xx.

Skipped Steps and Incorrect Ordering

Situation
Behavior
Correct usage

Request to a page that is not open yet (for example, ShippingOptionSelectionPage before a delivery type is selected)

The server does not apply the step. context_list returns the earlier page it expects, and errors names the missing prerequisite, for example delivery_option: This field is required.

After each request, choose the next request from page_name in context_list. Do not advance through a fixed list of page names.

An earlier step changes (for example, delivery type)

Selections in later steps may become invalid. The Instore client therefore resubmits the address immediately after a delivery type change (setDeliveryOptionWithAddress).

Resubmit the steps after the changed one, in order: address → shipping → payment.

Address list is empty

The client clears shipping_options; for guests, pre_order.delivery_option becomes null. The shipping step cannot be reached.

First POST /address/, then GET and AddressSelectionPage.

Last address is deleted

The deleted address may remain selected in pre_order, so the client calls AddressClearPage.

POST AddressClearPage, then GET.

CashRegisterCompletePage before the barcode is generated

No barcode is returned.

CashRegisterInstallmentSelectionPage, then CashRegisterPage, then start polling.

PayOnDeliveryPage without a payment choice

The Instore client never produces this state: it submits the first option (payment_choices[0]) to PayOnDeliveryPaymentChoicePage as soon as the PaymentOptionSelectionPage response arrives.

PayOnDeliveryPaymentChoicePage first; for card POS, OrderSelectionPage in between.

Polling limit reached

Barcode: after 359 requests (~30 min) the client shows a timeout screen. QR: 359 requests (~30 min) if no order was created, 59 requests (~5 min) if it was.

Return to payment selection for a new barcode or QR.

Consistency between responses. If a response returns billing_address or delivery_option empty after it was populated in the previous response, the client resubmits the step to correct it. If the server keeps returning the same incomplete response, the client enters an infinite loop. This is a defect in the Instore client and should be tracked as a separate bug.

6. Instore and Commerce Checkout Differences

Instore and Commerce checkout share the same endpoint, response structure and ?page= mechanism. They differ in which pages they use and how payment completes. The table reflects Instore client behavior; the Commerce column shows what Instore disables or hands off to Commerce.

Topic
Instore checkout
Commerce checkout

Who runs the flow

Store staff, on the customer's basket and session. The session is not ended for inactivity during checkout.

The customer, on their own device (website or app).

Supported payment types

Only cash_register, funds_transfer, pay_on_delivery and QR. The client removes other payment_type values from the list; credit_card, saved_card and redirection are disabled in the client.

Card-based payment types are used here.

Payment completion

Asynchronous. Till payment is tracked by CashRegisterCompletePage polling, QR by status_url polling; for POS, the authorization code is sent to OrderSelectionPage.

The customer completes payment on their own device.

QR payment

Instore does not create the order. It selects a placeholder payment method, shows checkout_url as a QR code and tracks the result through status_url; no ThankYouPage is returned.

The customer opens checkout_url from the QR code and pays in Commerce checkout, where the order is created. The customer's method overwrites Instore's placeholder.

Till and SMS pages

CashRegisterInstallmentSelectionPage, CashRegisterPage, CashRegisterCompletePage, SendBarcodeSmsPage, SendCheckoutUrlSmsPage.

Not used.

Remote sales

RemoteDeliveryOptionSelectionPage and RemoteShippingOptionSelectionPage.

Standard delivery and shipping pages.

Client-side filters

is-mail and hoopkapida shipping options are hidden. When the UI setting is on, addresses and stores are filtered by the store's country.

No filters; the server returns all options.

Last updated

Was this helpful?