|
2 | 2 |
|
3 | 3 | import com.github.binarywang.utils.qrcode.QrcodeUtils; |
4 | 4 | import com.github.binarywang.wxpay.bean.coupon.*; |
| 5 | +import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; |
| 6 | +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; |
| 7 | +import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; |
5 | 8 | import com.github.binarywang.wxpay.bean.request.*; |
6 | 9 | import com.github.binarywang.wxpay.bean.result.*; |
7 | 10 | import com.github.binarywang.wxpay.constant.WxPayConstants; |
|
29 | 32 | * 测试支付相关接口 |
30 | 33 | * Created by Binary Wang on 2016/7/28. |
31 | 34 | * |
32 | | - * @author binarywang (https://github.com/binarywang) |
| 35 | + * @author <a href="https://github.com/binarywang">Binary Wang</a> |
33 | 36 | */ |
34 | 37 | @Test |
35 | 38 | @Guice(modules = ApiTestModule.class) |
@@ -58,17 +61,85 @@ public void testUnifiedOrder() throws WxPayException { |
58 | 61 | this.logger.warn(this.payService.getWxApiData().toString()); |
59 | 62 | } |
60 | 63 |
|
| 64 | + @Test |
| 65 | + public void testCreateOrder() throws Exception { |
| 66 | + //see other tests with method name starting with 'testCreateOrder_' |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + public void testCreateOrder_jssdk() throws Exception { |
| 71 | + WxPayMpOrderResult result = this.payService |
| 72 | + .createOrder(WxPayUnifiedOrderRequest.newBuilder() |
| 73 | + .body("我去") |
| 74 | + .totalFee(1) |
| 75 | + .spbillCreateIp("11.1.11.1") |
| 76 | + .notifyURL("111111") |
| 77 | + .tradeType(TradeType.JSAPI) |
| 78 | + .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) |
| 79 | + .outTradeNo("1111112") |
| 80 | + .build()); |
| 81 | + this.logger.info(result.toString()); |
| 82 | + this.logger.warn(this.payService.getWxApiData().toString()); |
| 83 | + } |
| 84 | + |
| 85 | + @Test |
| 86 | + public void testCreateOrder_app() throws Exception { |
| 87 | + WxPayAppOrderResult result = this.payService |
| 88 | + .createOrder(WxPayUnifiedOrderRequest.newBuilder() |
| 89 | + .body("我去") |
| 90 | + .totalFee(1) |
| 91 | + .spbillCreateIp("11.1.11.1") |
| 92 | + .notifyURL("111111") |
| 93 | + .tradeType(TradeType.APP) |
| 94 | + .outTradeNo("1111112") |
| 95 | + .build()); |
| 96 | + this.logger.info(result.toString()); |
| 97 | + this.logger.warn(this.payService.getWxApiData().toString()); |
| 98 | + } |
| 99 | + |
| 100 | + @Test |
| 101 | + public void testCreateOrder_native() throws Exception { |
| 102 | + WxPayNativeOrderResult result = this.payService |
| 103 | + .createOrder(WxPayUnifiedOrderRequest.newBuilder() |
| 104 | + .body("我去") |
| 105 | + .totalFee(1) |
| 106 | + .spbillCreateIp("11.1.11.1") |
| 107 | + .notifyURL("111111") |
| 108 | + .tradeType(TradeType.NATIVE) |
| 109 | + .outTradeNo("1111112") |
| 110 | + .build()); |
| 111 | + this.logger.info(result.toString()); |
| 112 | + this.logger.warn(this.payService.getWxApiData().toString()); |
| 113 | + } |
| 114 | + |
| 115 | + @Test |
| 116 | + public void testCreateOrder_micropay() throws Exception { |
| 117 | + //TODO 待完善 |
| 118 | + Object result = this.payService |
| 119 | + .createOrder(WxPayUnifiedOrderRequest.newBuilder() |
| 120 | + .body("我去") |
| 121 | + .totalFee(1) |
| 122 | + .spbillCreateIp("11.1.11.1") |
| 123 | + .notifyURL("111111") |
| 124 | + .tradeType(TradeType.MICROPAY) |
| 125 | + .outTradeNo("1111112") |
| 126 | + .build()); |
| 127 | + this.logger.info(result.toString()); |
| 128 | + this.logger.warn(this.payService.getWxApiData().toString()); |
| 129 | + } |
| 130 | + |
61 | 131 | @Test |
62 | 132 | public void testGetPayInfo() throws Exception { |
63 | | - Map<String, String> payInfo = this.payService.getPayInfo(WxPayUnifiedOrderRequest.newBuilder() |
64 | | - .body("我去") |
65 | | - .totalFee(1) |
66 | | - .spbillCreateIp("1.11.1.11") |
67 | | - .notifyURL("111111") |
68 | | - .tradeType(TradeType.JSAPI) |
69 | | - .outTradeNo("1111113") |
70 | | - .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) |
71 | | - .build()); |
| 133 | + Map<String, String> payInfo = this.payService |
| 134 | + .getPayInfo(WxPayUnifiedOrderRequest.newBuilder() |
| 135 | + .body("我去") |
| 136 | + .totalFee(1) |
| 137 | + .spbillCreateIp("1.11.1.11") |
| 138 | + .notifyURL("111111") |
| 139 | + .tradeType(TradeType.JSAPI) |
| 140 | + .outTradeNo("1111113") |
| 141 | + .openid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()) |
| 142 | + .build()); |
72 | 143 | this.logger.info(payInfo.toString()); |
73 | 144 | } |
74 | 145 |
|
@@ -237,10 +308,6 @@ public void testCreateScanPayQrcodeMode2() throws Exception { |
237 | 308 | assertEquals(QrcodeUtils.decodeQrcode(qrcodeFilePath.toFile()), qrcodeContent); |
238 | 309 | } |
239 | 310 |
|
240 | | - @Test |
241 | | - public void testGetOrderNotifyResult() throws Exception { |
242 | | - } |
243 | | - |
244 | 311 | @Test |
245 | 312 | public void testMicropay() throws Exception { |
246 | 313 | WxPayMicropayResult result = this.payService.micropay(WxPayMicropayRequest.newBuilder() |
@@ -347,4 +414,14 @@ public void testQueryComment() throws Exception { |
347 | 414 | this.payService.queryComment(beginDate, endDate, 0, null); |
348 | 415 | } |
349 | 416 |
|
| 417 | + @Test |
| 418 | + public void testParseOrderNotifyResult() throws Exception { |
| 419 | + // 请参考com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResultTest里的单元测试 |
| 420 | + } |
| 421 | + |
| 422 | + @Test |
| 423 | + public void testGetWxApiData() throws Exception { |
| 424 | + //see test in testUnifiedOrder() |
| 425 | + } |
| 426 | + |
350 | 427 | } |
0 commit comments