🐛 【微信支付】修复多商户情况下微信回调签名失败的问题

This commit is contained in:
fangyaoxia
2022-06-14 02:36:25 +00:00
committed by Binary Wang
parent a21a622936
commit 5ac2e690c0

View File

@@ -345,9 +345,10 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
if (result.getSignType() != null) {
// 如果解析的通知对象中signType有值则使用它进行验签
signType = result.getSignType();
} else if (this.getConfig().getSignType() != null) {
} else if (configMap.get(result.getMchId()).getSignType() != null) {
// 如果配置中signType有值则使用它进行验签
signType = this.getConfig().getSignType();
signType = configMap.get(result.getMchId()).getSignType();
this.switchover(result.getMchId());
}
}
@@ -430,6 +431,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
WxPayRefundNotifyResult result;
if (XmlConfig.fastMode) {
result = BaseWxPayResult.fromXML(xmlData, WxPayRefundNotifyResult.class);
this.switchover(result.getMchId());
result.decryptReqInfo(this.getConfig().getMchKey());
} else {
result = WxPayRefundNotifyResult.fromXML(xmlData, this.getConfig().getMchKey());
@@ -465,12 +467,13 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
}
@Override
public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, String signType) throws WxPayException {
public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, @Deprecated String signType) throws WxPayException {
try {
log.debug("扫码支付回调通知请求参数:{}", xmlData);
WxScanPayNotifyResult result = BaseWxPayResult.fromXML(xmlData, WxScanPayNotifyResult.class);
this.switchover(result.getMchId());
log.debug("扫码支付回调通知解析后的对象:{}", result);
result.checkResult(this, signType, false);
result.checkResult(this, this.getConfig().getSignType(), false);
return result;
} catch (WxPayException e) {
throw e;
@@ -481,8 +484,8 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
@Override
public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData) throws WxPayException {
final String signType = this.getConfig().getSignType();
return this.parseScanPayNotifyResult(xmlData, signType);
// final String signType = this.getConfig().getSignType();
return this.parseScanPayNotifyResult(xmlData, null);
}
@Override