bugfix
This commit is contained in:
parent
5748eb7d76
commit
cd66c915e1
Binary file not shown.
@ -124,17 +124,7 @@ async def refund_payment(request, params_kw=None):
|
|||||||
exception(f'query_payment():{params_kw}, {e}')
|
exception(f'query_payment():{params_kw}, {e}')
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
# 回调入口:你可把厂商回调用各自 endpoint 再转发到这里,或在厂商控制台按各自 URL 配置
|
# 微信支付回调入口
|
||||||
async def payment_notify_handle(request, data):
|
|
||||||
logid = data.params.out_trade_no
|
|
||||||
pl = PaymentLog(request._run_ns)
|
|
||||||
plog = await pl.payed_log(logid)
|
|
||||||
await unipay_accounting(request, data)
|
|
||||||
if provider == "wechat":
|
|
||||||
return {"code":"SUCCESS", "message":"OK"}
|
|
||||||
else:
|
|
||||||
return "OK"
|
|
||||||
|
|
||||||
async def wechat_notify(request):
|
async def wechat_notify(request):
|
||||||
debug("wechat notify called .......")
|
debug("wechat notify called .......")
|
||||||
provider = 'wechat'
|
provider = 'wechat'
|
||||||
@ -142,18 +132,23 @@ async def wechat_notify(request):
|
|||||||
e = Exception(f'{provider} cannot pay')
|
e = Exception(f'{provider} cannot pay')
|
||||||
exception(f'{e}')
|
exception(f'{e}')
|
||||||
return
|
return
|
||||||
|
data = None
|
||||||
try:
|
try:
|
||||||
data = await PROVIDERS[provider].handle_notify(request)
|
data = await PROVIDERS[provider].handle_notify(request)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
e = Exception(f'{provider} cannot pay')
|
e = Exception(f'{provider} cannot pay')
|
||||||
exception(f'{e}')
|
exception(f'{e}')
|
||||||
return
|
return
|
||||||
|
if data is None:
|
||||||
|
return {"code":"SUCCESS", "message":"OK"}
|
||||||
|
debug(f'{data=}')
|
||||||
try:
|
try:
|
||||||
await unipay_accounting(request, data)
|
await unipay_accounting(request, data.data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exception(f'{e}')
|
exception(f'{e}')
|
||||||
return {"code":"SUCCESS", "message":"OK"}
|
return {"code":"SUCCESS", "message":"OK"}
|
||||||
|
|
||||||
|
# 支付宝回调入口
|
||||||
async def alipay_notify(request):
|
async def alipay_notify(request):
|
||||||
debug("alipay notify called .......")
|
debug("alipay notify called .......")
|
||||||
provider = 'alipay'
|
provider = 'alipay'
|
||||||
|
|||||||
@ -159,16 +159,17 @@ class AlipayGateway(Gateway):
|
|||||||
# 退款
|
# 退款
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
async def refund(self, *, out_trade_no: str, refund_amount: str, out_request_no: str) -> Dict[str, Any]:
|
async def refund(self, payload:DictObject) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
out_request_no 必须全局唯一(一个退款请求一个编号)
|
out_request_no 必须全局唯一(一个退款请求一个编号)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.setup_session()
|
self.setup_session()
|
||||||
biz_content = {
|
biz_content = {
|
||||||
"out_trade_no": out_trade_no,
|
"out_trade_no": payload.origin_id,
|
||||||
"refund_amount": refund_amount,
|
"refund_amount": payload.refund_amount,
|
||||||
"out_request_no": out_request_no
|
"out_request_no": payload.out_trade_no
|
||||||
|
"notify_url": payload.notify_url
|
||||||
}
|
}
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
@ -217,5 +218,10 @@ class AlipayGateway(Gateway):
|
|||||||
"provider": "alipay",
|
"provider": "alipay",
|
||||||
"data": params,
|
"data": params,
|
||||||
}
|
}
|
||||||
return DictObject(**ret)
|
ret = DictObject(**ret)
|
||||||
|
ret.data.action = 'UNKOWN'
|
||||||
|
if ret.data.notify_type == 'trade_status_sync':
|
||||||
|
ret.data.action = 'RECHARGE'
|
||||||
|
if ret.data.notify_type == 'refund_status_sync':
|
||||||
|
ret.data.action = 'RECHARGE_REVERSE'
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user