| @@ -5,7 +5,7 @@ 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.service.WxPayService; | import com.github.binarywang.wxpay.service.WxPayService; | ||||
| import com.github.binarywang.wxpay.testbase.ApiTestModule; | import com.github.binarywang.wxpay.testbase.ApiTestModule; | ||||
| import com.github.binarywang.wxpay.testbase.TestPayConfig; | |||||
| import com.github.binarywang.wxpay.testbase.XmlWxPayConfig; | |||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||
| import me.chanjar.weixin.common.exception.WxErrorException; | import me.chanjar.weixin.common.exception.WxErrorException; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -105,7 +105,7 @@ public class WxMpPayServiceImplTest { | |||||
| request.setActName("abc"); | request.setActName("abc"); | ||||
| request.setClientIp("aaa"); | request.setClientIp("aaa"); | ||||
| request.setMchBillNo("aaaa"); | request.setMchBillNo("aaaa"); | ||||
| request.setReOpenid(((TestPayConfig) this.wxService.getConfig()).getOpenid()); | |||||
| request.setReOpenid(((XmlWxPayConfig) this.wxService.getConfig()).getOpenid()); | |||||
| WxPaySendRedpackResult redpackResult = this.wxService.sendRedpack(request); | WxPaySendRedpackResult redpackResult = this.wxService.sendRedpack(request); | ||||
| this.logger.info(redpackResult.toString()); | this.logger.info(redpackResult.toString()); | ||||
| } | } | ||||
| @@ -131,7 +131,7 @@ public class WxMpPayServiceImplTest { | |||||
| .spbillCreateIp("111111") | .spbillCreateIp("111111") | ||||
| .notifyURL("111111") | .notifyURL("111111") | ||||
| .tradeType("JSAPI") | .tradeType("JSAPI") | ||||
| .openid("122") | |||||
| .openid(((XmlWxPayConfig) this.wxService.getConfig()).getOpenid()) | |||||
| .outTradeNo("111111") | .outTradeNo("111111") | ||||
| .build()); | .build()); | ||||
| this.logger.info(result.toString()); | this.logger.info(result.toString()); | ||||
| @@ -16,7 +16,7 @@ public class ApiTestModule implements Module { | |||||
| @Override | @Override | ||||
| public void configure(Binder binder) { | public void configure(Binder binder) { | ||||
| try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { | try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) { | ||||
| TestPayConfig config = this.fromXml(TestPayConfig.class, is1); | |||||
| XmlWxPayConfig config = this.fromXml(XmlWxPayConfig.class, is1); | |||||
| WxPayService wxService = new WxPayServiceImpl(); | WxPayService wxService = new WxPayServiceImpl(); | ||||
| wxService.setConfig(config); | wxService.setConfig(config); | ||||
| @@ -1,31 +1,31 @@ | |||||
| package com.github.binarywang.wxpay.testbase; | |||||
| import com.github.binarywang.wxpay.config.WxPayConfig; | |||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.http.ssl.SSLContexts; | |||||
| import javax.net.ssl.SSLContext; | |||||
| import java.io.File; | |||||
| import java.io.FileInputStream; | |||||
| import java.security.KeyStore; | |||||
| @XStreamAlias("xml") | |||||
| public class TestPayConfig extends WxPayConfig { | |||||
| private String openid; | |||||
| public String getOpenid() { | |||||
| return openid; | |||||
| } | |||||
| public void setOpenid(String openid) { | |||||
| this.openid = openid; | |||||
| } | |||||
| @Override | |||||
| public boolean useSandboxForWxPay() { | |||||
| //沙箱环境不成熟,有问题无法使用,暂时屏蔽掉 | |||||
| // return true; | |||||
| return false; | |||||
| } | |||||
| } | |||||
| package com.github.binarywang.wxpay.testbase; | |||||
| import com.github.binarywang.wxpay.config.WxPayConfig; | |||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.http.ssl.SSLContexts; | |||||
| import javax.net.ssl.SSLContext; | |||||
| import java.io.File; | |||||
| import java.io.FileInputStream; | |||||
| import java.security.KeyStore; | |||||
| @XStreamAlias("xml") | |||||
| public class XmlWxPayConfig extends WxPayConfig { | |||||
| private String openid; | |||||
| public String getOpenid() { | |||||
| return openid; | |||||
| } | |||||
| public void setOpenid(String openid) { | |||||
| this.openid = openid; | |||||
| } | |||||
| @Override | |||||
| public boolean useSandboxForWxPay() { | |||||
| //沙箱环境不成熟,有问题无法使用,暂时屏蔽掉 | |||||
| // return true; | |||||
| return false; | |||||
| } | |||||
| } | |||||