feat(wechat): Native payment → generate QR via env.data2qrpath → show Image for scan

This commit is contained in:
yumoqing 2026-07-17 13:33:18 +08:00
parent 24337faa55
commit 6d4dace412
2 changed files with 28 additions and 0 deletions

View File

@ -131,6 +131,9 @@ async def create_payment(request, params_kw=None):
data.client_ip = client_ip
res = await PROVIDERS[provider].create_payment(data)
debug(f'{provider=} instance return {res}')
if provider == 'wechat':
qrpath = await env.data2qrpath(res)
res = env.entire_url('/idfile') + '?path=' + env.quote(qrpath)
return res
raise Exception('write payment_log error')
except Exception as e:

View File

@ -2,6 +2,31 @@ params_kw.amount = float(params_kw.amount)
debug(f'recharge.dspy: {params_kw=}')
try:
url = await create_payment(request, params_kw)
if params_kw.provider == 'wechat':
return {
"widgettype": "VBox",
"options": {
"css": "card",
"padding": "20px",
"width": "320"
},
"subwidgets": [
{
"widgettype": "Image",
"options": {
"url": url,
"width": "280"
}
},
{
"widgettype": "Text",
"options": {
"text": "请使用微信扫描二维码完成支付",
"halign": "center"
}
}
]
}
return {
"widgettype":"NewWindow",
"options":{