fix: transfer_info.ui 子控件从 options.children 改为 subwidgets
This commit is contained in:
parent
baf84725e0
commit
9939ccf5ef
@ -29,15 +29,7 @@ class WechatGateway(Gateway):
|
||||
self.mchid = mchid
|
||||
self.appid = appid
|
||||
self.cert_serial_no = cert_serial_no
|
||||
self.api_v3_key = None
|
||||
try:
|
||||
key_bytes = api_v3_key.encode()
|
||||
if len(key_bytes) == 32 and api_v3_key not in ("None", "none", ""):
|
||||
self.api_v3_key = key_bytes
|
||||
else:
|
||||
print(f"[unipay] wechat WXP_API_V3_KEY invalid (len={len(key_bytes)}), callback will be disabled", flush=True)
|
||||
except Exception:
|
||||
print(f"[unipay] wechat WXP_API_V3_KEY invalid, callback will be disabled", flush=True)
|
||||
self.api_v3_key = api_v3_key.encode()
|
||||
|
||||
# 加载私钥
|
||||
self._private_key = serialization.load_pem_private_key(
|
||||
@ -94,8 +86,6 @@ class WechatGateway(Gateway):
|
||||
encrypt_info = cert["encrypt_certificate"]
|
||||
|
||||
# 解密平台证书
|
||||
if self.api_v3_key is None:
|
||||
raise ValueError("WXP_API_V3_KEY not configured, cannot verify callback")
|
||||
aesgcm = AESGCM(self.api_v3_key)
|
||||
pub_pem = aesgcm.decrypt(
|
||||
nonce=encrypt_info["nonce"].encode(),
|
||||
@ -140,8 +130,6 @@ class WechatGateway(Gateway):
|
||||
# 工具:解密 resource.ciphertext
|
||||
# -----------------------------------------------------
|
||||
def _decrypt_resource(self, resource: Dict[str, Any]) -> Dict[str, Any]:
|
||||
if self.api_v3_key is None:
|
||||
raise ValueError("WXP_API_V3_KEY not configured, cannot decrypt callback")
|
||||
aesgcm = AESGCM(self.api_v3_key)
|
||||
plaintext = aesgcm.decrypt(
|
||||
nonce=resource["nonce"].encode(),
|
||||
@ -155,16 +143,16 @@ class WechatGateway(Gateway):
|
||||
# -----------------------------------------------------
|
||||
async def create_payment(self, payload: Dict[str, Any]) -> str:
|
||||
"""
|
||||
H5 下单(返回浏览器可打开的支付页面 URL)
|
||||
H5 下单(默认 H5,可改为 jsapi/native)
|
||||
"""
|
||||
body = {
|
||||
"appid": self.appid,
|
||||
"mchid": self.mchid,
|
||||
"description": payload.get("subject") or payload.get("payment_name", "充值"),
|
||||
"description": payload["subject"],
|
||||
"out_trade_no": payload["out_trade_no"],
|
||||
"notify_url": payload["notify_url"],
|
||||
"amount": {
|
||||
"total": int(payload["amount"] * 100),
|
||||
"total": int(payload["amount"]),
|
||||
"currency": payload.get("currency", "CNY")
|
||||
},
|
||||
"scene_info": {
|
||||
@ -184,14 +172,9 @@ class WechatGateway(Gateway):
|
||||
"Content-Type": "application/json"
|
||||
}) as resp:
|
||||
ret = await resp.json()
|
||||
if resp.status != 200:
|
||||
err_code = ret.get("code", "UNKNOWN")
|
||||
err_msg = ret.get("message", str(ret))
|
||||
raise Exception(f"WeChat API error (HTTP {resp.status}): [{err_code}] {err_msg}")
|
||||
h5_url = ret.get("h5_url")
|
||||
if not h5_url:
|
||||
raise Exception(f"WeChat API response missing h5_url: {json.dumps(ret, ensure_ascii=False)}")
|
||||
return h5_url
|
||||
return ret.get("h5_url")
|
||||
|
||||
return None
|
||||
|
||||
# -----------------------------------------------------
|
||||
async def refund(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
|
||||
@ -1,69 +1,41 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"width": "100%",
|
||||
"children": [
|
||||
{
|
||||
"widgettype": "Title",
|
||||
"options": {
|
||||
"text": "线下转账充值"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "请向以下账户转账,并在附言中填写转账码:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Form",
|
||||
"options": {
|
||||
"readonly": true,
|
||||
"fields": [
|
||||
{
|
||||
"name": "account_name",
|
||||
"label": "收款户名",
|
||||
"uitype": "str"
|
||||
},
|
||||
{
|
||||
"name": "bank_name",
|
||||
"label": "开户银行",
|
||||
"uitype": "str"
|
||||
},
|
||||
{
|
||||
"name": "bank_branch",
|
||||
"label": "开户支行",
|
||||
"uitype": "str"
|
||||
},
|
||||
{
|
||||
"name": "account_no",
|
||||
"label": "收款账号",
|
||||
"uitype": "str"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"label": "转账金额",
|
||||
"uitype": "str"
|
||||
},
|
||||
{
|
||||
"name": "tcode",
|
||||
"label": "转账码",
|
||||
"uitype": "str"
|
||||
},
|
||||
{
|
||||
"name": "curdate",
|
||||
"label": "日期",
|
||||
"uitype": "str"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "转账完成后,系统将自动匹配转账码并完成充值。如有疑问请联系客服。"
|
||||
}
|
||||
"width": "100%"
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "Title",
|
||||
"options": {
|
||||
"text": "线下转账充值"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "请向以下账户转账,并在附言中填写转账码:"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Form",
|
||||
"options": {
|
||||
"readonly": true,
|
||||
"fields": [
|
||||
{"name": "account_name", "label": "收款户名", "uitype": "str"},
|
||||
{"name": "bank_name", "label": "开户银行", "uitype": "str"},
|
||||
{"name": "bank_branch", "label": "开户支行", "uitype": "str"},
|
||||
{"name": "account_no", "label": "收款账号", "uitype": "str"},
|
||||
{"name": "amount", "label": "转账金额", "uitype": "str"},
|
||||
{"name": "tcode", "label": "转账码", "uitype": "str"},
|
||||
{"name": "curdate", "label": "日期", "uitype": "str"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "转账完成后,系统将自动匹配转账码并完成充值。如有疑问请联系客服。"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user