mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🎨 【微信支付】优化复用订单通知SignatureHeader
This commit is contained in:
parent
e621bb1828
commit
e4b2f94af5
@ -1,6 +1,6 @@
|
|||||||
package com.github.binarywang.wxpay.service;
|
package com.github.binarywang.wxpay.service;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
|
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharingV3.*;
|
import com.github.binarywang.wxpay.bean.profitsharingV3.*;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ public interface ProfitSharingV3Service {
|
|||||||
* @throws WxPayException the wx pay exception
|
* @throws WxPayException the wx pay exception
|
||||||
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml">微信文档</a>
|
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml">微信文档</a>
|
||||||
*/
|
*/
|
||||||
ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
|
ProfitSharingNotifyResult getProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.binarywang.wxpay.service.impl;
|
package com.github.binarywang.wxpay.service.impl;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
|
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharingV3.*;
|
import com.github.binarywang.wxpay.bean.profitsharingV3.*;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
|
import com.github.binarywang.wxpay.service.ProfitSharingV3Service;
|
||||||
@ -120,7 +120,7 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException {
|
public ProfitSharingNotifyResult getProfitSharingNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
|
||||||
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
|
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
|
||||||
ProfitSharingNotifyData.Resource resource = response.getResource();
|
ProfitSharingNotifyData.Resource resource = response.getResource();
|
||||||
String cipherText = resource.getCipherText();
|
String cipherText = resource.getCipherText();
|
||||||
@ -170,7 +170,7 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
if (verifier == null) {
|
if (verifier == null) {
|
||||||
throw new WxPayException("证书检验对象为空");
|
throw new WxPayException("证书检验对象为空");
|
||||||
}
|
}
|
||||||
return verifier.verify(header.getSerialNo(),
|
return verifier.verify(header.getSerial(),
|
||||||
beforeSign.getBytes(StandardCharsets.UTF_8), header.getSigned());
|
beforeSign.getBytes(StandardCharsets.UTF_8), header.getSignature());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.github.binarywang.wxpay.service.impl;
|
package com.github.binarywang.wxpay.service.impl;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader;
|
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import com.github.binarywang.wxpay.testbase.ApiTestModule;
|
import com.github.binarywang.wxpay.testbase.ApiTestModule;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@ -27,11 +25,11 @@ public class ProfitSharingV3ServiceImplTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testProfitSharingNotifyData() throws WxPayException {
|
public void testProfitSharingNotifyData() throws WxPayException {
|
||||||
SignatureHeader header = new SignatureHeader();
|
SignatureHeader header = new SignatureHeader();
|
||||||
header.setSerialNo("Wechatpay-Serial");
|
header.setSerial("Wechatpay-Serial");
|
||||||
header.setTimeStamp("Wechatpay-Timestamp");
|
header.setTimeStamp("Wechatpay-Timestamp");
|
||||||
header.setNonce("Wechatpay-Nonce");
|
header.setNonce("Wechatpay-Nonce");
|
||||||
header.setSigned("Wechatpay-Signature");
|
header.setSignature("Wechatpay-Signature");
|
||||||
String data = "body";
|
String data = "body";
|
||||||
log.info(this.payService.getProfitSharingV3Service().getProfitSharingNotifyData(data,header).toString());
|
log.info(this.payService.getProfitSharingV3Service().getProfitSharingNotifyResult(data,header).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user