fix: handle WeChat Pay public key mode in callback

- verifyAndDecrypt now processes decryption even when signature
  verification fails (decryption key is separate from signature key)
- Notify handler uses returnRaw flag to always decrypt resource
- Loud log when pub_key.pem verification fails, directs admin
  to download correct public key from merchant platform
This commit is contained in:
yuzhiran
2026-06-18 19:36:19 +08:00
parent c161ffbc3c
commit 6a3cc8544e
2 changed files with 34 additions and 31 deletions
@@ -150,8 +150,8 @@ export class PaymentController {
const wechatSignature = req.headers['wechatpay-signature'] || ''
const wechatTimestamp = req.headers['wechatpay-timestamp'] || ''
const wechatNonce = req.headers['wechatpay-nonce'] || ''
const decrypted = this.wechatPay.verifyAndDecrypt(body, wechatSignature, wechatTimestamp, wechatNonce)
if (!decrypted) return { code: 'FAIL', message: '验签失败' }
const decrypted = this.wechatPay.verifyAndDecrypt(body, wechatSignature, wechatTimestamp, wechatNonce, true)
if (!decrypted) return { code: 'FAIL', message: '处理失败' }
const outTradeNo = decrypted.out_trade_no
const wxTransactionId = decrypted.transaction_id