Compare commits

..

No commits in common. "74aa5b87b9e5f4181521b40514c9e98e523a2263" and "7e792e438c7f2d8711c9c6a8aa556ca521fb5532" have entirely different histories.

3 changed files with 17 additions and 18 deletions

Binary file not shown.

View File

@ -134,7 +134,17 @@ async def refund_payment(request, params_kw=None):
exception(f'query_payment():{params_kw}, {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):
debug("wechat notify called .......")
provider = 'wechat'
@ -142,23 +152,18 @@ async def wechat_notify(request):
e = Exception(f'{provider} cannot pay')
exception(f'{e}')
return
data = None
try:
data = await PROVIDERS[provider].handle_notify(request)
except Exception as e:
e = Exception(f'{provider} cannot pay')
exception(f'{e}')
return
if data is None:
return {"code":"SUCCESS", "message":"OK"}
debug(f'{data=}')
try:
await unipay_accounting(request, data.data)
await unipay_accounting(request, data)
except Exception as e:
exception(f'{e}')
return {"code":"SUCCESS", "message":"OK"}
# 支付宝回调入口
async def alipay_notify(request):
debug("alipay notify called .......")
provider = 'alipay'

View File

@ -159,17 +159,16 @@ class AlipayGateway(Gateway):
# 退款
# ==============================================================================
async def refund(self, payload:DictObject) -> Dict[str, Any]:
async def refund(self, *, out_trade_no: str, refund_amount: str, out_request_no: str) -> Dict[str, Any]:
"""
out_request_no 必须全局唯一一个退款请求一个编号
"""
self.setup_session()
biz_content = {
"out_trade_no": payload.origin_id,
"refund_amount": payload.refund_amount,
"out_request_no": payload.out_trade_no
"notify_url": payload.notify_url
"out_trade_no": out_trade_no,
"refund_amount": refund_amount,
"out_request_no": out_request_no
}
params = {
@ -218,10 +217,5 @@ class AlipayGateway(Gateway):
"provider": "alipay",
"data": params,
}
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'
return DictObject(**ret)