Till integration walkthrough
This page walks through a complete till integration using only live endpoints. Each step links to its guide.
Once, at setup
Section titled “Once, at setup”- Get credentials. The brand gives you a client id and secret. Store the secret like a password. See Authentication.
- Map your stores. For each till location, find the LoyX store by your own store code:
GET /v1/stores/external/{external_store_id}. If a store has no code yet, set it withPATCH /v1/stores/{store_id}or ask the brand to. See Stores. - Decide your receipt id. Pick an id that is unique per brand for all time, for example
{store}-{register}-{number}. See Idempotency.
Every time a token expires
Section titled “Every time a token expires”POST /v1/auth/tokenwith your client id and secret. Cache the token until shortly beforeexpires_inruns out. On any401, get a new token and retry the call once.
At each sale
Section titled “At each sale” cashier scans app QR ──► lookup ──► card ──► (sale is paid) ──► record sale │ │ └─ 404: continue without a member ───────┘-
Identify. The member shows the QR code in the LoyX app. Send the scanned text, unchanged:
POST /v1/memberships/lookup{"identifier": "qr_code", "value": "<scanned text>"}Keep
membership_id. On404 qr_code_not_resolvable, ask the member to refresh the code. On404 membership_not_found, continue as a guest. See Identify a member. -
Show the card (optional). The lookup answer already has the balance, unit and cycle. Add the member’s usable rewards at this store with
GET /v1/memberships/{membership_id}/rewards?external_store_id=<your store code>. See Member card and rewards. -
Record the sale once it is paid:
POST /v1/transactionswith your receipt id inexternal.external_transaction_id, your store code inexternal.external_store_id, the member as{"identifier": "membership_id", "value": "..."}, and the lines. See Record a sale.Send it after the receipt prints, from a local queue. The sale should never wait on LoyX.
When things go wrong
Section titled “When things go wrong”| Situation | Do this |
|---|---|
No answer, timeout, 502/503/504 |
Retry the same request later. The receipt id makes it safe. |
429 |
Wait Retry-After seconds. |
401 |
Get a new token, retry once. |
409 external_transaction_id_conflict |
Two receipts share an id. Fix your id scheme; do not retry. |
422 |
Fix the fields listed in error.details; do not retry unchanged. |
| The till is offline | Queue sales locally, send them when online, in order. Late sales are accepted. |
Checklist before go-live
Section titled “Checklist before go-live”- Secrets are stored encrypted and never logged.
- Every sale carries a unique, stable
external_transaction_id. - A retried sale returns
200withIdempotent-Replayed: true, not a second sale. - QR text is sent unchanged.
- Amounts are integers in minor units.
- Sales are sent from a queue that survives a restart.
- Phone numbers, emails and national ids never appear in URLs or logs.
- Your client ignores unknown fields and enum values.