1
This commit is contained in:
@@ -4,6 +4,11 @@ import certifi
|
||||
import ssl
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# 先定义 logger
|
||||
import time as _time
|
||||
logger = logging.getLogger("payment")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
# 尝试禁用 SSL 验证(用于解决证书问题)
|
||||
try:
|
||||
_create_unverified_https_context = ssl._create_unverified_context
|
||||
@@ -16,7 +21,6 @@ else:
|
||||
# 修复 WebUtils.py 中 bytes 和 str 拼接的问题
|
||||
def fix_alipay_web_utils():
|
||||
try:
|
||||
import sys
|
||||
from alipay.aop.api.util import WebUtils
|
||||
|
||||
# 保存原始的 do_post 函数
|
||||
@@ -28,14 +32,12 @@ def fix_alipay_web_utils():
|
||||
except Exception as e:
|
||||
# 如果是 ResponseException,尝试修复错误信息
|
||||
error_msg = str(e)
|
||||
if "invalid http status" in error_msg or "ResponseException" in error_msg:
|
||||
if "invalid http status" in error_msg or "ResponseException" in error_msg or "can only concatenate str (not \"bytes\") to str" in error_msg:
|
||||
# 重新实现一个更安全的版本
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import ssl
|
||||
import json
|
||||
import socket
|
||||
from alipay.aop.api.exception.ResponseException import ResponseException
|
||||
|
||||
logger.warning("Alipay SDK ResponseException detected, using fallback request")
|
||||
@@ -121,10 +123,6 @@ from app.utils.id_gen import generate_id, generate_order_no
|
||||
# ---------------------------------------------------------------------------
|
||||
# Payment logger → log/payment/YYYY-MM-DD.log (one file per day, no cleanup)
|
||||
# ---------------------------------------------------------------------------
|
||||
import time as _time
|
||||
|
||||
logger = logging.getLogger("payment")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
_log_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "log", "payment")
|
||||
os.makedirs(_log_dir, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user