diff --git a/app/payment/zpay.py b/app/payment/zpay.py index 96aa3d0..b738826 100644 --- a/app/payment/zpay.py +++ b/app/payment/zpay.py @@ -4,6 +4,7 @@ ZPAY 支付渠道实现 支持:页面跳转支付、API 接口支付、异步通知验签 """ import hashlib +import json from typing import Any, Dict, Optional import requests @@ -119,6 +120,12 @@ class ZPayProvider(PaymentProvider): result = resp.json() except Exception: result = {} + # ZPAY 可能返回二次编码的 JSON(body 为 JSON 字符串),需再次解析 + if isinstance(result, str): + try: + result = json.loads(result) + except Exception: + result = {} if not isinstance(result, dict): result = {} try: