English
In-Store Payment (Consumer)
Besides scanning to pay, the cashier mini-program gives customers an "in-store service" entry: visited stores, store details, consumption records and Mine. It is not an ordering or delivery system and offers no store-level checkout — paying in store always means scanning the QR terminal on site; store pages only present information and purchase history.
Page capabilities and the payment flow are covered in Usage & Payment Flow; publishing and QR rules are in Publishing & Go-Live.
Page Structure
| Page | WeChat / Alipay | Douyin | Data source |
|---|---|---|---|
| Stores (home tab) | Yes | Not generated | GET /client/store/visited |
| Mine (tab) | Yes | Not generated | GET /client/consumer/summary |
| Consumption records | Yes (opened from Mine) | Not generated | GET /client/consumer/order/page |
| Store detail | Yes (tap a store in the list) | Not generated | GET /client/store/get + recent 3 records |
| QR terminal entry page | Yes (debugging / manual input) | Fallback home page | Scan or type a QR terminal code |
Only "visited stores" are shown
The store list does not expose all platform stores (that would let anyone anonymously enumerate stores and bypass the in-store scan). It aggregates the current customer's paid orders, deduplicates by store, sorts by most recent purchase and returns at most 50 stores. Search is a local keyword filter with no server call.
Identity and Session
Stores, consumption records and Mine do not depend on a QR terminal and cannot reuse the QR terminal's mini-program authentication, so they use a separate silent auth flow:
- The frontend obtains an auth code via
uni.login/my.getAuthCode/tt.loginand callsPOST /client/consumer/auth(channel+authCode; Douyin may sendanonymousCode); - The backend reuses the cashier authentication capability to obtain
openId/userIdand issues a consumer session tokenconsumerToken; - Subsequent query endpoints accept only
Authorization: Bearer <consumerToken>; the identity triple(appId, channel, openId)is taken from the server-side session and the frontend no longer reports openId itself, eliminating forged-identity queries.
Session rules:
- The token is a random UUID stored in Redis (prefix
payment:consumer-session:), with a 30-minute sliding expiry renewed on every successful check; - A missing / malformed / expired token returns business code
10401; the frontend clears state, re-authenticates silently and retries once; - The session is completely independent of the admin login Sa-Token (
Accesstoken), and tokens are never written to logs; - Platform-tier authentication has no merchant app dimension, so
appIdin the session may be empty.
Store List
- Brand-colored header: title, keyword search box and a scan button;
- Each store card: logo, store name, address and last purchase time;
- Empty state: with no keyword it guides the user to "scan" a QR terminal; with a keyword it offers to clear the search;
- Refreshes on first entry and whenever returning from the payment page, so newly visited stores appear immediately (the token is reused within 30 minutes, with no repeated authorization);
- Authorization refusal and network errors show a failure state with retry.
Store Detail
The only entry is tapping a store in the list (storeNo). When launched by scanning, the startup-parameter dispatcher forwards straight to the QR terminal payment page and this page is not rendered.
What it shows:
- Facade photo (gradient placeholder when missing), logo, store name and merchant short name;
- Address with Navigate (opens the system map) and contact phone with Call (strips
-and spaces automatically); - A Scan to Pay button that opens the QR terminal payment page on site (stores and QR terminals are one-to-many, so a store cannot determine which QR terminal to use for an order — hence no online checkout);
- Recent purchases: the latest 3 paid orders of this store, with a link to the full consumption records.
Store detail is a public endpoint that returns only enabled stores and display fields (store name, logo, facade, address, phone, longitude/latitude) — never internal fields such as merchant No. or app ID. Anti-abuse is handled by IP-based rate limiting at the gateway/operations layer; the application does not duplicate it.
Consumption Records
- Queries only the current identity's paid orders (a refund does not change the order's paid status, so records remain after a refund);
- Grouped by payment date (Today / Yesterday / month-day / year-month-day) and sorted by payment time descending;
- Paged loading: 20 per page in the frontend, backend maximum 50 per page, page number at least 1;
- Supports pull-to-refresh and load-more; the summary row uses the Mine summary data and falls back to the paged total when unavailable;
- Order numbers are masked (last 8 characters kept, prefixed with
****); only amount, time, store name and status are shown.
Mine
- Header: a fixed avatar and generic label ("DaxPay user / in-store consumption account"; the UI never exposes openId / userId);
- Stat row: visited store count / order count / total amount spent;
- Menu: consumption records, terms & conditions, contact us, about us, dark mode (phase one follows the system and only displays the current setting);
- Footer: app version and ICP filing information (when configured; tap to copy).
Aggregation: the latest 1000 paid orders of the identity are aggregated in memory (visited stores are deduplicated by orders that carry a store No.; total amount is the sum of order amounts). Heavy users with more than 1000 orders see truncated totals, which is expected.
In-Store Payment Flow
The real payment entry for in-store purchases is the QR terminal in the store; the consumer pages only provide navigation and record keeping:
- Tap "Scan" on the store list or store detail, or scan the in-store QR terminal directly inside WeChat / Alipay;
- The QR terminal payment page loads the terminal and merchant info via
GET /client/device/qrcode/get-by-code?code=&clientEnv=&runtime=mini; - For random-amount terminals, enter the amount; fixed-amount terminals confirm directly; when the pay method needs identity, mini-program auth runs silently;
POST /client/device/qrcode/payinitiates the payment and launches the platform payment component;- After payment, the result is confirmed by the server state (see below).
Server-Side Payment Confirmation
The client's requestPayment / tradePay success callback only means the invocation succeeded — it must not be treated as payment success:
- With a fund trade No., the payment page polls
GET /unipay/gateway/pay-result?tradeNo=every 2 seconds for up to 15 attempts (about a 30-second confirmation window) for the authoritative server state (the same anonymous, unsigned endpoint used by the H5 result page); the result page also queries the same endpoint when it has a trade No. (single query, manual refresh); - Without a trade No. in the payment response, it falls back to the QR terminal order status
GET /client/device/qrcode/order-status?orderNo=and normalizes the polled status the same way; - Success is set only after the server confirms
paid;failed/closed/expiredare terminal states; if no terminal state is reached within the window the page stays at "Confirming payment result" with a refresh outlet and never assumes success; - On cancellation or invocation failure it also performs a short confirmation first (up to 3 attempts, about 4 seconds, covering the race where the money is deducted but the callback is still in flight) and shows failure with retry only when no terminal state is reached.
Scan Entry Fallback
- QR terminals are plain-link QR codes
/m/{code}: scanning inside a wallet may land on the home page, a store page or any registered page. Landing pages all call the startup-parameter dispatcher — as soon asoptions.qmatches a QR terminal link, theyreLaunchto the QR terminal payment page without rendering the current page, so the landing page configured in the mini-program console does not matter; - Douyin has no store / Mine pages generated, so its home page falls back to the QR terminal entry page (scan or type a terminal code) and no tabBar is registered, avoiding missing build-time paths;
- For the H5 fallback when the mini-program is unavailable or the QR rule misses, see Usage & Payment Flow.
Platform Differences
| Item | Alipay | Douyin | |
|---|---|---|---|
| Store / Mine tabs | Yes | Yes | No (home is the QR terminal entry page) |
| Navigation bar | Custom-drawn, brand-colored header | Native navigation bar | Custom-drawn |
| Brand / selected icons | WeChat brand colors | Alipay blue | N/A (no tabBar) |
| Dark mode | Follows the system (native tabBar colors sync) | Follows the system | Follows the system |
| UI language | Simplified Chinese / English (other system languages normalize to English) | Same | Same |
The tabBar is registered only for WeChat / Alipay (pages.config.ts generates it per build platform); on WeChat the tabBar colors reference the light/dark variables in theme.json, and the runtime language and colors are then overridden by the navigation helper.
API Reference
| Method | Path | Auth | Description |
|---|---|---|---|
| POST | /client/consumer/auth | None | Silent auth: exchange for openId / userId and issue consumerToken |
| GET | /client/consumer/order/page | Bearer | Consumption records, paged (optional storeNo, max 50 per page) |
| GET | /client/consumer/summary | Bearer | Summary (visited stores / orders / total amount) |
| GET | /client/store/get | None | Store detail by storeNo (enabled stores only) |
| GET | /client/store/visited | Bearer | Visited stores aggregated by purchases (max 50) |
| GET | /client/device/qrcode/get-by-code | None | QR terminal info (runtime=mini) |
| GET | /client/device/qrcode/order-status | None | QR terminal order status (payment-confirmation fallback) |
| GET | /unipay/gateway/pay-result | None | Authoritative payment result by fund trade No. |
Handle session expiry
Requests from Stores / Consumption Records / Mine that receive 10401 re-authenticate and retry once; if the user refuses authorization, the page shows a failure state. Never cache or pass openId as the query identity in business code.
Related Links
- Usage & Payment Flow: the three QR types and the page-by-page payment flow
- Publishing & Go-Live: plain-link QR rules and platform review
- Gateway Payment: gateway payment and QR terminal collection
- QR Code Plates & Terminals: generating, claiming and binding QR terminals to stores