微信支付修改为配置文件
This commit is contained in:
@@ -24,13 +24,12 @@ email:
|
||||
wx_pay:
|
||||
# status close:关闭 open:打开
|
||||
status: close
|
||||
merchant_id: ${MERCHANT_ID:1705334978}
|
||||
privateKey_path: ${PRIVATEKEY_PATH:E:\wxPayCertify\1705334978_20250131_cert\apiclient_key.pem}
|
||||
merchant_serial_number: ${MERCHANT_SERIAL_NUMBER:354F4A0BD7A11CB756ED3BC380A0E41442DE68F7}
|
||||
api_v3_key: ${API_V3_KEY:zhyahjkiysetindhGseuHadjKITshons}
|
||||
public_key_path: ${PUBLIC_KEY_PATH:E:\wxPayCertify\pub_key.pem}
|
||||
public_key_id: ${PUBLIC_KEY_ID:PUB_KEY_ID_0117053349782025013000337100001480}
|
||||
#回调域名地址
|
||||
merchant_id: ${MERCHANT_ID:your_merchant_id}
|
||||
private_key: ${WX_PRIVATE_KEY:your_private_key}
|
||||
merchant_serial_number: ${MERCHANT_SERIAL_NUMBER:your_merchant_serial_number}
|
||||
api_v3_key: ${API_V3_KEY:your_api_v3_key}
|
||||
public_key: ${WX_PUBLIC_KEY:your_public_key}
|
||||
public_key_id: ${PUBLIC_KEY_ID:your_public_key_id}
|
||||
notify_domain: ${API_NOTIFY_DOMAIN:http://127.0.0.1:8080/api/}
|
||||
|
||||
# 支付宝支付
|
||||
|
||||
@@ -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