Skip to content

Commit e4b2f94

Browse files
linyaqiangBinary Wang
authored andcommitted
🎨 【微信支付】优化复用订单通知SignatureHeader
1 parent e621bb1 commit e4b2f94

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.binarywang.wxpay.service;
22

3-
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
3+
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
44
import com.github.binarywang.wxpay.bean.profitsharingV3.*;
55
import com.github.binarywang.wxpay.exception.WxPayException;
66

@@ -238,7 +238,7 @@ public interface ProfitSharingV3Service {
238238
* @throws WxPayException the wx pay exception
239239
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml">微信文档</a>
240240
*/
241-
ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
241+
ProfitSharingNotifyResult getProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
242242

243243
/**
244244
* <pre>

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.binarywang.wxpay.service.impl;
22

3-
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
3+
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
44
import com.github.binarywang.wxpay.bean.profitsharingV3.*;
55
import com.github.binarywang.wxpay.exception.WxPayException;
66
import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
@@ -120,7 +120,7 @@ public ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver r
120120
}
121121

122122
@Override
123-
public ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException {
123+
public ProfitSharingNotifyResult getProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
124124
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
125125
ProfitSharingNotifyData.Resource resource = response.getResource();
126126
String cipherText = resource.getCipherText();
@@ -170,7 +170,7 @@ private boolean verifyNotifySign(SignatureHeader header, String data) throws WxP
170170
if (verifier == null) {
171171
throw new WxPayException("证书检验对象为空");
172172
}
173-
return verifier.verify(header.getSerialNo(),
174-
beforeSign.getBytes(StandardCharsets.UTF_8), header.getSigned());
173+
return verifier.verify(header.getSerial(),
174+
beforeSign.getBytes(StandardCharsets.UTF_8), header.getSignature());
175175
}
176176
}

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImplTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.github.binarywang.wxpay.service.impl;
22

3-
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
3+
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
44
import com.github.binarywang.wxpay.exception.WxPayException;
55
import com.github.binarywang.wxpay.service.WxPayService;
66
import com.github.binarywang.wxpay.testbase.ApiTestModule;
77
import com.google.inject.Inject;
88
import lombok.extern.slf4j.Slf4j;
9-
import org.slf4j.Logger;
10-
import org.slf4j.LoggerFactory;
119
import org.testng.annotations.Guice;
1210
import org.testng.annotations.Test;
1311

@@ -27,11 +25,11 @@ public class ProfitSharingV3ServiceImplTest {
2725
@Test
2826
public void testProfitSharingNotifyData() throws WxPayException {
2927
SignatureHeader header = new SignatureHeader();
30-
header.setSerialNo("Wechatpay-Serial");
28+
header.setSerial("Wechatpay-Serial");
3129
header.setTimeStamp("Wechatpay-Timestamp");
3230
header.setNonce("Wechatpay-Nonce");
33-
header.setSigned("Wechatpay-Signature");
31+
header.setSignature("Wechatpay-Signature");
3432
String data = "body";
35-
log.info(this.payService.getProfitSharingV3Service().getProfitSharingNotifyData(data,header).toString());
33+
log.info(this.payService.getProfitSharingV3Service().getProfitSharingNotifyResult(data,header).toString());
3634
}
3735
}

0 commit comments

Comments
 (0)