This commit is contained in:
menxipeng
2025-08-03 13:58:34 +08:00
parent 58e70a009d
commit d6c5934dba
21 changed files with 1027 additions and 7 deletions

View File

@@ -0,0 +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);
}
}

View File

@@ -0,0 +1,56 @@
//package com.ruoyi.common.config;
//
//import com.lvcai.lvcaibiwebstarter.constant
// .IStatusCode;
//import com.lvcai.lvcaibiwebstarter.enums.GenericStatusCode;
//import lombok.AllArgsConstructor;
//import lombok.Data;
//import lombok.Setter;
//
///**
// * 描述:
// *
// * @author menxipeng by 2023/12/15
// */
//
//@AllArgsConstructor
//public enum PayStatusCode {
//
// /**
// * 稍后再试
// */
// TRY_AGAIN_LATER(902, "稍后再试"),
//
// /**
// * 支付方式错误
// */
// PAY_TYPE_ERROR(990, "支付方式错误"),
//
// PAY_ERROR(991, "支付失败"),
// /**
// * 支付宝预创建订单失败
// */
// ALI_PRE_CREATE_FAIL(992, "支付宝预创建订单失败"),
//
// // 重复上传
// REPEAT_UPLOAD(993, "重复上传"),
// ;
//
// public int codeValue;
// public String msg;
//
// @Override
// public int getCodeSegment() {
// return 15;
// }
//
// @Override
// public int getCodeValue() {
// return this.codeValue;
// }
//
// @Override
// public String getMsg() {
// return this.msg;
// }
//}