diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bbe7b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__/ +*.pyc +*.pyo diff --git a/scripts/__pycache__/load_path.cpython-310.pyc b/scripts/__pycache__/load_path.cpython-310.pyc deleted file mode 100644 index 18709d7..0000000 Binary files a/scripts/__pycache__/load_path.cpython-310.pyc and /dev/null differ diff --git a/unipay/providers/wechat.py b/unipay/providers/wechat.py index 55f359d..9e34947 100644 --- a/unipay/providers/wechat.py +++ b/unipay/providers/wechat.py @@ -172,9 +172,14 @@ class WechatGateway(Gateway): "Content-Type": "application/json" }) as resp: ret = await resp.json() - return ret.get("h5_url") - - return None + 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 # ----------------------------------------------------- async def refund(self, payload: Dict[str, Any]) -> Dict[str, Any]: