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.mchid = mchid
|
||||||
self.appid = appid
|
self.appid = appid
|
||||||
self.cert_serial_no = cert_serial_no
|
self.cert_serial_no = cert_serial_no
|
||||||
self.api_v3_key = None
|
self.api_v3_key = api_v3_key.encode()
|
||||||
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._private_key = serialization.load_pem_private_key(
|
self._private_key = serialization.load_pem_private_key(
|
||||||
@ -94,8 +86,6 @@ class WechatGateway(Gateway):
|
|||||||
encrypt_info = cert["encrypt_certificate"]
|
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)
|
aesgcm = AESGCM(self.api_v3_key)
|
||||||
pub_pem = aesgcm.decrypt(
|
pub_pem = aesgcm.decrypt(
|
||||||
nonce=encrypt_info["nonce"].encode(),
|
nonce=encrypt_info["nonce"].encode(),
|
||||||
@ -140,8 +130,6 @@ class WechatGateway(Gateway):
|
|||||||
# 工具:解密 resource.ciphertext
|
# 工具:解密 resource.ciphertext
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
def _decrypt_resource(self, resource: Dict[str, Any]) -> Dict[str, Any]:
|
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)
|
aesgcm = AESGCM(self.api_v3_key)
|
||||||
plaintext = aesgcm.decrypt(
|
plaintext = aesgcm.decrypt(
|
||||||
nonce=resource["nonce"].encode(),
|
nonce=resource["nonce"].encode(),
|
||||||
@ -155,16 +143,16 @@ class WechatGateway(Gateway):
|
|||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
async def create_payment(self, payload: Dict[str, Any]) -> str:
|
async def create_payment(self, payload: Dict[str, Any]) -> str:
|
||||||
"""
|
"""
|
||||||
H5 下单(返回浏览器可打开的支付页面 URL)
|
H5 下单(默认 H5,可改为 jsapi/native)
|
||||||
"""
|
"""
|
||||||
body = {
|
body = {
|
||||||
"appid": self.appid,
|
"appid": self.appid,
|
||||||
"mchid": self.mchid,
|
"mchid": self.mchid,
|
||||||
"description": payload.get("subject") or payload.get("payment_name", "充值"),
|
"description": payload["subject"],
|
||||||
"out_trade_no": payload["out_trade_no"],
|
"out_trade_no": payload["out_trade_no"],
|
||||||
"notify_url": payload["notify_url"],
|
"notify_url": payload["notify_url"],
|
||||||
"amount": {
|
"amount": {
|
||||||
"total": int(payload["amount"] * 100),
|
"total": int(payload["amount"]),
|
||||||
"currency": payload.get("currency", "CNY")
|
"currency": payload.get("currency", "CNY")
|
||||||
},
|
},
|
||||||
"scene_info": {
|
"scene_info": {
|
||||||
@ -184,14 +172,9 @@ class WechatGateway(Gateway):
|
|||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}) as resp:
|
}) as resp:
|
||||||
ret = await resp.json()
|
ret = await resp.json()
|
||||||
if resp.status != 200:
|
return ret.get("h5_url")
|
||||||
err_code = ret.get("code", "UNKNOWN")
|
|
||||||
err_msg = ret.get("message", str(ret))
|
return None
|
||||||
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
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
async def refund(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
async def refund(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"width": "100%",
|
"width": "100%"
|
||||||
"children": [
|
},
|
||||||
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "Title",
|
"widgettype": "Title",
|
||||||
"options": {
|
"options": {
|
||||||
@ -20,41 +21,13 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"readonly": true,
|
"readonly": true,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{"name": "account_name", "label": "收款户名", "uitype": "str"},
|
||||||
"name": "account_name",
|
{"name": "bank_name", "label": "开户银行", "uitype": "str"},
|
||||||
"label": "收款户名",
|
{"name": "bank_branch", "label": "开户支行", "uitype": "str"},
|
||||||
"uitype": "str"
|
{"name": "account_no", "label": "收款账号", "uitype": "str"},
|
||||||
},
|
{"name": "amount", "label": "转账金额", "uitype": "str"},
|
||||||
{
|
{"name": "tcode", "label": "转账码", "uitype": "str"},
|
||||||
"name": "bank_name",
|
{"name": "curdate", "label": "日期", "uitype": "str"}
|
||||||
"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"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -66,4 +39,3 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user