update pay ui
This commit is contained in:
@@ -43,14 +43,15 @@ ALIPAY_CONFIG = {
|
||||
|
||||
def load_key_from_file(file_path):
|
||||
"""从文件读取密钥内容"""
|
||||
import sys
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
return f.read().strip()
|
||||
except FileNotFoundError:
|
||||
print(f"❌ 密钥文件不存在: {file_path}")
|
||||
print(f"[AlipayConfig] Key file not found: {file_path}", file=sys.stderr)
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"❌ 读取密钥文件失败: {e}")
|
||||
print(f"[AlipayConfig] Read key file failed: {e}", file=sys.stderr)
|
||||
return None
|
||||
|
||||
|
||||
@@ -70,48 +71,48 @@ def validate_config():
|
||||
|
||||
# 检查 app_id
|
||||
if not ALIPAY_CONFIG.get('app_id') or ALIPAY_CONFIG['app_id'].startswith('your_'):
|
||||
issues.append("❌ app_id 未配置,请替换为真实的支付宝应用ID")
|
||||
issues.append("app_id not configured")
|
||||
|
||||
# 检查密钥文件
|
||||
if not os.path.exists(ALIPAY_CONFIG['app_private_key_path']):
|
||||
issues.append(f"❌ 应用私钥文件不存在: {ALIPAY_CONFIG['app_private_key_path']}")
|
||||
issues.append(f"Private key file not found: {ALIPAY_CONFIG['app_private_key_path']}")
|
||||
else:
|
||||
key = get_app_private_key()
|
||||
if not key or len(key) < 100:
|
||||
issues.append("❌ 应用私钥内容异常,请检查文件格式")
|
||||
issues.append("Private key content invalid")
|
||||
|
||||
if not os.path.exists(ALIPAY_CONFIG['alipay_public_key_path']):
|
||||
issues.append(f"❌ 支付宝公钥文件不存在: {ALIPAY_CONFIG['alipay_public_key_path']}")
|
||||
issues.append(f"Alipay public key file not found: {ALIPAY_CONFIG['alipay_public_key_path']}")
|
||||
else:
|
||||
key = get_alipay_public_key()
|
||||
if not key or len(key) < 100:
|
||||
issues.append("❌ 支付宝公钥内容异常,请检查文件格式")
|
||||
issues.append("Alipay public key content invalid")
|
||||
|
||||
return len(issues) == 0, issues
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("支付宝支付配置验证")
|
||||
print("Alipay Payment Config Validation")
|
||||
print("=" * 50)
|
||||
|
||||
is_valid, issues = validate_config()
|
||||
|
||||
if is_valid:
|
||||
print("✅ 配置验证通过!")
|
||||
print("[OK] Config validation passed!")
|
||||
print(f" App ID: {ALIPAY_CONFIG['app_id']}")
|
||||
print(f" 网关: {ALIPAY_CONFIG['gateway_url']}")
|
||||
print(f" 回调地址: {ALIPAY_CONFIG['notify_url']}")
|
||||
print(f" 同步跳转: {ALIPAY_CONFIG['return_url']}")
|
||||
print(f" Gateway: {ALIPAY_CONFIG['gateway_url']}")
|
||||
print(f" Notify URL: {ALIPAY_CONFIG['notify_url']}")
|
||||
print(f" Return URL: {ALIPAY_CONFIG['return_url']}")
|
||||
else:
|
||||
print("⚠️ 配置存在问题:")
|
||||
print("[ERROR] Config has issues:")
|
||||
for issue in issues:
|
||||
print(f" {issue}")
|
||||
print(f" - {issue}")
|
||||
|
||||
print("\n📋 配置步骤:")
|
||||
print("1. 登录支付宝开放平台 (open.alipay.com)")
|
||||
print("2. 创建应用并获取 App ID")
|
||||
print("3. 在开发设置中配置RSA2密钥")
|
||||
print("4. 将应用私钥、支付宝公钥放到 ./alipay/ 文件夹")
|
||||
print("5. 更新本文件中的配置信息")
|
||||
print("\nSetup steps:")
|
||||
print("1. Login to Alipay Open Platform (open.alipay.com)")
|
||||
print("2. Create app and get App ID")
|
||||
print("3. Configure RSA2 keys in development settings")
|
||||
print("4. Put private key and Alipay public key in ./alipay/ folder")
|
||||
print("5. Update config in this file")
|
||||
|
||||
print("=" * 50)
|
||||
|
||||
Reference in New Issue
Block a user