unipay/wwwroot/recharge.dspy
yumoqing 1a2d8f8f2d feat(wechat): switch from H5 to Native payment (QR code scan)
- Change API endpoint from /v3/pay/transactions/h5 to /v3/pay/transactions/native
- Remove scene_info (not needed for native mode)
- Return code_url instead of h5_url
- recharge.dspy: display QR code image via api.qrserver.com
- user_recharge.dspy: return both code_url and qr_url
2026-07-15 17:22:40 +08:00

23 lines
509 B
Plaintext

import urllib.parse
params_kw.amount = float(params_kw.amount)
debug(f'recharge.dspy: {params_kw=}')
try:
code_url = await create_payment(request, params_kw)
qr_img_url = 'https://api.qrserver.com/v1/create-qr-code/?size=280x280&data=' + urllib.parse.quote(code_url, safe='')
return {
"widgettype":"NewWindow",
"options":{
"url": qr_img_url,
"height": "340",
"width":"340"
}
}
except Exception as e:
return {
"widgettype":"Text",
"options":{
"width":"100%",
"text":f"{e}"
}
}