English
Mock Channel: Payment Methods and Mock Payment
Mock emulates along two orthogonal dimensions: channel (provider) × way (way). The channel is the wallet the payer uses; the way is how the order is launched.
Nine Ways
| way | Meaning | State after order | payBody |
|---|---|---|---|
| QR | QR code (Native) | Pending | Confirmation page address |
| SCAN | QR redirect | Pending | Confirmation page address |
| H5 | Mobile browser | Pending | Confirmation page address |
| PC | Desktop website | Pending | Confirmation page address |
| APP | APP launch | Pending | Confirmation page address (simulated in-app cashier UI) |
| MP | Official account | Pending | prepay JSON |
| JSAPI | Web / mini program | Pending | prepay JSON |
| MINI_APP | Mini program | Pending | prepay JSON |
| BARCODE | Payment code scanned | Immediate | None |
Pending-family orders are stored without a final state; the final state is advanced manually on the confirmation page or delayed to auto success by the "Pending Order Advance" switch; payment code is decided immediately by the scene engine.
The main app maps platform payment methods to way (only OTHER without a fixed channel is out of scope); see the MockPayService.mapWay comments.
Aggregate Payment (One Code, Multiple Wallets)
When the order channel is provider=AGGREGATE (platform method aggregate_pay_qrcode), the order stays pending as QR and returns the confirmation page address — the "one code, multiple wallets" code.
The confirmation page replaces "Confirm Payment" with four wallet buttons: WeChat, Alipay, UnionPay QuickPass, and Douyin. Whichever you click is the wallet that paid. The order records the actual wallet and returns it to the main app through the synchronous receipt and the callback payload.
Aggregate orders pushed to success without a wallet are rejected with 40404; failures and pending states do not require a wallet.
Payment Code
Payment codes are checked against the basic channel format; invalid values return internal code 10022:
| Channel | Prefix | Length |
|---|---|---|
| 10–15 | 18 digits | |
| Alipay | 25–30 | 16–24 digits |
| UnionPay | 62 | 19 digits |
| Douyin | No public authoritative format; validation skipped | — |
Prefix recognition is a constant and cannot be configured. To create "unrecognized channel", use a value outside the ranges, such as starting with 77.
The phone payment code emulator (/#/authcode) generates a payment code QR directly and supports ?provider=WECHAT&mode=CONFIRM presets, useful for demonstrating a cashier scanning the customer.
Payment Parameter Simulation
This path solves "I only have the payment parameters produced by an order; how do I finish the payment":
- Go to "Mock Control → Payment Parameter Simulation" and paste WeChat or Alipay JSAPI / APP / mini program payment parameters;
- Click "Parse and Validate": field-level validation of the appId, prepay_id, signature, and time window, plus scene and order number recognition;
- Click "Generate Mock QR" to get a short code and a
/#/sim/{code}link; - Scan the QR with a phone to open the mock payment page, then click "Simulate Payment Success / Simulate Payment Failure" to decide.
- Mock order matched: the phone operation advances the order final state synchronously and triggers the callback; the PC page polls every 3 seconds to echo "phone opened", "phone operation result", and the latest callback delivery (HTTP status + response body);
- No order matched: only the simulation result is recorded; the page shows an orange hint "will not trigger a payment callback", and the PC page degrades to "no mock order matched · parameter validation only".
Alipay JSAPI payBody is a plain trade number string and can be pasted directly for parsing; WeChat JSAPI / mini program is prepay JSON (package carries prepay_id=mock_...).
WeChat Emulation
| Page | Address | Purpose |
|---|---|---|
| WeChat authorization emulation | /#/wxauth | Simulates the official-account web authorization redirect and callback |
| WeChat payment emulation | /#/wxpay/{tradeNo} | Simulates the confirm action of the in-WeChat payment page |
With the "WeChat openid validation" switch, you can exercise the failure path of a mismatched appid / openid; turning the switch off skips the whole block and is for comparison debugging only.