feat(M08-A): 接入充值微信支付调起
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# M08-A 充值微信支付 API
|
||||
|
||||
- `POST /app-api/recharge/orders/:rechargeOrderId/wechat-prepay`
|
||||
- 鉴权:顾客登录态,需 `profile.read`。
|
||||
- 行为:校验充值单属于当前用户,读取微信支付配置和当前用户 openid,创建 JSAPI 预支付。
|
||||
- 返回:`rechargeOrderId`、`rechargeNo`、`amountCents`、`timeStamp`、`nonceStr`、`package`、`signType`、`paySign`。
|
||||
|
||||
- `POST /app-api/recharge/wechat/notify`
|
||||
- 鉴权:微信支付平台证书签名和 AES-GCM 资源解密。
|
||||
- 行为:按 `out_trade_no` 定位充值单,校验金额,写入 `qipai_payment_callbacks` 幂等记录,成功后给钱包现金/赠送余额入账。
|
||||
- 隐私:通知 payload 入库前移除 `payer` 等敏感对象。
|
||||
@@ -0,0 +1,7 @@
|
||||
# M08-A 充值微信支付字段
|
||||
|
||||
- 迁移:`database/migrations/2026062524_m08a_recharge_wechat.*.sql`
|
||||
- 目的:让充值单独立记录微信预支付、交易号、回调幂等键和脱敏通知,不复用订单支付的 `order_id` 语义。
|
||||
- 正向变更:`qipai_recharge_orders` 新增 `payment_provider`、`provider_prepay_id`、`provider_payment_id`、`provider_callback_id`、`raw_notify`,并增加交易号与回调唯一键。
|
||||
- 回滚:删除新增唯一键和字段,删除迁移版本 `2026062524`。
|
||||
- 验证:检查 5 个新增字段和 2 个唯一索引存在。
|
||||
@@ -157,3 +157,32 @@ M08-A 仍为 `PARTIAL`。本次完成顾客端第一段工程闭环,但订单
|
||||
|
||||
- 工程提交:`e24920c`
|
||||
- 远端校验:待本轮 push 后执行 `HEAD == origin/main`。
|
||||
|
||||
## 2026-06-25 续接:顾客端充值微信支付调起
|
||||
|
||||
- 数据库新增 `2026062524_m08a_recharge_wechat` 迁移,为 `qipai_recharge_orders` 增加微信预支付 ID、微信交易号、回调幂等 ID 和脱敏通知 JSON,避免把充值单伪造成订单支付。
|
||||
- `RechargeService` 新增 `createWechatPrepay` 和 `processWechatNotification`,充值预支付复用微信支付配置、顾客 openid 和 JSAPI 参数生成;微信通知验签解密后按充值单号入账,重复通知不重复加余额。
|
||||
- `POST /app-api/recharge/orders/:rechargeOrderId/wechat-prepay` 暴露给小程序,校验当前登录顾客只能为本人充值单调起支付。
|
||||
- `POST /app-api/recharge/wechat/notify` 新增充值微信支付通知入口,通知 payload 入库前移除 `payer`。
|
||||
- 小程序充值页新增“微信支付”按钮,创建充值单后可调起微信支付;到账结果以后端通知和个人中心余额为准。
|
||||
- 迁移 runner 白名单纳入新迁移,并补充 API/DB changelog。
|
||||
|
||||
验收:
|
||||
|
||||
- `npm run build`(`backend/`):PASS。
|
||||
- `node scripts/check-miniapp-m08-a.mjs`:PASS。
|
||||
- `node tests/recharge-service.test.mjs`:PASS。
|
||||
- `node tests/recharge-route.test.mjs`:PASS。
|
||||
- `node tests/migration-contract.test.mjs`:PASS。
|
||||
- `node tests/migration-runner.test.mjs`:PASS。
|
||||
- `node tests/wechat-pay.test.mjs`:PASS。
|
||||
- `npm test`(`backend/`):PASS。
|
||||
|
||||
状态:
|
||||
|
||||
- M08-A 仍为 `PARTIAL`;余额/套餐/优惠券下单抵扣深度集成、真机合法域名、真实微信支付和实物开门验证待继续。
|
||||
|
||||
提交:
|
||||
|
||||
- 工程提交:待本轮 commit 后记录。
|
||||
- 远端校验:待本轮 push 后执行 `HEAD == origin/main`。
|
||||
|
||||
Reference in New Issue
Block a user