微信支付修改为配置文件
This commit is contained in:
@@ -24,33 +24,33 @@ public class WxPayConfig {
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Value("${wx_pay.merchant_id}")
|
||||
private String merchantId = "";
|
||||
@Value("${wx_pay.merchant_id:}")
|
||||
private String merchantId;
|
||||
/**
|
||||
* 商户API私钥路径
|
||||
* 商户API私钥内容
|
||||
*/
|
||||
@Value("${wx_pay.privateKey_path}")
|
||||
private String privateKeyPath = "";
|
||||
@Value("${wx_pay.private_key:}")
|
||||
private String privateKeyContent;
|
||||
/**
|
||||
* 商户证书序列号
|
||||
*/
|
||||
@Value("${wx_pay.merchant_serial_number}")
|
||||
private String merchantSerialNumber = "";
|
||||
@Value("${wx_pay.merchant_serial_number:}")
|
||||
private String merchantSerialNumber;
|
||||
/**
|
||||
* 商户APIV3密钥
|
||||
*/
|
||||
@Value("${wx_pay.api_v3_key}")
|
||||
private String apiV3Key = "";
|
||||
@Value("${wx_pay.api_v3_key:}")
|
||||
private String apiV3Key;
|
||||
/**
|
||||
* 平台公钥地址
|
||||
* 平台公钥内容
|
||||
*/
|
||||
@Value("${wx_pay.public_key_path}")
|
||||
private String publicKeyPath = "";
|
||||
@Value("${wx_pay.public_key:}")
|
||||
private String publicKeyContent;
|
||||
/**
|
||||
* 平台公钥地址ID
|
||||
* 平台公钥ID
|
||||
*/
|
||||
@Value("${wx_pay.public_key_id}")
|
||||
private String publicKeyId = "";
|
||||
@Value("${wx_pay.public_key_id:}")
|
||||
private String publicKeyId;
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,18 +60,18 @@ public class WxPayConfig {
|
||||
@ConditionalOnProperty(name = "wx_pay.status", havingValue = "open")
|
||||
public RSAPublicKeyConfig rSAAutoCertificateConfig() {
|
||||
Assert.hasText(merchantId, "微信支付的商户号不能为空");
|
||||
Assert.hasText(privateKeyPath, "商户API私钥路径不能为空");
|
||||
Assert.hasText(privateKeyContent, "商户API私钥不能为空");
|
||||
Assert.hasText(merchantSerialNumber, "商户证书序列号不能为空");
|
||||
Assert.hasText(apiV3Key, "商户APIV3密钥不能为空");
|
||||
Assert.hasText(publicKeyPath, "微信支付平台公钥地址不能为空");
|
||||
Assert.hasText(publicKeyContent, "微信支付平台公钥不能为空");
|
||||
Assert.hasText(publicKeyId, "微信支付平台公钥Id不能为空");
|
||||
|
||||
return new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(merchantId)
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.privateKey(privateKeyContent)
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3Key)
|
||||
.publicKeyFromPath(publicKeyPath)
|
||||
.publicKey(publicKeyContent)
|
||||
.publicKeyId(publicKeyId)
|
||||
.build();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class WxPayConfig {
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "wx_pay.status", havingValue = "open")
|
||||
public PrivateKey privateKey(){
|
||||
return PemUtil.loadPrivateKeyFromPath(privateKeyPath);
|
||||
return PemUtil.loadPrivateKeyFromString(privateKeyContent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user