@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.coupon; | package com.github.binarywang.wxpay.bean.coupon; | ||||
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest; | |||||
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.*; | import lombok.*; | ||||
import me.chanjar.weixin.common.annotation.Required; | import me.chanjar.weixin.common.annotation.Required; | ||||
@@ -19,7 +19,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCouponInfoQueryRequest extends WxPayBaseRequest { | |||||
public class WxPayCouponInfoQueryRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:代金券id | * 字段名:代金券id | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.coupon; | package com.github.binarywang.wxpay.bean.coupon; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.Data; | import lombok.Data; | ||||
import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
@@ -18,7 +18,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCouponInfoQueryResult extends WxPayBaseResult { | |||||
public class WxPayCouponInfoQueryResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:设备号. | * 字段名:设备号. | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.coupon; | package com.github.binarywang.wxpay.bean.coupon; | ||||
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest; | |||||
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.*; | import lombok.*; | ||||
import me.chanjar.weixin.common.annotation.Required; | import me.chanjar.weixin.common.annotation.Required; | ||||
@@ -20,7 +20,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCouponSendRequest extends WxPayBaseRequest { | |||||
public class WxPayCouponSendRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:代金券批次id | * 字段名:代金券批次id | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.coupon; | package com.github.binarywang.wxpay.bean.coupon; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.Data; | import lombok.Data; | ||||
import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
@@ -18,7 +18,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCouponSendResult extends WxPayBaseResult { | |||||
public class WxPayCouponSendResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:设备号 | * 字段名:设备号 | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.coupon; | package com.github.binarywang.wxpay.bean.coupon; | ||||
import com.github.binarywang.wxpay.bean.request.WxPayBaseRequest; | |||||
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.*; | import lombok.*; | ||||
import me.chanjar.weixin.common.annotation.Required; | import me.chanjar.weixin.common.annotation.Required; | ||||
@@ -20,7 +20,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCouponStockQueryRequest extends WxPayBaseRequest { | |||||
public class WxPayCouponStockQueryRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:代金券批次id | * 字段名:代金券批次id | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.coupon; | package com.github.binarywang.wxpay.bean.coupon; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Data; | import lombok.Data; | ||||
@@ -20,7 +20,7 @@ import lombok.NoArgsConstructor; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCouponStockQueryResult extends WxPayBaseResult { | |||||
public class WxPayCouponStockQueryResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:设备号 | * 字段名:设备号 | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.notify; | package com.github.binarywang.wxpay.bean.notify; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter; | import com.github.binarywang.wxpay.converter.WxPayOrderNotifyResultConverter; | ||||
import com.thoughtworks.xstream.XStream; | import com.thoughtworks.xstream.XStream; | ||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
@@ -25,7 +25,7 @@ import java.util.Map; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializable { | |||||
public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializable { | |||||
private static final long serialVersionUID = 5389718115223345496L; | private static final long serialVersionUID = 5389718115223345496L; | ||||
/** | /** | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.notify; | package com.github.binarywang.wxpay.bean.notify; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
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; | ||||
@@ -31,7 +31,7 @@ import java.security.MessageDigest; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRefundNotifyResult extends WxPayBaseResult implements Serializable { | |||||
public class WxPayRefundNotifyResult extends BaseWxPayResult implements Serializable { | |||||
private static final long serialVersionUID = 4651725860079259186L; | private static final long serialVersionUID = 4651725860079259186L; | ||||
/** | /** | ||||
@@ -41,7 +41,7 @@ public class WxPayRefundNotifyResult extends WxPayBaseResult implements Serializ | |||||
* @param mchKey 商户密钥 | * @param mchKey 商户密钥 | ||||
*/ | */ | ||||
public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) throws WxPayException { | public static WxPayRefundNotifyResult fromXML(String xmlString, String mchKey) throws WxPayException { | ||||
WxPayRefundNotifyResult result = WxPayBaseResult.fromXML(xmlString, WxPayRefundNotifyResult.class); | |||||
WxPayRefundNotifyResult result = BaseWxPayResult.fromXML(xmlString, WxPayRefundNotifyResult.class); | |||||
String reqInfoString = result.getReqInfoString(); | String reqInfoString = result.getReqInfoString(); | ||||
try { | try { | ||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); | Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.bean.notify; | package com.github.binarywang.wxpay.bean.notify; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
import lombok.Data; | import lombok.Data; | ||||
import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
@@ -11,7 +11,7 @@ import java.io.Serializable; | |||||
@Data | @Data | ||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
public class WxScanPayNotifyResult extends WxPayBaseResult implements Serializable { | |||||
public class WxScanPayNotifyResult extends BaseWxPayResult implements Serializable { | |||||
private static final long serialVersionUID = 3381324564266118986L; | private static final long serialVersionUID = 3381324564266118986L; | ||||
/** | /** | ||||
@@ -25,7 +25,7 @@ import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_S | |||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@Data | @Data | ||||
public abstract class WxPayBaseRequest { | |||||
public abstract class BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:公众账号ID | * 字段名:公众账号ID |
@@ -26,7 +26,7 @@ import me.chanjar.weixin.common.util.ToStringUtils; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayQueryRequest extends WxPayBaseRequest { | |||||
public class WxEntPayQueryRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 商户订单号 | * 商户订单号 | ||||
@@ -20,7 +20,7 @@ import me.chanjar.weixin.common.util.ToStringUtils; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayRequest extends WxPayBaseRequest { | |||||
public class WxEntPayRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:公众账号appid | * 字段名:公众账号appid | ||||
@@ -17,7 +17,7 @@ import lombok.*; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayAuthcode2OpenidRequest extends WxPayBaseRequest { | |||||
public class WxPayAuthcode2OpenidRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -11,7 +11,7 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayDefaultRequest extends WxPayBaseRequest { | |||||
public class WxPayDefaultRequest extends BaseWxPayRequest { | |||||
@Override | @Override | ||||
protected void checkConstraints() { | protected void checkConstraints() { | ||||
//do nothing | //do nothing | ||||
@@ -24,7 +24,7 @@ import java.util.Arrays; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayDownloadBillRequest extends WxPayBaseRequest { | |||||
public class WxPayDownloadBillRequest extends BaseWxPayRequest { | |||||
private static final String[] BILL_TYPES = new String[]{BillType.ALL, BillType.SUCCESS, BillType.REFUND, BillType.RECHARGE_REFUND}; | private static final String[] BILL_TYPES = new String[]{BillType.ALL, BillType.SUCCESS, BillType.REFUND, BillType.RECHARGE_REFUND}; | ||||
private static final String TAR_TYPE_GZIP = "GZIP"; | private static final String TAR_TYPE_GZIP = "GZIP"; | ||||
@@ -18,7 +18,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayMicropayRequest extends WxPayBaseRequest { | |||||
public class WxPayMicropayRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 商品描述 | * 商品描述 | ||||
@@ -17,7 +17,7 @@ import lombok.*; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderCloseRequest extends WxPayBaseRequest { | |||||
public class WxPayOrderCloseRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -26,7 +26,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderQueryRequest extends WxPayBaseRequest { | |||||
public class WxPayOrderQueryRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -19,7 +19,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderReverseRequest extends WxPayBaseRequest { | |||||
public class WxPayOrderReverseRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -19,7 +19,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayQueryCommentRequest extends WxPayBaseRequest { | |||||
public class WxPayQueryCommentRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:开始时间 | * 字段名:开始时间 | ||||
@@ -23,7 +23,7 @@ import lombok.*; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRedpackQueryRequest extends WxPayBaseRequest { | |||||
public class WxPayRedpackQueryRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* 商户订单号 | * 商户订单号 | ||||
* mch_billno | * mch_billno | ||||
@@ -18,7 +18,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRefundQueryRequest extends WxPayBaseRequest { | |||||
public class WxPayRefundQueryRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 设备号 | * 设备号 | ||||
@@ -25,7 +25,7 @@ import java.util.Arrays; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRefundRequest extends WxPayBaseRequest { | |||||
public class WxPayRefundRequest extends BaseWxPayRequest { | |||||
private static final String[] REFUND_ACCOUNT = new String[]{ | private static final String[] REFUND_ACCOUNT = new String[]{ | ||||
RefundAccountSource.RECHARGE_FUNDS, RefundAccountSource.UNSETTLED_FUNDS}; | RefundAccountSource.RECHARGE_FUNDS, RefundAccountSource.UNSETTLED_FUNDS}; | ||||
@@ -24,7 +24,7 @@ import me.chanjar.weixin.common.annotation.Required; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayReportRequest extends WxPayBaseRequest { | |||||
public class WxPayReportRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 设备号 | * 设备号 | ||||
@@ -15,7 +15,7 @@ import lombok.*; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPaySendRedpackRequest extends WxPayBaseRequest { | |||||
public class WxPaySendRedpackRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* mch_billno | * mch_billno | ||||
* 商户订单号(每个订单号必须唯一) 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。 | * 商户订单号(每个订单号必须唯一) 组成:mch_id+yyyymmdd+10位一天内不能重复的数字。 接口根据商户订单号支持重入,如出现超时可再调用。 | ||||
@@ -17,7 +17,7 @@ import lombok.*; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayShorturlRequest extends WxPayBaseRequest { | |||||
public class WxPayShorturlRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* URL链接 | * URL链接 | ||||
@@ -23,7 +23,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { | |||||
public class WxPayUnifiedOrderRequest extends BaseWxPayRequest { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:设备号 | * 字段名:设备号 | ||||
@@ -1,7 +1,7 @@ | |||||
package com.github.binarywang.wxpay.bean.result; | package com.github.binarywang.wxpay.bean.result; | ||||
import com.github.binarywang.wxpay.exception.WxPayException; | import com.github.binarywang.wxpay.exception.WxPayException; | ||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceAbstractImpl; | |||||
import com.github.binarywang.wxpay.service.impl.BaseWxPayServiceImpl; | |||||
import com.github.binarywang.wxpay.util.SignUtils; | import com.github.binarywang.wxpay.util.SignUtils; | ||||
import com.google.common.base.Joiner; | import com.google.common.base.Joiner; | ||||
import com.google.common.collect.Lists; | import com.google.common.collect.Lists; | ||||
@@ -38,7 +38,7 @@ import java.util.Map; | |||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
@Data | @Data | ||||
public abstract class WxPayBaseResult { | |||||
public abstract class BaseWxPayResult { | |||||
/** | /** | ||||
* 返回状态码 | * 返回状态码 | ||||
*/ | */ | ||||
@@ -121,7 +121,7 @@ public abstract class WxPayBaseResult { | |||||
/** | /** | ||||
* 从xml字符串创建bean对象 | * 从xml字符串创建bean对象 | ||||
*/ | */ | ||||
public static <T extends WxPayBaseResult> T fromXML(String xmlString, Class<T> clz) { | |||||
public static <T extends BaseWxPayResult> T fromXML(String xmlString, Class<T> clz) { | |||||
XStream xstream = XStreamInitializer.getInstance(); | XStream xstream = XStreamInitializer.getInstance(); | ||||
xstream.processAnnotations(clz); | xstream.processAnnotations(clz); | ||||
T result = (T) xstream.fromXML(xmlString); | T result = (T) xstream.fromXML(xmlString); | ||||
@@ -219,7 +219,7 @@ public abstract class WxPayBaseResult { | |||||
* @param signType 签名类型 | * @param signType 签名类型 | ||||
* @param checkSuccess 是否同时检查结果是否成功 | * @param checkSuccess 是否同时检查结果是否成功 | ||||
*/ | */ | ||||
public void checkResult(WxPayServiceAbstractImpl wxPayService, String signType, boolean checkSuccess) throws WxPayException { | |||||
public void checkResult(BaseWxPayServiceImpl wxPayService, String signType, boolean checkSuccess) throws WxPayException { | |||||
//校验返回结果签名 | //校验返回结果签名 | ||||
Map<String, String> map = toMap(); | Map<String, String> map = toMap(); | ||||
if (getSign() != null && !SignUtils.checkSign(map, signType, wxPayService.getConfig().getMchKey())) { | if (getSign() != null && !SignUtils.checkSign(map, signType, wxPayService.getConfig().getMchKey())) { |
@@ -15,7 +15,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayQueryResult extends WxPayBaseResult { | |||||
public class WxEntPayQueryResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* 商户订单号 | * 商户订单号 | ||||
@@ -15,7 +15,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxEntPayResult extends WxPayBaseResult { | |||||
public class WxEntPayResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* 商户appid | * 商户appid | ||||
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayAuthcode2OpenidResult extends WxPayBaseResult { | |||||
public class WxPayAuthcode2OpenidResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 用户标识 | * 用户标识 | ||||
@@ -12,5 +12,5 @@ import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
*/ | */ | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayCommonResult extends WxPayBaseResult { | |||||
public class WxPayCommonResult extends BaseWxPayResult { | |||||
} | } |
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayMicropayResult extends WxPayBaseResult { | |||||
public class WxPayMicropayResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 用户标识 | * 用户标识 | ||||
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderCloseResult extends WxPayBaseResult { | |||||
public class WxPayOrderCloseResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* 业务结果描述 | * 业务结果描述 | ||||
@@ -25,7 +25,7 @@ import java.util.List; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderQueryResult extends WxPayBaseResult { | |||||
public class WxPayOrderQueryResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre>设备号 | * <pre>设备号 | ||||
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayOrderReverseResult extends WxPayBaseResult { | |||||
public class WxPayOrderReverseResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -23,7 +23,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRedpackQueryResult extends WxPayBaseResult { | |||||
public class WxPayRedpackQueryResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -18,7 +18,7 @@ import java.util.List; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRefundQueryResult extends WxPayBaseResult { | |||||
public class WxPayRefundQueryResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* 字段名:设备号. | * 字段名:设备号. | ||||
@@ -19,7 +19,7 @@ import java.io.Serializable; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayRefundResult extends WxPayBaseResult implements Serializable { | |||||
public class WxPayRefundResult extends BaseWxPayResult implements Serializable { | |||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
@XStreamAlias("device_info") | @XStreamAlias("device_info") | ||||
@@ -16,7 +16,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPaySandboxSignKeyResult extends WxPayBaseResult { | |||||
public class WxPaySandboxSignKeyResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -17,7 +17,7 @@ import java.io.Serializable; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPaySendRedpackResult extends WxPayBaseResult implements Serializable { | |||||
public class WxPaySendRedpackResult extends BaseWxPayResult implements Serializable { | |||||
private static final long serialVersionUID = -4837415036337132073L; | private static final long serialVersionUID = -4837415036337132073L; | ||||
@XStreamAlias("mch_billno") | @XStreamAlias("mch_billno") | ||||
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayShorturlResult extends WxPayBaseResult { | |||||
public class WxPayShorturlResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
* URL链接 | * URL链接 | ||||
@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; | |||||
@EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
@NoArgsConstructor | @NoArgsConstructor | ||||
@XStreamAlias("xml") | @XStreamAlias("xml") | ||||
public class WxPayUnifiedOrderResult extends WxPayBaseResult { | |||||
public class WxPayUnifiedOrderResult extends BaseWxPayResult { | |||||
/** | /** | ||||
* 微信生成的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时 | * 微信生成的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时 | ||||
@@ -57,11 +57,11 @@ public class WxPayOrderNotifyResultConverter extends AbstractReflectionConverter | |||||
@Override | @Override | ||||
protected void marshallField(MarshallingContext context, Object newObj, Field field) { | protected void marshallField(MarshallingContext context, Object newObj, Field field) { | ||||
if (field.getName().equals("couponList")) { | |||||
if ("couponList".equals(field.getName())) { | |||||
return; | return; | ||||
} else { | |||||
super.marshallField(context, newObj, field); | |||||
} | } | ||||
super.marshallField(context, newObj, field); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -1,6 +1,6 @@ | |||||
package com.github.binarywang.wxpay.exception; | package com.github.binarywang.wxpay.exception; | ||||
import com.github.binarywang.wxpay.bean.result.WxPayBaseResult; | |||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult; | |||||
import com.google.common.base.Joiner; | import com.google.common.base.Joiner; | ||||
/** | /** | ||||
@@ -60,7 +60,7 @@ public class WxPayException extends Exception { | |||||
xmlString = builder.xmlString; | xmlString = builder.xmlString; | ||||
} | } | ||||
public static WxPayException from(WxPayBaseResult payBaseResult) { | |||||
public static WxPayException from(BaseWxPayResult payBaseResult) { | |||||
return WxPayException.newBuilder() | return WxPayException.newBuilder() | ||||
.xmlString(payBaseResult.getXmlString()) | .xmlString(payBaseResult.getXmlString()) | ||||
.returnMsg(payBaseResult.getReturnMsg()) | .returnMsg(payBaseResult.getReturnMsg()) | ||||
@@ -11,7 +11,6 @@ import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; | |||||
import com.github.binarywang.wxpay.bean.request.*; | import com.github.binarywang.wxpay.bean.request.*; | ||||
import com.github.binarywang.wxpay.bean.result.*; | import com.github.binarywang.wxpay.bean.result.*; | ||||
import com.github.binarywang.wxpay.config.WxPayConfig; | import com.github.binarywang.wxpay.config.WxPayConfig; | ||||
import com.github.binarywang.wxpay.constant.WxPayConstants; | |||||
import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; | import com.github.binarywang.wxpay.constant.WxPayConstants.BillType; | ||||
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; | import com.github.binarywang.wxpay.constant.WxPayConstants.SignType; | ||||
import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; | import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType; | ||||
@@ -21,26 +20,10 @@ import com.github.binarywang.wxpay.util.SignUtils; | |||||
import com.google.common.base.Joiner; | import com.google.common.base.Joiner; | ||||
import com.google.common.collect.Maps; | import com.google.common.collect.Maps; | ||||
import jodd.io.ZipUtil; | import jodd.io.ZipUtil; | ||||
import jodd.util.Base64; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.apache.http.auth.AuthScope; | |||||
import org.apache.http.auth.UsernamePasswordCredentials; | |||||
import org.apache.http.client.CredentialsProvider; | |||||
import org.apache.http.client.config.RequestConfig; | |||||
import org.apache.http.client.methods.CloseableHttpResponse; | |||||
import org.apache.http.client.methods.HttpPost; | |||||
import org.apache.http.conn.ssl.DefaultHostnameVerifier; | |||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; | |||||
import org.apache.http.entity.StringEntity; | |||||
import org.apache.http.impl.client.BasicCredentialsProvider; | |||||
import org.apache.http.impl.client.CloseableHttpClient; | |||||
import org.apache.http.impl.client.HttpClientBuilder; | |||||
import org.apache.http.impl.client.HttpClients; | |||||
import org.apache.http.util.EntityUtils; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
import javax.net.ssl.SSLContext; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
@@ -61,7 +44,7 @@ import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; | |||||
* | * | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
public abstract class BaseWxPayServiceImpl implements WxPayService { | |||||
private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; | private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com"; | ||||
protected final Logger log = LoggerFactory.getLogger(this.getClass()); | protected final Logger log = LoggerFactory.getLogger(this.getClass()); | ||||
protected static ThreadLocal<WxPayApiData> wxApiData = new ThreadLocal<>(); | protected static ThreadLocal<WxPayApiData> wxApiData = new ThreadLocal<>(); | ||||
@@ -112,7 +95,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/secapi/pay/refund"; | String url = this.getPayBaseUrl() + "/secapi/pay/refund"; | ||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
WxPayRefundResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundResult.class); | |||||
WxPayRefundResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -130,7 +113,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/pay/refundquery"; | String url = this.getPayBaseUrl() + "/pay/refundquery"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayRefundQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRefundQueryResult.class); | |||||
WxPayRefundQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundQueryResult.class); | |||||
result.composeRefundRecords(); | result.composeRefundRecords(); | ||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
@@ -184,7 +167,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
//无需校验,因为没有返回签名信息 | //无需校验,因为没有返回签名信息 | ||||
return WxPayBaseResult.fromXML(responseContent, WxPaySendRedpackResult.class); | |||||
return BaseWxPayResult.fromXML(responseContent, WxPaySendRedpackResult.class); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -196,7 +179,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo"; | String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gethbinfo"; | ||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
WxPayRedpackQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayRedpackQueryResult.class); | |||||
WxPayRedpackQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayRedpackQueryResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -214,7 +197,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
throw new WxPayException("无响应结果"); | throw new WxPayException("无响应结果"); | ||||
} | } | ||||
WxPayOrderQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderQueryResult.class); | |||||
WxPayOrderQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayOrderQueryResult.class); | |||||
result.composeCoupons(); | result.composeCoupons(); | ||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
@@ -232,7 +215,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/pay/closeorder"; | String url = this.getPayBaseUrl() + "/pay/closeorder"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayOrderCloseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderCloseResult.class); | |||||
WxPayOrderCloseResult result = BaseWxPayResult.fromXML(responseContent, WxPayOrderCloseResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
@@ -314,7 +297,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/pay/unifiedorder"; | String url = this.getPayBaseUrl() + "/pay/unifiedorder"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayUnifiedOrderResult result = WxPayBaseResult.fromXML(responseContent, WxPayUnifiedOrderResult.class); | |||||
WxPayUnifiedOrderResult result = BaseWxPayResult.fromXML(responseContent, WxPayUnifiedOrderResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -374,7 +357,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers"; | String url = this.getPayBaseUrl() + "/mmpaymkttransfers/promotion/transfers"; | ||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
WxEntPayResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayResult.class); | |||||
WxEntPayResult result = BaseWxPayResult.fromXML(responseContent, WxEntPayResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -387,7 +370,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo"; | String url = this.getPayBaseUrl() + "/mmpaymkttransfers/gettransferinfo"; | ||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
WxEntPayQueryResult result = WxPayBaseResult.fromXML(responseContent, WxEntPayQueryResult.class); | |||||
WxEntPayQueryResult result = BaseWxPayResult.fromXML(responseContent, WxEntPayQueryResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -440,7 +423,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/payitil/report"; | String url = this.getPayBaseUrl() + "/payitil/report"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayCommonResult result = WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class); | |||||
WxPayCommonResult result = BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
} | } | ||||
@@ -466,7 +449,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
} else { | } else { | ||||
responseContent = this.post(url, request.toXML(), false); | responseContent = this.post(url, request.toXML(), false); | ||||
if (responseContent.startsWith("<")) { | if (responseContent.startsWith("<")) { | ||||
throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class)); | |||||
throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class)); | |||||
} | } | ||||
} | } | ||||
@@ -492,7 +475,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
return Joiner.on("\n").join(allLines); | return Joiner.on("\n").join(allLines); | ||||
} catch (ZipException e) { | } catch (ZipException e) { | ||||
if (e.getMessage().contains("Not in GZIP format")) { | if (e.getMessage().contains("Not in GZIP format")) { | ||||
throw WxPayException.from(WxPayBaseResult.fromXML(new String(responseBytes, StandardCharsets.UTF_8), | |||||
throw WxPayException.from(BaseWxPayResult.fromXML(new String(responseBytes, StandardCharsets.UTF_8), | |||||
WxPayCommonResult.class)); | WxPayCommonResult.class)); | ||||
} else { | } else { | ||||
this.log.error("解压zip文件出错", e); | this.log.error("解压zip文件出错", e); | ||||
@@ -584,7 +567,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/pay/micropay"; | String url = this.getPayBaseUrl() + "/pay/micropay"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayMicropayResult result = WxPayBaseResult.fromXML(responseContent, WxPayMicropayResult.class); | |||||
WxPayMicropayResult result = BaseWxPayResult.fromXML(responseContent, WxPayMicropayResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -595,7 +578,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/secapi/pay/reverse"; | String url = this.getPayBaseUrl() + "/secapi/pay/reverse"; | ||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
WxPayOrderReverseResult result = WxPayBaseResult.fromXML(responseContent, WxPayOrderReverseResult.class); | |||||
WxPayOrderReverseResult result = BaseWxPayResult.fromXML(responseContent, WxPayOrderReverseResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -606,7 +589,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/tools/shorturl"; | String url = this.getPayBaseUrl() + "/tools/shorturl"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayShorturlResult result = WxPayBaseResult.fromXML(responseContent, WxPayShorturlResult.class); | |||||
WxPayShorturlResult result = BaseWxPayResult.fromXML(responseContent, WxPayShorturlResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result.getShortUrl(); | return result.getShortUrl(); | ||||
} | } | ||||
@@ -622,7 +605,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/tools/authcodetoopenid"; | String url = this.getPayBaseUrl() + "/tools/authcodetoopenid"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayAuthcode2OpenidResult result = WxPayBaseResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class); | |||||
WxPayAuthcode2OpenidResult result = BaseWxPayResult.fromXML(responseContent, WxPayAuthcode2OpenidResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result.getOpenid(); | return result.getOpenid(); | ||||
} | } | ||||
@@ -639,7 +622,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; | String url = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPaySandboxSignKeyResult result = WxPayBaseResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class); | |||||
WxPaySandboxSignKeyResult result = BaseWxPayResult.fromXML(responseContent, WxPaySandboxSignKeyResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result.getSandboxSignKey(); | return result.getSandboxSignKey(); | ||||
} | } | ||||
@@ -650,7 +633,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/send_coupon"; | String url = this.getPayBaseUrl() + "/mmpaymkttransfers/send_coupon"; | ||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
WxPayCouponSendResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponSendResult.class); | |||||
WxPayCouponSendResult result = BaseWxPayResult.fromXML(responseContent, WxPayCouponSendResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -661,7 +644,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock"; | String url = this.getPayBaseUrl() + "/mmpaymkttransfers/query_coupon_stock"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayCouponStockQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponStockQueryResult.class); | |||||
WxPayCouponStockQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayCouponStockQueryResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -672,7 +655,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo"; | String url = this.getPayBaseUrl() + "/mmpaymkttransfers/querycouponsinfo"; | ||||
String responseContent = this.post(url, request.toXML(), false); | String responseContent = this.post(url, request.toXML(), false); | ||||
WxPayCouponInfoQueryResult result = WxPayBaseResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class); | |||||
WxPayCouponInfoQueryResult result = BaseWxPayResult.fromXML(responseContent, WxPayCouponInfoQueryResult.class); | |||||
result.checkResult(this, request.getSignType(), true); | result.checkResult(this, request.getSignType(), true); | ||||
return result; | return result; | ||||
} | } | ||||
@@ -703,7 +686,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
String responseContent = this.post(url, request.toXML(), true); | String responseContent = this.post(url, request.toXML(), true); | ||||
if (responseContent.startsWith("<")) { | if (responseContent.startsWith("<")) { | ||||
throw WxPayException.from(WxPayBaseResult.fromXML(responseContent, WxPayCommonResult.class)); | |||||
throw WxPayException.from(BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class)); | |||||
} | } | ||||
return responseContent; | return responseContent; |
@@ -31,7 +31,7 @@ import java.nio.charset.StandardCharsets; | |||||
* | * | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
public class WxPayServiceApacheHttpImpl extends WxPayServiceAbstractImpl { | |||||
public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { | |||||
@Override | @Override | ||||
protected byte[] postForBytes(String url, String requestStr, boolean useKey) throws WxPayException { | protected byte[] postForBytes(String url, String requestStr, boolean useKey) throws WxPayException { | ||||
@@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; | |||||
* | * | ||||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
*/ | */ | ||||
public class WxPayServiceJoddHttpImpl extends WxPayServiceAbstractImpl { | |||||
public class WxPayServiceJoddHttpImpl extends BaseWxPayServiceImpl { | |||||
@Override | @Override | ||||
protected byte[] postForBytes(String url, String requestStr, boolean useKey) throws WxPayException { | protected byte[] postForBytes(String url, String requestStr, boolean useKey) throws WxPayException { | ||||
@@ -11,7 +11,7 @@ import java.util.Map; | |||||
* @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a> | ||||
* </pre> | * </pre> | ||||
*/ | */ | ||||
public class WxPayBaseResultTest { | |||||
public class BaseWxPayResultTest { | |||||
@Test | @Test | ||||
public void testGetXmlValue() throws Exception { | public void testGetXmlValue() throws Exception { |
@@ -38,7 +38,7 @@ import static org.testng.Assert.*; | |||||
*/ | */ | ||||
@Test | @Test | ||||
@Guice(modules = ApiTestModule.class) | @Guice(modules = ApiTestModule.class) | ||||
public class WxPayServiceAbstractImplTest { | |||||
public class BaseWxPayServiceImplTest { | |||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
@Inject | @Inject |