|
38 | 38 | import java.util.Calendar; |
39 | 39 | import java.util.Date; |
40 | 40 | import java.util.Optional; |
| 41 | +import java.util.UUID; |
41 | 42 |
|
42 | 43 | import static com.github.binarywang.wxpay.constant.WxPayConstants.TarType; |
43 | 44 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -157,16 +158,16 @@ public void testCreateOrderSpecific() throws Exception { |
157 | 158 | // Won't compile |
158 | 159 | // WxPayMpOrderResult result = payService.createOrder(TradeType.Specific.APP, new WxPayUnifiedOrderRequest()); |
159 | 160 | payService.createOrder( |
160 | | - TradeType.Specific.JSAPI, |
161 | | - WxPayUnifiedOrderRequest.newBuilder() |
162 | | - .body("我去") |
163 | | - .totalFee(1) |
164 | | - .productId("aaa") |
165 | | - .spbillCreateIp("11.1.11.1") |
166 | | - .notifyUrl("111111") |
167 | | - .outTradeNo("111111290") |
168 | | - .build() |
169 | | - ) |
| 161 | + TradeType.Specific.JSAPI, |
| 162 | + WxPayUnifiedOrderRequest.newBuilder() |
| 163 | + .body("我去") |
| 164 | + .totalFee(1) |
| 165 | + .productId("aaa") |
| 166 | + .spbillCreateIp("11.1.11.1") |
| 167 | + .notifyUrl("111111") |
| 168 | + .outTradeNo("111111290") |
| 169 | + .build() |
| 170 | + ) |
170 | 171 | .getAppId(); |
171 | 172 | } |
172 | 173 |
|
@@ -876,4 +877,34 @@ public void testQueryOrderV3WithProxy() { |
876 | 877 |
|
877 | 878 | } |
878 | 879 |
|
| 880 | + @Test |
| 881 | + public void testCreatePartnerOrderV3() throws WxPayException { |
| 882 | + WxPayConfig wxPayConfig = new WxPayConfig(); |
| 883 | + //服务商的参数 |
| 884 | + wxPayConfig.setMchId("xxx"); |
| 885 | + wxPayConfig.setApiV3Key("xxx"); |
| 886 | + wxPayConfig.setPrivateKeyPath("xxx"); |
| 887 | + wxPayConfig.setPrivateCertPath("xxx"); |
| 888 | + wxPayConfig.setKeyPath("xxx"); |
| 889 | + wxPayConfig.setAppId("xxx"); |
| 890 | + wxPayConfig.setKeyPath("xxx"); |
| 891 | + //如果有子商户的appId则配置 |
| 892 | +// wxPayConfig.setSubAppId("xxx"); |
| 893 | + //创建支付服务 |
| 894 | + WxPayService wxPayService = new WxPayServiceImpl(); |
| 895 | + wxPayService.setConfig(wxPayConfig); |
| 896 | + //子商户的参数 |
| 897 | + wxPayConfig.setSubMchId("xxx"); |
| 898 | + |
| 899 | + //构建请求 |
| 900 | + WxPayPartnerUnifiedOrderV3Request request = new WxPayPartnerUnifiedOrderV3Request(); |
| 901 | + request.setAmount(new WxPayPartnerUnifiedOrderV3Request.Amount().setTotal(1)); |
| 902 | + request.setPayer(new WxPayPartnerUnifiedOrderV3Request.Payer().setSpOpenid("xxx")); |
| 903 | + //如果有子商户的appId则配置 |
| 904 | +// request.setPayer(new WxPayPartnerUnifiedOrderV3Request.Payer().setSubOpenid("xxx")); |
| 905 | + request.setOutTradeNo(UUID.randomUUID().toString()); |
| 906 | + |
| 907 | + WxPayUnifiedOrderV3Result.JsapiResult result = payService.createPartnerOrderV3(TradeTypeEnum.JSAPI, request); |
| 908 | + System.out.println(result); |
| 909 | + } |
879 | 910 | } |
0 commit comments