升级到jdk17
This commit is contained in:
55
scripts/WechatAutoTest.java
Normal file
55
scripts/WechatAutoTest.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.gxwebsoft;
|
||||
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
|
||||
public class WechatAutoTest {
|
||||
public static void main(String[] args) {
|
||||
String merchantId = args[0];
|
||||
String privateKeyPath = args[1];
|
||||
String serialNumber = args[2];
|
||||
String apiV3Key = args[3];
|
||||
|
||||
try {
|
||||
System.out.println("🔧 正在创建 RSAAutoCertificateConfig...");
|
||||
|
||||
Config config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(merchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber(serialNumber)
|
||||
.apiV3Key(apiV3Key)
|
||||
.build();
|
||||
|
||||
System.out.println("✅ 微信支付证书配置成功!");
|
||||
System.out.println("");
|
||||
System.out.println("📋 配置信息:");
|
||||
System.out.println(" 商户号: " + merchantId);
|
||||
System.out.println(" 证书序列号: " + serialNumber);
|
||||
System.out.println(" 私钥路径: " + privateKeyPath);
|
||||
System.out.println("");
|
||||
System.out.println("🎉 RSAAutoCertificateConfig 已成功初始化");
|
||||
System.out.println("📥 系统将自动下载微信支付平台证书");
|
||||
System.out.println("🔄 证书过期时将自动更新");
|
||||
System.out.println("🚫 无需手动下载 wechatpay_cert.pem");
|
||||
System.out.println("");
|
||||
System.out.println("✨ 您的微信支付证书配置已完成!");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("❌ 证书配置失败: " + e.getMessage());
|
||||
System.err.println("");
|
||||
System.err.println("🔍 可能的原因:");
|
||||
System.err.println("1. 商户平台未开启API安全功能");
|
||||
System.err.println("2. APIv3密钥不正确");
|
||||
System.err.println("3. 证书序列号不匹配");
|
||||
System.err.println("4. 网络连接问题");
|
||||
System.err.println("");
|
||||
System.err.println("💡 解决方案:");
|
||||
System.err.println("1. 登录微信商户平台 -> 账户中心 -> API安全");
|
||||
System.err.println("2. 确认已申请使用微信支付公钥");
|
||||
System.err.println("3. 检查APIv3密钥和证书序列号");
|
||||
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user