微信支付接口抽取部分常量
This commit is contained in:
@@ -4,6 +4,10 @@ import com.github.binarywang.utils.qrcode.QrcodeUtils;
|
||||
import com.github.binarywang.wxpay.bean.coupon.*;
|
||||
import com.github.binarywang.wxpay.bean.request.*;
|
||||
import com.github.binarywang.wxpay.bean.result.*;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants.BillType;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.testbase.ApiTestModule;
|
||||
@@ -33,23 +37,58 @@ public class WxPayServiceAbstractImplTest {
|
||||
@Inject
|
||||
private WxPayService payService;
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}.
|
||||
*/
|
||||
@Test
|
||||
public void testUnifiedOrder() throws WxPayException {
|
||||
WxPayUnifiedOrderResult result = this.payService
|
||||
.unifiedOrder(WxPayUnifiedOrderRequest.newBuilder()
|
||||
.body("我去")
|
||||
.totalFee(1)
|
||||
.spbillCreateIp("11.1.11.1")
|
||||
.notifyURL("111111")
|
||||
.tradeType(TradeType.JSAPI)
|
||||
.openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
|
||||
.outTradeNo("1111112")
|
||||
.build());
|
||||
this.logger.info(result.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPayInfo() throws Exception {
|
||||
Map<String, String> payInfo = this.payService.getPayInfo(WxPayUnifiedOrderRequest.newBuilder()
|
||||
.body("我去")
|
||||
.totalFee(1)
|
||||
.spbillCreateIp("111111")
|
||||
.spbillCreateIp("1.11.1.11")
|
||||
.notifyURL("111111")
|
||||
.tradeType("JSAPI")
|
||||
.outTradeNo("111111")
|
||||
.tradeType(TradeType.JSAPI)
|
||||
.outTradeNo("1111113")
|
||||
.openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
|
||||
.build());
|
||||
this.logger.info(payInfo.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#queryOrder(String, String)} .
|
||||
*/
|
||||
@Test
|
||||
public void testQueryOrder() throws WxPayException {
|
||||
this.logger.info(this.payService.queryOrder("11212121", null).toString());
|
||||
this.logger.info(this.payService.queryOrder(null, "11111").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#closeOrder(String)} .
|
||||
*/
|
||||
@Test
|
||||
public void testCloseOrder() throws WxPayException {
|
||||
this.logger.info(this.payService.closeOrder("11212121").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDownloadBill() throws Exception {
|
||||
WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170101", "ALL", "GZIP", "1111111");
|
||||
WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170101", BillType.ALL, "GZIP", "1111111");
|
||||
//前一天没有账单记录返回null
|
||||
assertNotNull(wxPayBillResult);
|
||||
//必填字段为空时,抛出异常
|
||||
@@ -60,7 +99,7 @@ public class WxPayServiceAbstractImplTest {
|
||||
public void testReport() throws Exception {
|
||||
WxPayReportRequest request = new WxPayReportRequest();
|
||||
request.setInterfaceUrl("hahahah");
|
||||
request.setSignType("HMAC-SHA256");//貌似接口未校验此字段
|
||||
request.setSignType(SignType.HMAC_SHA256);//貌似接口未校验此字段
|
||||
request.setExecuteTime(1000);
|
||||
request.setReturnCode("aaa");
|
||||
request.setResultCode("aaa");
|
||||
@@ -130,41 +169,6 @@ public class WxPayServiceAbstractImplTest {
|
||||
this.logger.info(redpackResult.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#unifiedOrder(WxPayUnifiedOrderRequest)}.
|
||||
*/
|
||||
@Test
|
||||
public void testUnifiedOrder() throws WxPayException {
|
||||
WxPayUnifiedOrderResult result = this.payService
|
||||
.unifiedOrder(WxPayUnifiedOrderRequest.newBuilder()
|
||||
.body("我去")
|
||||
.totalFee(1)
|
||||
.spbillCreateIp("11.1.11.1")
|
||||
.notifyURL("111111")
|
||||
.tradeType("JSAPI")
|
||||
.openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid())
|
||||
.outTradeNo("111111")
|
||||
.build());
|
||||
this.logger.info(result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#queryOrder(String, String)} .
|
||||
*/
|
||||
@Test
|
||||
public void testQueryOrder() throws WxPayException {
|
||||
this.logger.info(this.payService.queryOrder("11212121", null).toString());
|
||||
this.logger.info(this.payService.queryOrder(null, "11111").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#closeOrder(String)} .
|
||||
*/
|
||||
@Test
|
||||
public void testCloseOrder() throws WxPayException {
|
||||
this.logger.info(this.payService.closeOrder("11212121").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link WxPayService#entPay(WxEntPayRequest)}.
|
||||
*/
|
||||
@@ -175,7 +179,7 @@ public class WxPayServiceAbstractImplTest {
|
||||
.openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
|
||||
.amount(1)
|
||||
.spbillCreateIp("10.10.10.10")
|
||||
.checkName("NO_CHECK")
|
||||
.checkName(WxPayConstants.CheckNameOption.NO_CHECK)
|
||||
.description("描述信息")
|
||||
.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user