From 56bf87dfda434644d367b54cf656781ef9b85a9e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 18 Dec 2025 15:44:53 +0800 Subject: [PATCH] bugfix --- unipay/providers/alipay.py | 5 +++-- unipay/providers/wechat.py | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/unipay/providers/alipay.py b/unipay/providers/alipay.py index 67f7234..ac3130d 100644 --- a/unipay/providers/alipay.py +++ b/unipay/providers/alipay.py @@ -192,12 +192,13 @@ class AlipayGateway(Gateway): # 回调 / 异步通知(验签) # ============================================================================== - async def handle_notify(self, request, params) -> Dict[str, Any]: + async def handle_notify(self, request) -> Dict[str, Any]: """ 支付宝异步通知验签 + """ + form = await request.post() params = dict(form) - """ sign = params.pop("sign", None) sign_type = params.pop("sign_type", None) diff --git a/unipay/providers/wechat.py b/unipay/providers/wechat.py index c5d6274..0b26280 100644 --- a/unipay/providers/wechat.py +++ b/unipay/providers/wechat.py @@ -3,6 +3,7 @@ import base64 import json import time import aiohttp +from appPublic.dictObject import DictObject from typing import Dict, Any from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import padding @@ -234,7 +235,7 @@ class WechatGateway(Gateway): } # ----------------------------------------------------- - async def handle_notify(self, headers: Dict[str, str], body: str) -> Dict[str, Any]: + async def handle_notify(self, request) -> Dict[str, Any]: """ 解密/验证回调,返回标准 dict: out_trade_no @@ -242,6 +243,8 @@ class WechatGateway(Gateway): trade_state payer info """ + headers = request.headers + body = await request.read().decode('utf-8') await self._verify_callback(headers, body) payload = json.loads(body) @@ -249,11 +252,9 @@ class WechatGateway(Gateway): decrypted = self._decrypt_resource(resource) # 返回标准结构 - return { + ret = { "provider": "wechat", - "data": decrypted, - "out_trade_no": decrypted.get("out_trade_no"), - "trans_no": decrypted.get("transaction_id"), - "status": decrypted.get("trade_state") + "params": decrypted } + return DictObject(**ret)