mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
🎨 格式化代码,增加部分注释
This commit is contained in:
@@ -186,10 +186,7 @@ public class SignatureProvider {
|
|||||||
* @return the boolean
|
* @return the boolean
|
||||||
*/
|
*/
|
||||||
public boolean responseSignVerify(ResponseSignVerifyParams params) {
|
public boolean responseSignVerify(ResponseSignVerifyParams params) {
|
||||||
|
|
||||||
log.debug("responseSignVerify: {}", params);
|
|
||||||
log.debug("wechatpaySerial: {}", params.getWechatpaySerial());
|
log.debug("wechatpaySerial: {}", params.getWechatpaySerial());
|
||||||
|
|
||||||
boolean verifyResult= params.getWechatpaySerial().startsWith(PUBLIC_KYE_ID_PREFIX)?
|
boolean verifyResult= params.getWechatpaySerial().startsWith(PUBLIC_KYE_ID_PREFIX)?
|
||||||
responseSignVerifyWithWeChatPublicKeyInfo(params):
|
responseSignVerifyWithWeChatPublicKeyInfo(params):
|
||||||
responseSignVerifyWithX509WechatCertificate(params);
|
responseSignVerifyWithX509WechatCertificate(params);
|
||||||
@@ -197,10 +194,12 @@ public class SignatureProvider {
|
|||||||
return verifyResult;
|
return verifyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
*通过平台证书进行验签
|
||||||
|
*/
|
||||||
private boolean responseSignVerifyWithX509WechatCertificate(ResponseSignVerifyParams params){
|
private boolean responseSignVerifyWithX509WechatCertificate(ResponseSignVerifyParams params){
|
||||||
log.debug("responseSignVerifyWithX509WechatCertificate: {}", params);
|
log.debug("responseSignVerifyWithX509WechatCertificate: {}", params);
|
||||||
String wechatpaySerial = params.getWechatpaySerial();
|
String wechatpaySerial = params.getWechatpaySerial();
|
||||||
|
|
||||||
X509WechatCertificateInfo certificate = CERTIFICATE_SET.stream()
|
X509WechatCertificateInfo certificate = CERTIFICATE_SET.stream()
|
||||||
.filter(cert -> Objects.equals(wechatpaySerial, cert.getWechatPaySerial()))
|
.filter(cert -> Objects.equals(wechatpaySerial, cert.getWechatPaySerial()))
|
||||||
.findAny()
|
.findAny()
|
||||||
@@ -223,13 +222,12 @@ public class SignatureProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
*通过微信支付公钥进行验签
|
||||||
|
*/
|
||||||
private boolean responseSignVerifyWithWeChatPublicKeyInfo(ResponseSignVerifyParams params){
|
private boolean responseSignVerifyWithWeChatPublicKeyInfo(ResponseSignVerifyParams params){
|
||||||
log.debug("responseSignVerifyWithWeChatPublicKeyInfo: {}", params);
|
log.debug("responseSignVerifyWithWeChatPublicKeyInfo: {}", params);
|
||||||
|
|
||||||
String wechatpaySerial = params.getWechatpaySerial();
|
String wechatpaySerial = params.getWechatpaySerial();
|
||||||
|
|
||||||
log.debug("wechatpaySerial: {}", wechatpaySerial);
|
|
||||||
|
|
||||||
if (wechatpaySerial.startsWith(PUBLIC_KYE_ID_PREFIX)){
|
if (wechatpaySerial.startsWith(PUBLIC_KYE_ID_PREFIX)){
|
||||||
WeChatPublicKeyInfo info = PUBLIC_KEY_SET.stream()
|
WeChatPublicKeyInfo info = PUBLIC_KEY_SET.stream()
|
||||||
.filter(key -> Objects.equals(wechatpaySerial, key.getPublicKeyId()))
|
.filter(key -> Objects.equals(wechatpaySerial, key.getPublicKeyId()))
|
||||||
|
|||||||
@@ -14,11 +14,9 @@ public class WeChatPublicKeyInfo {
|
|||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
public WeChatPublicKeyInfo(RSAPublicKey publicKey, String publicKeyId, String tenantId) {
|
public WeChatPublicKeyInfo(RSAPublicKey publicKey, String publicKeyId, String tenantId) {
|
||||||
|
|
||||||
this.publicKeyId = publicKeyId;
|
this.publicKeyId = publicKeyId;
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
this.publicKey = publicKey;
|
this.publicKey = publicKey;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WeChatPublicKeyInfo() {
|
public WeChatPublicKeyInfo() {
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ public class WechatDirectPayApi extends AbstractApi {
|
|||||||
super(wechatPayClient, tenantId);
|
super(wechatPayClient, tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付款码支付API
|
||||||
|
*
|
||||||
|
* @param payParams the pay params
|
||||||
|
* @return the wechat response entity
|
||||||
|
*/
|
||||||
public WechatResponseEntity<ObjectNode> codePay(PayParams payParams) {
|
public WechatResponseEntity<ObjectNode> codePay(PayParams payParams) {
|
||||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||||
this.client().withType(WechatPayV3Type.CODE, payParams)
|
this.client().withType(WechatPayV3Type.CODE, payParams)
|
||||||
|
|||||||
@@ -224,8 +224,6 @@ public class WechatPayClient {
|
|||||||
String tenantId = Objects.requireNonNull(headers.get("Pay-TenantId")).get(0);
|
String tenantId = Objects.requireNonNull(headers.get("Pay-TenantId")).get(0);
|
||||||
String authorization = signatureProvider.requestSign(tenantId, httpMethod.name(), canonicalUrl, body);
|
String authorization = signatureProvider.requestSign(tenantId, httpMethod.name(), canonicalUrl, body);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpHeaders httpHeaders = new HttpHeaders();
|
HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.addAll(headers);
|
httpHeaders.addAll(headers);
|
||||||
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
|||||||
Reference in New Issue
Block a user