mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-14 05:43:46 +08:00
📝 格式化代码,修改文档
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
## 1.0.20.RELEASE
|
||||||
|
### 微信支付
|
||||||
|
|
||||||
|
- enhance: 增加了通过微信公钥对微信支付相关接口的响应内容或微信回调通知的参数进行验签的支持。
|
||||||
|
- 微信配置项增加了:``` wechat-pay-public-key-id: 微信支付公钥的ID、 wechat-pay-public-key-path:微信支付公钥的路径、wechat-pay-public-key-absolute-path: 微信支付公钥的绝对路径、 switch-verify-sign-method: 是否启用从平台证书切换到微信支公钥```
|
||||||
|
- `wechat-pay-public-key-id ` 与`wechat-pay-public-key-path或wechat-pay-public-key-absolute-path`<font color=red>同时正确配置</font>,才会启用微信支付公钥验签,否则默认使用平台证书进行验签。</font>
|
||||||
|
- 如果需要[从平台证书切换成微信支付公钥](https://pay.weixin.qq.com/doc/v3/merchant/4012154180#5.-%E6%B2%A1%E6%9C%89%E4%BD%BF%E7%94%A8%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98SDK%E7%9A%84%E5%95%86%E6%88%B7%E5%A6%82%E4%BD%95%E5%B0%86%E5%B9%B3%E5%8F%B0%E8%AF%81%E4%B9%A6%E5%88%87%E6%8D%A2%E6%88%90%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E5%85%AC%E9%92%A5),请启用`switch-verify-sign-method`参数
|
||||||
|
- enhance: 增加了微信支付V3版本的付款码支付``codePay``与撤销API``reverse``(仅支持普通商户模式,服务商模式暂不支持)
|
||||||
|
- factor: 升级了spring-boot-parent版本从 2.7.7 到2.7.18
|
||||||
|
- factor: 升级了Alipay SDK版本从4.31.7.ALL到4.40.251.ALL
|
||||||
## 1.0.18.RELEASE
|
## 1.0.18.RELEASE
|
||||||
### 微信支付
|
### 微信支付
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ wechat:
|
|||||||
mch-id: 1603337223
|
mch-id: 1603337223
|
||||||
domain: https://felord.cn/miniapp
|
domain: https://felord.cn/miniapp
|
||||||
cert-path: miniapp/apiclient_cert.p12
|
cert-path: miniapp/apiclient_cert.p12
|
||||||
|
#微信公钥ID
|
||||||
|
wechat-pay-public-key-id: PUB_KEY_ID_0116278111111115222222501
|
||||||
|
#微信公钥
|
||||||
|
wechat-pay-public-key-path: pub_key.pem
|
||||||
|
wechat-pay-public-key-absolute-path: D:\\felord\\wechat\\cert\\pub_key.pem
|
||||||
|
#是否启用从平台证书切换成微信支付公钥 不填默认为false
|
||||||
|
switch-verify-sign-method: true
|
||||||
```
|
```
|
||||||
|
|
||||||
> ❗注意:在一套系统中需要开发者保证`tentanID`唯一。
|
> ❗注意:在一套系统中需要开发者保证`tentanID`唯一。
|
||||||
|
|||||||
@@ -80,14 +80,17 @@ public class InMemoryWechatTenantService implements WechatTenantService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private WeChatPublicKeyInfo initWeChatPublicKeyInfo(WechatMetaBean meta) {
|
private WeChatPublicKeyInfo initWeChatPublicKeyInfo(WechatMetaBean meta) {
|
||||||
boolean enablePublicKey=StringUtils.hasLength(meta.getV3().getWeChatPayPublicKeyId()) && StringUtils.hasLength(meta.getV3().getWeChatPayPublicKeyPath());
|
boolean enablePublicKey=StringUtils.hasLength(meta.getV3().getWechatPayPublicKeyId()) &&
|
||||||
|
(StringUtils.hasLength(meta.getV3().getWechatPayPublicKeyPath())||StringUtils.hasLength(meta.getV3().getWechatPayPublicKeyAbsolutePath()));
|
||||||
if (!enablePublicKey) {
|
if (!enablePublicKey) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String certPath=meta.getV3().getWeChatPayPublicKeyPath();
|
String certPath=meta.getV3().getWechatPayPublicKeyPath();
|
||||||
|
String certAbsolutePath = meta.getV3().getWechatPayPublicKeyAbsolutePath();
|
||||||
Resource resource =
|
Resource resource =
|
||||||
resourceLoader.getResource(certPath == null ? "classpath:wechat/pub_key.pem" :
|
StringUtils.hasLength(certAbsolutePath) ? new FileSystemResource(certAbsolutePath) :
|
||||||
|
resourceLoader.getResource(!StringUtils.hasLength(certPath) ? "classpath:wechat/pub_key.pem" :
|
||||||
certPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX) ? certPath : ResourceUtils.CLASSPATH_URL_PREFIX + certPath);
|
certPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX) ? certPath : ResourceUtils.CLASSPATH_URL_PREFIX + certPath);
|
||||||
PemReader pemReader = new PemReader(new InputStreamReader(resource.getInputStream()));
|
PemReader pemReader = new PemReader(new InputStreamReader(resource.getInputStream()));
|
||||||
PemObject pemObject = pemReader.readPemObject();
|
PemObject pemObject = pemReader.readPemObject();
|
||||||
@@ -95,10 +98,8 @@ public class InMemoryWechatTenantService implements WechatTenantService {
|
|||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(keySpec);
|
RSAPublicKey publicKey = (RSAPublicKey) keyFactory.generatePublic(keySpec);
|
||||||
// 生成公钥
|
// 生成公钥
|
||||||
WeChatPublicKeyInfo keyInfo = new WeChatPublicKeyInfo(publicKey, meta.getV3().getWeChatPayPublicKeyId(), meta.getTenantId());
|
return new WeChatPublicKeyInfo(publicKey, meta.getV3().getWechatPayPublicKeyId(), meta.getTenantId());
|
||||||
return keyInfo;
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
|
||||||
throw new PayException("An error occurred while generating the public key,Please check the format and content of the configured public key");
|
throw new PayException("An error occurred while generating the public key,Please check the format and content of the configured public key");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,14 +80,16 @@ public class WechatPayProperties {
|
|||||||
/**
|
/**
|
||||||
* wechat pay public key id
|
* wechat pay public key id
|
||||||
*/
|
*/
|
||||||
private String weChatPayPublicKeyId;
|
private String wechatPayPublicKeyId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012154180#4.1-%E8%8E%B7%E5%8F%96%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E5%85%AC%E9%92%A5">
|
* see <a href="https://pay.weixin.qq.com/doc/v3/merchant/4012154180#4.1-%E8%8E%B7%E5%8F%96%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E5%85%AC%E9%92%A5">
|
||||||
* </a>
|
* </a>
|
||||||
* wechat pay public key
|
* wechat pay public key
|
||||||
*/
|
*/
|
||||||
private String weChatPayPublicKeyPath;
|
private String wechatPayPublicKeyPath;
|
||||||
|
|
||||||
|
private String wechatPayPublicKeyAbsolutePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ public class SignatureProvider {
|
|||||||
|
|
||||||
public boolean isSwitchVerifySignMethod(String tenantId) {
|
public boolean isSwitchVerifySignMethod(String tenantId) {
|
||||||
|
|
||||||
String publicKeyId=wechatMetaContainer.getWechatMeta(tenantId).getV3().getWeChatPayPublicKeyId();
|
String publicKeyId=wechatMetaContainer.getWechatMeta(tenantId).getV3().getWechatPayPublicKeyId();
|
||||||
|
|
||||||
Boolean switchVerifySignMethod = wechatMetaContainer.getWechatMeta(tenantId).getV3().getSwitchVerifySignMethod();
|
Boolean switchVerifySignMethod = wechatMetaContainer.getWechatMeta(tenantId).getV3().getSwitchVerifySignMethod();
|
||||||
|
|
||||||
@@ -456,6 +456,6 @@ public class SignatureProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getWechatPublicKeyId(String tenantId) {
|
public String getWechatPublicKeyId(String tenantId) {
|
||||||
return wechatMetaContainer.getWechatMeta(tenantId).getV3().getWeChatPayPublicKeyId();
|
return wechatMetaContainer.getWechatMeta(tenantId).getV3().getWechatPayPublicKeyId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user