This commit is contained in:
menxipeng
2025-08-03 16:56:44 +08:00
parent d6c5934dba
commit 85375b7f0c
18 changed files with 1627 additions and 282 deletions

View File

@@ -1,62 +1,62 @@
package com.ruoyi.common.config;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* 描述:
*
* @author menxipeng by 2023/12/15
*/
@Getter
@Component
public class AliPayConfig {
@Value("${alipay.gateway}")
private String aliPayGateway;
@Value("${alipay.appid}")
private String aliPayAppid;
@Value("${alipay.privateKey}")
private String aliPayPrivateKey;
@Value("${alipay.publicKey}")
private String aliPayPublicKey;
@Value("${alipay.merchantCertPath}")
private String merchantCertPath;
@Value("${alipay.alipayCertPath}")
private String alipayCertPath;
@Value("${alipay.alipayRootCertPath}")
private String alipayRootCertPath;
@Value("${alipay.notifyUrl}")
private String aliPayNotifyUrl;
@Value("${alipay.authUrl}")
private String aliPayAuthUrl;
@Value("${alipay.timeout}")
private Integer aliTimeOut;
@Bean
public void init() {
Config config = new Config();
config.protocol = "https";
config.gatewayHost = "openapi.alipay.com";
config.signType = "RSA2";
config.appId = aliPayAppid;
// 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
config.merchantPrivateKey = aliPayPrivateKey;
//注证书文件路径支持设置为文件系统中的路径或CLASS_PATH中的路径优先从文件系统中加载加载失败后会继续尝试从CLASS_PATH中加载
config.merchantCertPath = merchantCertPath;
config.alipayCertPath = alipayCertPath;
config.alipayRootCertPath = alipayRootCertPath;
//注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
//可设置异步通知接收服务地址(可选)
config.notifyUrl = aliPayNotifyUrl;
Factory.setOptions(config);
}
}
//package com.ruoyi.common.config;
//
//import com.alipay.easysdk.factory.Factory;
//import com.alipay.easysdk.kernel.Config;
//import lombok.Getter;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//
///**
// * 描述:
// *
// * @author menxipeng by 2023/12/15
// */
//@Getter
//@Component
//public class AliPayConfig {
//
// @Value("${alipay.gateway}")
// private String aliPayGateway;
// @Value("${alipay.appid}")
// private String aliPayAppid;
// @Value("${alipay.privateKey}")
// private String aliPayPrivateKey;
// @Value("${alipay.publicKey}")
// private String aliPayPublicKey;
// @Value("${alipay.merchantCertPath}")
// private String merchantCertPath;
// @Value("${alipay.alipayCertPath}")
// private String alipayCertPath;
// @Value("${alipay.alipayRootCertPath}")
// private String alipayRootCertPath;
// @Value("${alipay.notifyUrl}")
// private String aliPayNotifyUrl;
// @Value("${alipay.authUrl}")
// private String aliPayAuthUrl;
// @Value("${alipay.timeout}")
// private Integer aliTimeOut;
//
//
// @Bean
// public void init() {
// Config config = new Config();
// config.protocol = "https";
// config.gatewayHost = "openapi.alipay.com";
// config.signType = "RSA2";
//
// config.appId = aliPayAppid;
// // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
// config.merchantPrivateKey = aliPayPrivateKey;
// //注证书文件路径支持设置为文件系统中的路径或CLASS_PATH中的路径优先从文件系统中加载加载失败后会继续尝试从CLASS_PATH中加载
// config.merchantCertPath = merchantCertPath;
// config.alipayCertPath = alipayCertPath;
// config.alipayRootCertPath = alipayRootCertPath;
// //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
// //可设置异步通知接收服务地址(可选)
// config.notifyUrl = aliPayNotifyUrl;
//
// Factory.setOptions(config);
// }
//
//}