Skip to content

Commit 5ac2e69

Browse files
foquanlinbinarywang
authored andcommitted
🐛 【微信支付】修复多商户情况下微信回调签名失败的问题
1 parent a21a622 commit 5ac2e69

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String sign
345345
if (result.getSignType() != null) {
346346
// 如果解析的通知对象中signType有值,则使用它进行验签
347347
signType = result.getSignType();
348-
} else if (this.getConfig().getSignType() != null) {
348+
} else if (configMap.get(result.getMchId()).getSignType() != null) {
349349
// 如果配置中signType有值,则使用它进行验签
350-
signType = this.getConfig().getSignType();
350+
signType = configMap.get(result.getMchId()).getSignType();
351+
this.switchover(result.getMchId());
351352
}
352353
}
353354

@@ -430,6 +431,7 @@ public WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws Wx
430431
WxPayRefundNotifyResult result;
431432
if (XmlConfig.fastMode) {
432433
result = BaseWxPayResult.fromXML(xmlData, WxPayRefundNotifyResult.class);
434+
this.switchover(result.getMchId());
433435
result.decryptReqInfo(this.getConfig().getMchKey());
434436
} else {
435437
result = WxPayRefundNotifyResult.fromXML(xmlData, this.getConfig().getMchKey());
@@ -465,12 +467,13 @@ public WxPayRefundNotifyV3Result parseRefundNotifyV3Result(String notifyData, Si
465467
}
466468

467469
@Override
468-
public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, String signType) throws WxPayException {
470+
public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, @Deprecated String signType) throws WxPayException {
469471
try {
470472
log.debug("扫码支付回调通知请求参数:{}", xmlData);
471473
WxScanPayNotifyResult result = BaseWxPayResult.fromXML(xmlData, WxScanPayNotifyResult.class);
474+
this.switchover(result.getMchId());
472475
log.debug("扫码支付回调通知解析后的对象:{}", result);
473-
result.checkResult(this, signType, false);
476+
result.checkResult(this, this.getConfig().getSignType(), false);
474477
return result;
475478
} catch (WxPayException e) {
476479
throw e;
@@ -481,8 +484,8 @@ public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, String sig
481484

482485
@Override
483486
public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData) throws WxPayException {
484-
final String signType = this.getConfig().getSignType();
485-
return this.parseScanPayNotifyResult(xmlData, signType);
487+
// final String signType = this.getConfig().getSignType();
488+
return this.parseScanPayNotifyResult(xmlData, null);
486489
}
487490

488491
@Override

0 commit comments

Comments
 (0)