forked from binarywang/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWxPayService.java
More file actions
1524 lines (1405 loc) · 68.5 KB
/
WxPayService.java
File metadata and controls
1524 lines (1405 loc) · 68.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.WxPayApiData;
import com.github.binarywang.wxpay.bean.coupon.*;
import com.github.binarywang.wxpay.bean.notify.*;
import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import java.io.File;
import java.io.InputStream;
import java.util.Date;
import java.util.Map;
/**
* <pre>
* 微信支付相关接口.
* Created by Binary Wang on 2016/7/28.
* </pre>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
*/
public interface WxPayService {
/**
* 获取微信支付请求url前缀,沙箱环境可能不一样.
*
* @return the pay base url
*/
String getPayBaseUrl();
/**
* Map里 加入新的 {@link WxPayConfig},适用于动态添加新的微信商户配置.
*
* @param mchId 商户id
* @param wxPayConfig 新的微信配置
*/
void addConfig(String mchId, WxPayConfig wxPayConfig);
/**
* 从 Map中 移除 {@link String mchId} 所对应的 {@link WxPayConfig},适用于动态移除微信商户配置.
*
* @param mchId 对应商户的标识
*/
void removeConfig(String mchId);
/**
* 注入多个 {@link WxPayConfig} 的实现. 并为每个 {@link WxPayConfig} 赋予不同的 {@link String mchId} 值
* 随机采用一个{@link String mchId}进行Http初始化操作
*
* @param wxPayConfigs WxPayConfig map
*/
void setMultiConfig(Map<String, WxPayConfig> wxPayConfigs);
/**
* 注入多个 {@link WxPayConfig} 的实现. 并为每个 {@link WxPayConfig} 赋予不同的 {@link String label} 值
*
* @param wxPayConfigs WxPayConfig map
* @param defaultMchId 设置一个{@link WxPayConfig} 所对应的{@link String mchId}进行Http初始化
*/
void setMultiConfig(Map<String, WxPayConfig> wxPayConfigs, String defaultMchId);
/**
* 进行相应的商户切换.
*
* @param mchId 商户标识
* @return 切换是否成功 boolean
*/
boolean switchover(String mchId);
/**
* 进行相应的商户切换.
*
* @param mchId 商户标识
* @return 切换成功 ,则返回当前对象,方便链式调用,否则抛出异常
*/
WxPayService switchoverTo(String mchId);
/**
* 发送post请求,得到响应字节数组.
*
* @param url 请求地址
* @param requestStr 请求信息
* @param useKey 是否使用证书
* @return 返回请求结果字节数组 byte [ ]
* @throws WxPayException the wx pay exception
*/
byte[] postForBytes(String url, String requestStr, boolean useKey) throws WxPayException;
/**
* 发送post请求,得到响应字符串.
*
* @param url 请求地址
* @param requestStr 请求信息
* @param useKey 是否使用证书
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String post(String url, String requestStr, boolean useKey) throws WxPayException;
/**
* 发送post请求,得到响应字符串.
*
* @param url 请求地址
* @param requestStr 请求信息
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String postV3(String url, String requestStr) throws WxPayException;
/**
* 发送patch请求,得到响应字符串.
*
* @param url 请求地址
* @param requestStr 请求信息
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String patchV3(String url, String requestStr) throws WxPayException;
/**
* 发送post请求,得到响应字符串.
* <p>
* 部分字段会包含敏感信息,所以在提交前需要在请求头中会包含"Wechatpay-Serial"信息
*
* @param url 请求地址
* @param requestStr 请求信息
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String postV3WithWechatpaySerial(String url, String requestStr) throws WxPayException;
/**
* 发送post请求,得到响应字符串.
*
* @param url 请求地址
* @param httpPost 请求信息
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String postV3(String url, HttpPost httpPost) throws WxPayException;
/**
* 发送http请求,得到响应字符串.
*
* @param url 请求地址
* @param httpRequest 请求信息,可以是put,post,get,delete等请求
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String requestV3(String url, HttpRequestBase httpRequest) throws WxPayException;
/**
* 发送get V3请求,得到响应字符串.
*
* @param url 请求地址
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String getV3(String url) throws WxPayException;
/**
* 发送get请求,得到响应字符串.
* <p>
* 部分字段会包含敏感信息,所以在提交前需要在请求头中会包含"Wechatpay-Serial"信息
*
* @param url 请求地址
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String getV3WithWechatPaySerial(String url) throws WxPayException;
/**
* 发送下载 V3请求,得到响应流.
*
* @param url 请求地址
* @return 返回请求响应流 input stream
* @throws WxPayException the wx pay exception
*/
InputStream downloadV3(String url) throws WxPayException;
/**
* 发送put V3请求,得到响应字符串.
*
* @param url 请求地址
* @param requestStr 请求数据
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String putV3(String url, String requestStr) throws WxPayException;
/**
* 发送delete V3请求,得到响应字符串.
*
* @param url 请求地址
* @return 返回请求结果字符串 string
* @throws WxPayException the wx pay exception
*/
String deleteV3(String url) throws WxPayException;
/**
* 获取微信签约代扣服务类
*
* @return entrust service
*/
WxEntrustPapService getWxEntrustPapService();
/**
* 获取批量转账到零钱服务类.
*
* @return the Batch transfer to change service
*/
PartnerTransferService getPartnerTransferService();
/**
* 微工卡
*
* @return the micro card
*/
PayrollService getPayrollService();
/**
* 获取企业付款服务类.
*
* @return the ent pay service
*/
EntPayService getEntPayService();
/**
* 获取红包接口服务类.
*
* @return . redpack service
*/
RedpackService getRedpackService();
/**
* 获取分账服务类.
* <p>
* V3接口 {@link WxPayService#getProfitSharingV3Service()}
* </p>
*
* @return the ent pay service
*/
ProfitSharingService getProfitSharingService();
/**
* 获取V3分账服务类.
*
* @return the ent pay service
*/
ProfitSharingV3Service getProfitSharingV3Service();
/**
* 获取支付分服务类.
*
* @return the ent pay service
*/
PayScoreService getPayScoreService();
/**
* 获取电商收付通服务类
*
* @return the ecommerce service
*/
EcommerceService getEcommerceService();
/**
* 获取微信支付智慧商圈服务类
*
* @return the business circle service
*/
BusinessCircleService getBusinessCircleService();
/**
* 获取微信支付通用媒体服务类
*
* @return the merchant media service
*/
MerchantMediaService getMerchantMediaService();
/**
* 获取微信支付营销媒体服务类
*
* @return the marketing media service
*/
MarketingMediaService getMarketingMediaService();
/**
* 获取微信支付营销代金券服务类
*
* @return the marketing favor service
*/
MarketingFavorService getMarketingFavorService();
/**
* 获取微信支付营销商家券服务类
*
* @return the marketing favor service
*/
MarketingBusiFavorService getMarketingBusiFavorService();
/**
* 获取商家转账到零钱服务类
*
* @return the merchant transfer service
*/
MerchantTransferService getMerchantTransferService();
/**
* 获取品牌红包商家转账到零钱服务类
*
* @return the brand merchant transfer service
*/
BrandMerchantTransferService getBrandMerchantTransferService();
/**
* 设置企业付款服务类,允许开发者自定义实现类.
*
* @param entPayService the ent pay service
*/
void setEntPayService(EntPayService entPayService);
/**
* <pre>
* 查询订单.
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
* 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
* 需要调用查询接口的情况:
* ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
* ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
* ◆ 调用被扫支付API,返回USERPAYING的状态;
* ◆ 调用关单或撤销接口API之前,需确认支付状态;
* 接口地址:https://api.mch.weixin.qq.com/pay/orderquery
* </pre>
*
* @param transactionId 微信订单号
* @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。
* @return the wx pay order query result
* @throws WxPayException the wx pay exception
*/
WxPayOrderQueryResult queryOrder(String transactionId, String outTradeNo) throws WxPayException;
/**
* <pre>
* 查询订单(适合于需要自定义子商户号和子商户appid的情形).
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
* 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
* 需要调用查询接口的情况:
* ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
* ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
* ◆ 调用被扫支付API,返回USERPAYING的状态;
* ◆ 调用关单或撤销接口API之前,需确认支付状态;
* 接口地址:https://api.mch.weixin.qq.com/pay/orderquery
* </pre>
*
* @param request 查询订单请求对象
* @return the wx pay order query result
* @throws WxPayException the wx pay exception
*/
WxPayOrderQueryResult queryOrder(WxPayOrderQueryRequest request) throws WxPayException;
/**
* <pre>
* 查询订单
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml</a>
* 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
* 注意:
* 查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
* 需要调用查询接口的情况:
* ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知。
* ◆ 调用支付接口后,返回系统错误或未知交易状态情况。
* ◆ 调用付款码支付API,返回USERPAYING的状态。
* ◆ 调用关单或撤销接口API之前,需确认支付状态。
* 接口地址:
* https://api.mch.weixin.qq.com/v3/pay/transactions/id/{transaction_id}
* https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/{out_trade_no}
* </pre>
*
* @param transactionId 微信订单号
* @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。
* @return the wx pay order query result
* @throws WxPayException the wx pay exception
*/
WxPayOrderQueryV3Result queryOrderV3(String transactionId, String outTradeNo) throws WxPayException;
/**
* <pre>
* 查询订单
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_2.shtml</a>
* 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
* 注意:
* 查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
* 需要调用查询接口的情况:
* ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知。
* ◆ 调用支付接口后,返回系统错误或未知交易状态情况。
* ◆ 调用付款码支付API,返回USERPAYING的状态。
* ◆ 调用关单或撤销接口API之前,需确认支付状态。
* 接口地址:
* https://api.mch.weixin.qq.com/v3/pay/transactions/id/{transaction_id}
* https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/{out_trade_no}
* </pre>
*
* @param request 查询订单请求对象
* @return the wx pay order query result
* @throws WxPayException the wx pay exception
*/
WxPayOrderQueryV3Result queryOrderV3(WxPayOrderQueryV3Request request) throws WxPayException;
/**
* <pre>
* 服务商模式查询订单
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml</a>
* 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
* 注意:
* 查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
* 需要调用查询接口的情况:
* ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知。
* ◆ 调用支付接口后,返回系统错误或未知交易状态情况。
* ◆ 调用付款码支付API,返回USERPAYING的状态。
* ◆ 调用关单或撤销接口API之前,需确认支付状态。
* 接口地址:
* https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/{transaction_id}
* https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}
* </pre>
*
* @param transactionId 微信订单号
* @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。
* @return the wx pay order query result
* @throws WxPayException the wx pay exception
*/
WxPayPartnerOrderQueryV3Result queryPartnerOrderV3(String transactionId, String outTradeNo) throws WxPayException;
/**
* <pre>
* 服务商模式查询订单
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_2.shtml</a>
* 商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
* 注意:
* 查询订单可通过微信支付订单号和商户订单号两种方式查询,两种查询方式返回结果相同
* 需要调用查询接口的情况:
* ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知。
* ◆ 调用支付接口后,返回系统错误或未知交易状态情况。
* ◆ 调用付款码支付API,返回USERPAYING的状态。
* ◆ 调用关单或撤销接口API之前,需确认支付状态。
* 接口地址:
* https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/{transaction_id}
* https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}
* </pre>
*
* @param request 查询订单请求对象
* @return the wx pay order query result
* @throws WxPayException the wx pay exception
*/
WxPayPartnerOrderQueryV3Result queryPartnerOrderV3(WxPayPartnerOrderQueryV3Request request) throws WxPayException;
/**
* <pre>
* 合单查询订单API
* 请求URL: https://api.mch.weixin.qq.com/v3/combine-transactions/out-trade-no/{combine_out_trade_no}
* 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_11.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_11.shtml</a>
* </pre>
*
* @param combineOutTradeNo 合单商户订单号
* @return 合单支付订单信息 combine query result
* @throws WxPayException the wx pay exception
*/
CombineQueryResult queryCombine(String combineOutTradeNo) throws WxPayException;
/**
* <pre>
* 关闭订单.
* 应用场景
* 以下情况需要调用关单接口:
* 1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
* 2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
* 注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。
* 接口地址:https://api.mch.weixin.qq.com/pay/closeorder
* 是否需要证书: 不需要。
* </pre>
*
* @param outTradeNo 商户系统内部的订单号
* @return the wx pay order close result
* @throws WxPayException the wx pay exception
*/
WxPayOrderCloseResult closeOrder(String outTradeNo) throws WxPayException;
/**
* <pre>
* 关闭订单(适合于需要自定义子商户号和子商户appid的情形).
* 应用场景
* 以下情况需要调用关单接口:
* 1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
* 2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
* 注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。
* 接口地址:https://api.mch.weixin.qq.com/pay/closeorder
* 是否需要证书: 不需要。
* </pre>
*
* @param request 关闭订单请求对象
* @return the wx pay order close result
* @throws WxPayException the wx pay exception
*/
WxPayOrderCloseResult closeOrder(WxPayOrderCloseRequest request) throws WxPayException;
/**
* <pre>
* 关闭订单
* 应用场景
* 以下情况需要调用关单接口:
* 1、商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
* 2、系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
* 注意:关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
* 接口地址:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_3.shtml
* </pre>
*
* @param outTradeNo 商户系统内部的订单号
* @return the wx pay order close result
* @throws WxPayException the wx pay exception
*/
void closeOrderV3(String outTradeNo) throws WxPayException;
/**
* <pre>
* 服务商关闭订单
* 应用场景
* 以下情况需要调用关单接口:
* 1、商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
* 2、系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
* 注意:关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
* 接口地址:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_3.shtml
* </pre>
*
* @param outTradeNo 商户系统内部的订单号
* @return the wx pay order close result
* @throws WxPayException the wx pay exception
*/
void closePartnerOrderV3(String outTradeNo) throws WxPayException;
/**
* <pre>
* 关闭订单
* 应用场景
* 以下情况需要调用关单接口:
* 1、商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
* 2、系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
* 注意:关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
* 接口地址:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_3.shtml
* </pre>
*
* @param request 关闭订单请求对象
* @return the wx pay order close result
* @throws WxPayException the wx pay exception
*/
void closeOrderV3(WxPayOrderCloseV3Request request) throws WxPayException;
/**
* <pre>
* 服务商关闭订单
* 应用场景
* 以下情况需要调用关单接口:
* 1、商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
* 2、系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
* 注意:关单没有时间限制,建议在订单生成后间隔几分钟(最短5分钟)再调用关单接口,避免出现订单状态同步不及时导致关单失败。
* 接口地址:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_3.shtml
* </pre>
*
* @param request 关闭订单请求对象
* @return the wx pay order close result
* @throws WxPayException the wx pay exception
*/
void closePartnerOrderV3(WxPayPartnerOrderCloseV3Request request) throws WxPayException;
/**
* <pre>
* 合单关闭订单API
* 请求URL: https://api.mch.weixin.qq.com/v3/combine-transactions/out-trade-no/{combine_out_trade_no}/close
* 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_12.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_12.shtml</a>
* </pre>
*
* @param request 请求对象
* @throws WxPayException the wx pay exception
*/
void closeCombine(CombineCloseRequest request) throws WxPayException;
/**
* 调用统一下单接口,并组装生成支付所需参数对象.
*
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
* @param request 统一下单请求参数
* @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
* @throws WxPayException the wx pay exception
*/
<T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException;
/**
* 调用统一下单接口,并组装生成支付所需参数对象.
*
* @param <T> the type parameter
* @param specificTradeType 将使用的交易方式,不能为 null
* @param request 统一下单请求参数,设定的 tradeType 及配置里的 tradeType 将被忽略,转而使用 specificTradeType
* @return 返回 {@link WxPayConstants.TradeType.Specific} 指定的类
* @throws WxPayException the wx pay exception
* @see WxPayService#createOrder(WxPayUnifiedOrderRequest) WxPayService#createOrder(WxPayUnifiedOrderRequest)WxPayService#createOrder(WxPayUnifiedOrderRequest)
*/
<T> T createOrder(WxPayConstants.TradeType.Specific<T> specificTradeType, WxPayUnifiedOrderRequest request) throws WxPayException;
/**
* 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1)
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
* 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
*
* @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
* @return the wx pay unified order result
* @throws WxPayException the wx pay exception
*/
WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request) throws WxPayException;
/**
* 调用统一下单接口,并组装生成支付所需参数对象.
*
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段
* @param tradeType the trade type
* @param request 统一下单请求参数
* @return 返回 {@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段
* @throws WxPayException the wx pay exception
*/
<T> T createOrderV3(TradeTypeEnum tradeType, WxPayUnifiedOrderV3Request request) throws WxPayException;
/**
* 服务商模式调用统一下单接口,并组装生成支付所需参数对象.
*
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段
* @param tradeType the trade type
* @param request 统一下单请求参数
* @return 返回 {@link com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result}里的内部类或字段
* @throws WxPayException the wx pay exception
*/
<T> T createPartnerOrderV3(TradeTypeEnum tradeType, WxPayPartnerUnifiedOrderV3Request request) throws WxPayException;
/**
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
*
* @param tradeType the trade type
* @param request 请求对象,注意一些参数如spAppid、spMchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
* @return the wx pay unified order result
* @throws WxPayException the wx pay exception
*/
WxPayUnifiedOrderV3Result unifiedPartnerOrderV3(TradeTypeEnum tradeType, WxPayPartnerUnifiedOrderV3Request request) throws WxPayException;
/**
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
*
* @param tradeType the trade type
* @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
* @return the wx pay unified order result
* @throws WxPayException the wx pay exception
*/
WxPayUnifiedOrderV3Result unifiedOrderV3(TradeTypeEnum tradeType, WxPayUnifiedOrderV3Request request) throws WxPayException;
/**
* <pre>
* 合单支付API(APP支付、JSAPI支付、H5支付、NATIVE支付).
* 请求URL:
* https://api.mch.weixin.qq.com/v3/combine-transactions/app
* https://api.mch.weixin.qq.com/v3/combine-transactions/h5
* https://api.mch.weixin.qq.com/v3/combine-transactions/jsapi
* https://api.mch.weixin.qq.com/v3/combine-transactions/native
* 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml</a>
* </pre>
*
* @param tradeType 支付方式
* @param request 请求对象
* @return 微信合单支付返回 combine transactions result
* @throws WxPayException the wx pay exception
*/
CombineTransactionsResult combine(TradeTypeEnum tradeType, CombineTransactionsRequest request) throws WxPayException;
/**
* <pre>
* 合单支付API(APP支付、JSAPI支付、H5支付、NATIVE支付).
* 请求URL:
* https://api.mch.weixin.qq.com/v3/combine-transactions/app
* https://api.mch.weixin.qq.com/v3/combine-transactions/h5
* https://api.mch.weixin.qq.com/v3/combine-transactions/jsapi
* https://api.mch.weixin.qq.com/v3/combine-transactions/native
* 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_9_3.shtml</a>
* </pre>
*
* @param <T> the type parameter
* @param tradeType 支付方式
* @param request 请求对象
* @return 调起支付需要的参数 t
* @throws WxPayException the wx pay exception
*/
<T> T combineTransactions(TradeTypeEnum tradeType, CombineTransactionsRequest request) throws WxPayException;
/**
* 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数.
* 详见https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_5
*
* @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
* @return the pay info
* @throws WxPayException the wx pay exception
* @deprecated 建议使用 {@link WxPayService#createOrder(WxPayUnifiedOrderRequest)}
*/
@Deprecated
Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws WxPayException;
/**
* 获取配置.
*
* @return the config
*/
WxPayConfig getConfig();
/**
* 设置配置对象.
*
* @param config the config
*/
void setConfig(WxPayConfig config);
/**
* <pre>
* 微信支付-申请退款.
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4</a>
* 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund
* </pre>
*
* @param request 请求对象
* @return 退款操作结果 wx pay refund result
* @throws WxPayException the wx pay exception
*/
WxPayRefundResult refund(WxPayRefundRequest request) throws WxPayException;
/**
* <pre>
* 申请退款API(支持单品).
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_103&index=3">https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_103&index=3</a>
*
* 应用场景
* 当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,按照退款规则将支付款按原路退到买家帐号上。
*
* 注意:
* 1、交易时间超过一年的订单无法提交退款;
* 2、微信支付退款支持单笔交易分多次退款,多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。申请退款总金额不能超过订单金额。 一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号。
* 3、请求频率限制:150qps,即每秒钟正常的申请退款请求次数不超过150次
* 错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款申请请求不超过6次
* 4、每个支付订单的部分退款次数不能超过50次
* 5、本接口支持单品优惠订单全额退款和单品优惠订单部分退款,推荐使用本接口,如果使用不支持单品优惠部分退款的历史接口,请看https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=9_4
*
* 接口地址
* https://api.mch.weixin.qq.com/secapi/pay/refundv2
* https://api2.mch.weixin.qq.com/secapi/pay/refundv2(备用域名)见跨城冗灾方案
* </pre>
*
* @param request 请求对象
* @return 退款操作结果 wx pay refund result
* @throws WxPayException the wx pay exception
*/
WxPayRefundResult refundV2(WxPayRefundRequest request) throws WxPayException;
/**
* <pre>
* 申请退款API(支持单品).
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_9.shtml</a>
*
* 应用场景
* 当交易发生之后一年内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付金额退还给买家,微信支付将在收到退款请求并且验证成功之后,将支付款按原路退还至买家账号上。
*
* 注意:
* 1、交易时间超过一年的订单无法提交退款
* 2、微信支付退款支持单笔交易分多次退款(不超50次),多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。申请退款总金额不能超过订单金额。 一笔退款失败后重新提交,请不要更换退款单号,请使用原商户退款单号
* 3、错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款申请请求不超过6次
* 4、每个支付订单的部分退款次数不能超过50次
* 5、如果同一个用户有多笔退款,建议分不同批次进行退款,避免并发退款导致退款失败
* 6、申请退款接口的返回仅代表业务的受理情况,具体退款是否成功,需要通过退款查询接口获取结果
* 7、一个月之前的订单申请退款频率限制为:5000/min
*
* 接口地址
* https://api.mch.weixin.qq.com/v3/refund/domestic/refunds
* </pre>
*
* @param request 请求对象
* @return 退款操作结果 wx pay refund result
* @throws WxPayException the wx pay exception
*/
WxPayRefundV3Result refundV3(WxPayRefundV3Request request) throws WxPayException;
/**
* <pre>
* 微信支付-查询退款.
* 应用场景:
* 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,
* 银行卡支付的退款3个工作日后重新查询退款状态。
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5">https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5</a>
* 接口链接:https://api.mch.weixin.qq.com/pay/refundquery
* </pre>
* 以下四个参数四选一
*
* @param transactionId 微信订单号
* @param outTradeNo 商户订单号
* @param outRefundNo 商户退款单号
* @param refundId 微信退款单号
* @return 退款信息 wx pay refund query result
* @throws WxPayException the wx pay exception
*/
WxPayRefundQueryResult refundQuery(String transactionId, String outTradeNo, String outRefundNo, String refundId)
throws WxPayException;
/**
* <pre>
* 微信支付-查询退款(适合于需要自定义子商户号和子商户appid的情形).
* 应用场景:
* 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,
* 银行卡支付的退款3个工作日后重新查询退款状态。
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5">https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5</a>
* 接口链接:https://api.mch.weixin.qq.com/pay/refundquery
* </pre>
*
* @param request 微信退款单号
* @return 退款信息 wx pay refund query result
* @throws WxPayException the wx pay exception
*/
WxPayRefundQueryResult refundQuery(WxPayRefundQueryRequest request) throws WxPayException;
/**
* <pre>
* 微信支付-查询退款API(支持单品).
* 应用场景
* 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,银行卡支付的退款3个工作日后重新查询退款状态。
* 注意:
* 1、本接口支持查询单品优惠相关退款信息,且仅支持按微信退款单号或商户退款单号查询,若继续调用老查询退款接口,
* 请见https://pay.weixin.qq.com/wiki/doc/api/jsapi_sl.php?chapter=9_5
* 2、请求频率限制:300qps,即每秒钟正常的退款查询请求次数不超过300次
* 3、错误或无效请求频率限制:6qps,即每秒钟异常或错误的退款查询请求不超过6次
*
* 接口地址
* https://api.mch.weixin.qq.com/pay/refundqueryv2
* https://api2.mch.weixin.qq.com/pay/refundqueryv2(备用域名)见跨城冗灾方案
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_104&index=4">https://pay.weixin.qq.com/wiki/doc/api/danpin.php?chapter=9_104&index=4</a>
* </pre>
*
* @param request 微信退款单号
* @return 退款信息 wx pay refund query result
* @throws WxPayException the wx pay exception
*/
WxPayRefundQueryResult refundQueryV2(WxPayRefundQueryRequest request) throws WxPayException;
/**
* <pre>
* 微信支付-查询退款
* 应用场景:
* 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,建议在提交退款申请后1分钟发起查询退款状态,一般来说零钱支付的退款5分钟内到账,银行卡支付的退款1-3个工作日到账。
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml</a>
* 接口链接:https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/{out_refund_no}
* </pre>
*
* @param outRefundNo 商户退款单号
* @return 退款信息 wx pay refund query result
* @throws WxPayException the wx pay exception
*/
WxPayRefundQueryV3Result refundQueryV3(String outRefundNo) throws WxPayException;
/**
* <pre>
* 微信支付-查询退款
* 应用场景:
* 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,建议在提交退款申请后1分钟发起查询退款状态,一般来说零钱支付的退款5分钟内到账,银行卡支付的退款1-3个工作日到账。
* 详见 <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_10.shtml</a>
* 接口链接:https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/{out_refund_no}
* </pre>
*
* @param request 微信退款单号
* @return 退款信息 wx pay refund query result
* @throws WxPayException the wx pay exception
*/
WxPayRefundQueryV3Result refundQueryV3(WxPayRefundQueryV3Request request) throws WxPayException;
/**
* 解析支付结果通知.
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
*
* @param xmlData the xml data
* @return the wx pay order notify result
* @throws WxPayException the wx pay exception
*/
WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException;
/**
* 解析支付结果通知.
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
*
* @param xmlData the xml data
* @param signType 签名类型
* @return the wx pay order notify result
* @throws WxPayException the wx pay exception
*/
WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData, String signType) throws WxPayException;
/**
* 解析支付结果v3通知. 直连商户模式
* 详见https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @return the wx pay order notify result
* @throws WxPayException the wx pay exception
*/
WxPayNotifyV3Result parseOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 服务商模式解析支付结果v3通知.
* 详见https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_5.shtml
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @return the wx pay order notify result
* @throws WxPayException the wx pay exception
*/
WxPayPartnerNotifyV3Result parsePartnerOrderNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 支付服务商和直连商户两种模式
* 详见https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @param resultType 结果类型
* @param dataType 结果数据类型
* @return the wx pay order notify result
* @throws WxPayException the wx pay exception
*/
<T extends WxPayBaseNotifyV3Result<E>, E> T baseParseOrderNotifyV3Result(String notifyData, SignatureHeader header, Class<T> resultType, Class<E> dataType) throws WxPayException;
/**
* <pre>
* 合单支付通知回调数据处理
* 文档地址: <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_13.shtml">https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter5_1_13.shtml</a>
* </pre>
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @return 解密后通知数据 combine transactions notify result
* @throws WxPayException the wx pay exception
*/
CombineNotifyResult parseCombineNotifyResult(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 解析退款结果通知
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9
*
* @param xmlData the xml data
* @return the wx pay refund notify result
* @throws WxPayException the wx pay exception
*/
WxPayRefundNotifyResult parseRefundNotifyResult(String xmlData) throws WxPayException;
/**
* 解析直连商户退款结果通知
* 详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=9
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @return the wx pay refund notify result
* @throws WxPayException the wx pay exception
*/
WxPayRefundNotifyV3Result parseRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 解析服务商模式退款结果通知
* 详见https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_11.shtml
*
* @param notifyData 通知数据
* @param header 通知头部数据,不传则表示不校验头
* @return the wx pay refund notify result
* @throws WxPayException the wx pay exception
*/
WxPayPartnerRefundNotifyV3Result parsePartnerRefundNotifyV3Result(String notifyData, SignatureHeader header) throws WxPayException;
/**
* 解析扫码支付回调通知
* 详见https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
*
* @param xmlData the xml data
* @param signType 签名类型
* @return the wx scan pay notify result
* @throws WxPayException the wx pay exception
*/
WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData, String signType) throws WxPayException;
/**
* 解析扫码支付回调通知
* 详见https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
*
* @param xmlData the xml data