diff --git a/unipay/init.py b/unipay/init.py index 2e48052..662207c 100644 --- a/unipay/init.py +++ b/unipay/init.py @@ -137,48 +137,50 @@ async def refund_payment(request, params_kw=None): # 微信支付回调入口 async def wechat_notify(request): debug("wechat notify called .......") + json_response = request._run_ns.json_reponse provider = 'wechat' if PROVIDERS[provider] is None: e = Exception(f'{provider} cannot pay') exception(f'{e}') - return + return json_response({"code":"SUCCESS", "message":"OK"}) data = None try: data = await PROVIDERS[provider].handle_notify(request) except Exception as e: e = Exception(f'{provider} cannot pay') exception(f'{e}') - return + return json_response({"code":"SUCCESS", "message":"OK"}) if data is None: - return {"code":"SUCCESS", "message":"OK"} + return json_response({"code":"SUCCESS", "message":"OK"}) debug(f'{data=}') try: await unipay_accounting(request, data.data) except Exception as e: exception(f'{e}') - return {"code":"SUCCESS", "message":"OK"} + return json_response({"code":"SUCCESS", "message":"OK"}) # 支付宝回调入口 async def alipay_notify(request): debug("alipay notify called .......") + Response = request._run_ns.Response provider = 'alipay' if PROVIDERS[provider] is None: e = Exception(f'{provider} cannot pay') exception(f'{e}') - return + return Response(text='success', status=200) data = None try: data = await PROVIDERS[provider].handle_notify(request) except Exception as e: e = Exception(f'{provider} cannot pay') exception(f'{e}') - return + return Response(text='success', status=200) debug(f'{data=}') try: await unipay_accounting(request, data.data) except Exception as e: exception(f'{e}') - return {"code":"SUCCESS", "message":"OK"} + return Response(text='success', status=200) async def setup_callback_path(app): app.router.add_post('/unipay/notify/wechat', wechat_notify)