修复多商户轮换死锁,并加固回调解密与证书校验。

余额不足等明确错误在查单宽限 PENDING 时会卡死不换号;现确认无单后切换,停用商户仍可解回调、请求带 notify_url。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-14 03:28:42 +08:00
parent ca4b52217f
commit 537e538528
3 changed files with 121 additions and 17 deletions

View File

@@ -102,8 +102,8 @@ def verify_wechat_sign(headers, body, wx_cfg=None):
if wx_cfg:
cfgs = [wx_cfg]
else:
from utils.wechat_mch_service import list_enabled_wx_cfgs
cfgs = list_enabled_wx_cfgs()
from utils.wechat_mch_service import list_wx_cfgs_for_callback
cfgs = list_wx_cfgs_for_callback()
for cfg in cfgs:
cert_path = _resolve_platform_pub_path(cfg, serial=serial)
@@ -139,10 +139,10 @@ def decrypt_callback_with_merchants(associated_data, nonce, ciphertext):
仅对启用商户密钥做 AES 尝试(通常很少),成功后返回 (plaintext, wx_cfg)。
业务侧再用 out_bill_no 反查记录上的 mch_id对齐一致性。
"""
from utils.wechat_mch_service import list_enabled_wx_cfgs
from utils.wechat_mch_service import list_wx_cfgs_for_callback
last_err = None
for cfg in list_enabled_wx_cfgs():
for cfg in list_wx_cfgs_for_callback():
try:
text = decrypt_callback_ciphertext(associated_data, nonce, ciphertext, wx_cfg=cfg)
return text, cfg