Files
vf_react/wechat_pay_config.py
2025-12-13 16:39:54 +08:00

73 lines
2.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
微信支付真实配置文件
请根据您的微信商户平台信息填写
"""
import os
# 获取当前文件所在目录(确保无论从哪里启动都能找到证书)
_BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# 微信支付配置 - 请替换为您的真实信息
WECHAT_PAY_CONFIG = {
# 基础配置
'app_id': 'wx0edeaab76d4fa414', # 微信公众平台AppID
'mch_id': '1718543833', # 微信支付商户号
'api_key': '141a5753c42526bb44bc44d6c4277664', # 微信商户平台设置的API密钥
# 证书文件路径(使用绝对路径,兼容 gunicorn 多进程启动)
'cert_path': os.path.join(_BASE_DIR, 'certs', 'apiclient_cert.pem'),
'key_path': os.path.join(_BASE_DIR, 'certs', 'apiclient_key.pem'),
# 回调配置
'notify_url': 'https://api.valuefrontier.cn/api/payment/wechat/callback',
# 其他配置
'sign_type': 'MD5',
'trade_type': 'NATIVE'
}
# 配置验证函数
def validate_config():
"""验证配置是否完整"""
issues = []
if WECHAT_PAY_CONFIG['app_id'].startswith('wx你的'):
issues.append("❌ app_id 还是示例值请替换为真实的微信AppID")
if WECHAT_PAY_CONFIG['mch_id'].startswith('你的'):
issues.append("❌ mch_id 还是示例值,请替换为真实的商户号")
if WECHAT_PAY_CONFIG['api_key'].startswith('你的'):
issues.append("❌ api_key 还是示例值请替换为真实的32位API密钥")
# 检查证书文件(路径已是绝对路径)
for key in ['cert_path', 'key_path']:
if not os.path.exists(WECHAT_PAY_CONFIG[key]):
issues.append(f"❌ 证书文件不存在: {WECHAT_PAY_CONFIG[key]}")
return len(issues) == 0, issues
if __name__ == "__main__":
print("微信支付配置验证")
print("=" * 50)
is_valid, issues = validate_config()
if is_valid:
print("✅ 配置验证通过!")
else:
print("⚠️ 配置存在问题:")
for issue in issues:
print(f" {issue}")
print("\n📋 配置步骤:")
print("1. 登录微信商户平台 (pay.weixin.qq.com)")
print("2. 获取AppID和商户号")
print("3. 在API安全中设置32位API密钥")
print("4. 下载证书文件并放到 ./certs/ 文件夹")
print("5. 更新本文件中的配置信息")
print("=" * 50)