From 97524da74de64fc5de966d3402ddd4484828403c Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 15 Jul 2026 17:43:06 +0800 Subject: [PATCH] fix(wechat): use Response instead of missing json_response in callback ServerEnv().json_reponse does not exist, causing 'NoneType' object is not callable. Align with alipay_notify pattern: use aiohttp Response directly with JSON string body. --- unipay/init.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/unipay/init.py b/unipay/init.py index a1c104c..4dd936c 100644 --- a/unipay/init.py +++ b/unipay/init.py @@ -184,27 +184,26 @@ async def refund_payment(request, params_kw=None): # 微信支付回调入口 async def wechat_notify(request): debug("wechat notify called .......") - json_response = ServerEnv().json_reponse + Response = ServerEnv().Response provider = 'wechat' if PROVIDERS[provider] is None: e = Exception(f'{provider} cannot pay') exception(f'{e}') - return json_response({"code":"SUCCESS", "message":"OK"}) + return Response(text='{"code":"SUCCESS","message":"OK"}', content_type='application/json') data = None try: data = await PROVIDERS[provider].handle_notify(request) except Exception as e: - e = Exception(f'{provider} cannot pay') exception(f'{e}') - return json_response({"code":"SUCCESS", "message":"OK"}) + return Response(text='{"code":"SUCCESS","message":"OK"}', content_type='application/json') if data is None: - return json_response({"code":"SUCCESS", "message":"OK"}) + return Response(text='{"code":"SUCCESS","message":"OK"}', content_type='application/json') debug(f'{data=}') try: await unipay_accounting(request, data.data) except Exception as e: exception(f'{e}') - return json_response({"code":"SUCCESS", "message":"OK"}) + return Response(text='{"code":"SUCCESS","message":"OK"}', content_type='application/json') # 支付宝回调入口 async def alipay_notify(request):