This commit is contained in:
2026-06-11 18:56:00 +08:00
parent f2b4d7972e
commit 60c4c90a39
+3 -12
View File
@@ -367,7 +367,6 @@ def _get_wechat_client(
try:
from wechatpayv3 import WeChatPay, WeChatPayType
import os
except ImportError:
logger.error(
"wechatpayv3 is not installed. "
@@ -376,17 +375,9 @@ def _get_wechat_client(
return None
try:
# 创建并确保微信支付证书目录存在
wechat_cert_dir = os.path.abspath(os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"..",
"storage",
"wechat_certs"
))
os.makedirs(wechat_cert_dir, exist_ok=True)
logger.info("WeChat Pay platform certificates will be stored in: %s", wechat_cert_dir)
logger.info("Initializing WeChat Pay with cert_dir=None (no cache)")
# 初始化微信支付客户端
# 初始化微信支付客户端cert_dir=None,让 SDK 在线获取证书
_wechat_client = WeChatPay(
wechatpay_type=WeChatPayType.NATIVE,
mchid=mch_id,
@@ -395,7 +386,7 @@ def _get_wechat_client(
appid=appid,
apiv3_key=api_v3_key,
notify_url=notify_url,
cert_dir=wechat_cert_dir,
cert_dir=None, # 不缓存证书,每次都从微信服务器获取
)
_wechat_mch_id = mch_id
logger.info("WeChat Pay client initialized successfully")