nomadro/apps/miniprogram/docs/wechat-virtual-pay-props.md
Eric b845d0bcea Update WeChat virtual pay OfferID and AppKeys; document miniprogram props.
Switch pay signing to sandbox/live AppKey by WX_PAY_ENV and record the product catalog.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-22 10:59:27 +08:00

56 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 微信小程序虚拟支付 · 账号与道具
SoT 代码:`apps/api/services/ebook_svc/domains/books/products.py`
支付签名:`apps/api/services/ebook_svc/services/wxpay.py`(`WX_PAY_ENV=0` 现网 / `1` 沙箱自动选 AppKey)
## 账号
| 项 | 值 |
|---|---|
| AppID(小程序) | `wx11f6afc44ea1532f` |
| OfferID(支付应用) | `1450705308` |
| 现网 AppKey | `JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY` |
| 沙箱 AppKey | `BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi` |
环境变量(`apps/api` / `.env`):
```env
WX_APPID=wx11f6afc44ea1532f
WX_SECRET=…
WX_OFFER_ID=1450705308
WX_APP_KEY=JUN15h8sl5sNQt0awMSrd4Jpv1aSGOYY
WX_SANDBOX_APP_KEY=BQ1DlPjq3PIEzV4UwXQrKxLtqAqlmAEi
WX_PAY_ENV=0
```
微信后台路径:**支付与交易 → 虚拟支付 → 道具管理**(须与下表 `product_id` / 价格一致后再发版)。
## 道具目录(Nomadro 小程序)
| key | 道具 ID (`productId`) | 价格 | 试读% | 图 | 说明 |
|---|---|---|---|---|---|
| `free` | (空) | 免费 | 100 | — | 不拉起支付 |
| `tiktok` | `tiktok` | ¥88(8800 分) | 30 | `props/tiktok.png` | 已发布 |
| `youtube` | `youtube` | ¥188(18800 分) | 30 | `props/youtube.png` | 默认付费方案 |
| `nomad` | `nomad` | ¥49(4900 分) | 30 | `props/nomad.png` | 已发布 |
| `svip` | `svip` | ¥998(99800 分) | 30 | `props/svip.png` | 已发布 |
| `ebook` | `ebook_unlock_default` | ¥188(18800 分) | 30 | `props/ebook.png` | 旧默认道具 |
| `test` | `test` | ¥1(100 分) | 30 | `props/test.png` | 联调;须在 MP 发布 |
后台图标目录:`apps/admin/public/props/`。
遗留数字 ID 映射(旧订单兼容):`298→tiktok`、`188→youtube`、`49→nomad`、`998→svip`。
## 调用链
1. 小程序下单 → `POST /pay/...`(`apps/api` ebook_svc)
2. 服务端用 OfferID + `productId` + 价格生成 `signData` / `paySig`
3. 端上 `wx.requestVirtualPayment`
4. 发货 / 查单走 `/xpay/*`,签名用当前环境 AppKey
## 验收
- 开发者工具:`WX_PAY_ENV=1` 用沙箱 AppKey
- 真机现网:`WX_PAY_ENV=0`,道具已在 MP「发布」且价格与上表一致
- 路径:登录 → 下单 → `requestVirtualPayment` → 发货回调