From fa6543ea54774088a74e3e8288f2a74cba27dde6 Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Mon, 15 Jun 2026 10:17:55 +0800 Subject: [PATCH] 1 --- video-gen-api/app/api/v1/payments.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/video-gen-api/app/api/v1/payments.py b/video-gen-api/app/api/v1/payments.py index e3fc9277..a94bd1c3 100644 --- a/video-gen-api/app/api/v1/payments.py +++ b/video-gen-api/app/api/v1/payments.py @@ -167,10 +167,11 @@ async def wechat_callback(request: Request, db: AsyncSession = Depends(get_db)): # 使用 AES-GCM 解密 try: - # API v3 key 需要转换为字节串 + # API v3 key 和 nonce 需要转换为字节串 api_v3_key_bytes = api_v3_key.encode('utf-8') + nonce_bytes = nonce_str.encode('utf-8') aesgcm = AESGCM(api_v3_key_bytes) - decrypted_str = aesgcm.decrypt(ciphertext, associated_data, nonce_str) + decrypted_str = aesgcm.decrypt(ciphertext, associated_data, nonce_bytes) except InvalidTag: logger.error("WeChat callback decryption failed: Invalid tag") raise HTTPException(status_code=400, detail="数据解密失败")