From da0ce15da6e382a6d43eea08af981f8ca9b5d267 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 26 May 2020 18:00:54 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#1585=20=E5=BE=AE=E4=BF=A1=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E7=BB=93=E6=9E=9C=E5=BC=82=E6=AD=A5=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=9A=84=E8=A7=A3=E6=9E=90=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=87=AA=E8=A1=8C=E6=8C=87=E5=AE=9AsignType?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E8=BD=BD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/binarywang/wxpay/service/WxPayService.java | 11 +++++++++++ .../wxpay/service/impl/BaseWxPayServiceImpl.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java index 74958c1f9..2c5ad12f7 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxPayService.java @@ -303,6 +303,17 @@ public interface WxPayService { */ WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException; + /** + * 解析支付结果通知. + * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7 + * + * @param xmlData the xml data + * @param signType 签名类型 + * @return the wx pay order notify result + * @throws WxPayException the wx pay exception + */ + WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException; + /** * 解析退款结果通知 * 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9 diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java index 4d61522f5..81082a3aa 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/BaseWxPayServiceImpl.java @@ -154,11 +154,20 @@ public abstract class BaseWxPayServiceImpl implements WxPayService { @Override public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException { + return this.parseOrderNotifyResult(xmlData, null); + } + + @Override + public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException { try { log.debug("微信支付异步通知请求参数:{}", xmlData); WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlData); + if (result.getSignType() != null) { + // 如果解析的通知对象中signType有值,则使用它进行验签 + signType = result.getSignType(); + } log.debug("微信支付异步通知请求解析后的对象:{}", result); - result.checkResult(this, result.getSignType(), false); + result.checkResult(this, signType, false); return result; } catch (WxPayException e) { throw e;