From b4833d10194d6ed28fb1a1839bc55d82c14264db Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 1 Nov 2018 15:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=BD=E9=87=8F=E4=BD=BF=E7=94=A8=E5=B8=B8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wxpay/bean/notify/WxPayOrderNotifyResult.java | 13 ++++--------- .../wxpay/bean/notify/WxPayRefundNotifyResult.java | 3 ++- .../wxpay/bean/result/BaseWxPayResult.java | 3 ++- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java index 895ffb78..f96871fa 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayOrderNotifyResult.java @@ -7,7 +7,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; +import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.util.SignUtils; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -285,18 +288,10 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult { @XStreamAlias("version") private String version; - /** - * 校验返回结果签名. - * - * @param wxPayService the wx pay service - * @param signType 签名类型 - * @param checkSuccess 是否同时检查结果是否成功 - * @throws WxPayException the wx pay exception - */ @Override public void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess) throws WxPayException { //防止伪造成功通知 - if ("SUCCESS".equals(getReturnCode()) && getSign() == null) { + if (WxPayConstants.ResultCode.SUCCESS.equals(getReturnCode()) && getSign() == null) { throw new WxPayException("伪造的通知!"); } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java index 5c3d0d14..3199793b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayRefundNotifyResult.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; +import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.annotations.XStreamAlias; @@ -46,7 +47,7 @@ public class WxPayRefundNotifyResult extends BaseWxPayResult implements Serializ */ public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) throws WxPayException { WxPayRefundNotifyResult result = BaseWxPayResult.fromXML(xmlString, WxPayRefundNotifyResult.class); - if ("FAIL".equals(result.getReturnCode())) { + if (WxPayConstants.ResultCode.FAIL.equals(result.getReturnCode())) { return result; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java index 47015df9..f3af4415 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/BaseWxPayResult.java @@ -22,6 +22,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.util.SignUtils; @@ -254,7 +255,7 @@ public abstract class BaseWxPayResult implements Serializable { //校验结果是否成功 if (checkSuccess) { - List successStrings = Lists.newArrayList("SUCCESS", ""); + List successStrings = Lists.newArrayList(WxPayConstants.ResultCode.SUCCESS, ""); if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase()) || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) { StringBuilder errorMsg = new StringBuilder();