| @@ -7,7 +7,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | 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.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.github.binarywang.wxpay.util.SignUtils; | ||||
| import com.thoughtworks.xstream.XStream; | import com.thoughtworks.xstream.XStream; | ||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
| @@ -285,18 +288,10 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult { | |||||
| @XStreamAlias("version") | @XStreamAlias("version") | ||||
| private String version; | private String version; | ||||
| /** | |||||
| * 校验返回结果签名. | |||||
| * | |||||
| * @param wxPayService the wx pay service | |||||
| * @param signType 签名类型 | |||||
| * @param checkSuccess 是否同时检查结果是否成功 | |||||
| * @throws WxPayException the wx pay exception | |||||
| */ | |||||
| @Override | @Override | ||||
| public void checkResult(WxPayService wxPayService, String signType, boolean checkSuccess) throws WxPayException { | 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("伪造的通知!"); | throw new WxPayException("伪造的通知!"); | ||||
| } | } | ||||
| @@ -11,6 +11,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | ||||
| import com.github.binarywang.wxpay.constant.WxPayConstants; | |||||
| import com.github.binarywang.wxpay.exception.WxPayException; | import com.github.binarywang.wxpay.exception.WxPayException; | ||||
| import com.thoughtworks.xstream.XStream; | import com.thoughtworks.xstream.XStream; | ||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | 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 { | public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) throws WxPayException { | ||||
| WxPayRefundNotifyResult result = BaseWxPayResult.fromXML(xmlString, WxPayRefundNotifyResult.class); | WxPayRefundNotifyResult result = BaseWxPayResult.fromXML(xmlString, WxPayRefundNotifyResult.class); | ||||
| if ("FAIL".equals(result.getReturnCode())) { | |||||
| if (WxPayConstants.ResultCode.FAIL.equals(result.getReturnCode())) { | |||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -22,6 +22,7 @@ import org.w3c.dom.Document; | |||||
| import org.w3c.dom.NodeList; | import org.w3c.dom.NodeList; | ||||
| import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
| import com.github.binarywang.wxpay.constant.WxPayConstants; | |||||
| 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.util.SignUtils; | import com.github.binarywang.wxpay.util.SignUtils; | ||||
| @@ -254,7 +255,7 @@ public abstract class BaseWxPayResult implements Serializable { | |||||
| //校验结果是否成功 | //校验结果是否成功 | ||||
| if (checkSuccess) { | if (checkSuccess) { | ||||
| List<String> successStrings = Lists.newArrayList("SUCCESS", ""); | |||||
| List<String> successStrings = Lists.newArrayList(WxPayConstants.ResultCode.SUCCESS, ""); | |||||
| if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase()) | if (!successStrings.contains(StringUtils.trimToEmpty(getReturnCode()).toUpperCase()) | ||||
| || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) { | || !successStrings.contains(StringUtils.trimToEmpty(getResultCode()).toUpperCase())) { | ||||
| StringBuilder errorMsg = new StringBuilder(); | StringBuilder errorMsg = new StringBuilder(); | ||||