Skip to content

Commit 6a19062

Browse files
committed
准备重构统一下单接口方法
1 parent 15e2700 commit 6a19062

File tree

3 files changed

+217
-6
lines changed

3 files changed

+217
-6
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpPayService.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import me.chanjar.weixin.mp.bean.pay.WxMpPayResult;
99
import me.chanjar.weixin.mp.bean.pay.WxRedpackResult;
1010
import me.chanjar.weixin.mp.bean.pay.WxSendRedpackRequest;
11+
import me.chanjar.weixin.mp.bean.pay.WxUnifiedOrderRequest;
1112
import me.chanjar.weixin.mp.bean.result.WxMpPrepayIdResult;
1213

1314
/**
@@ -17,7 +18,6 @@
1718
*/
1819
public interface WxMpPayService {
1920

20-
2121
/**
2222
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
2323
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
@@ -39,20 +39,30 @@ public interface WxMpPayService {
3939
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
4040
*
4141
* @param parameters All required/optional parameters for weixin payment
42+
* @deprecated use me.chanjar.weixin.mp.api.WxMpPayService.unifiedOrder(WxUnifiedOrderRequest) instead
4243
*/
44+
@Deprecated
4345
WxMpPrepayIdResult getPrepayId(Map<String, String> parameters);
4446

47+
/**
48+
* 统一下单(详见http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
49+
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
50+
* 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
51+
*
52+
*/
53+
WxMpPrepayIdResult unifiedOrder(WxUnifiedOrderRequest request);
54+
4555
/**
4656
* 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数
47-
* 详见http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82
57+
* 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
4858
*
4959
* @param parameters the required or optional parameters
5060
*/
5161
Map<String, String> getPayInfo(Map<String, String> parameters) throws WxErrorException;
5262

5363
/**
5464
* 该接口调用“统一下单”接口,并拼装NATIVE发起支付请求需要的参数
55-
* 详见http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82
65+
* 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
5666
* tradeType 交易类型 NATIVE (其他交易类型JSAPI,APP,WAP)
5767
*
5868
* @param productId 商户商品ID
@@ -61,14 +71,14 @@ public interface WxMpPayService {
6171
* @param body 商品描述
6272
* @param ip 发起支付的客户端IP
6373
* @param notifyUrl 通知地址
64-
* @deprecated Use me.chanjar.weixin.mp.api.WxMpService.getPayInfo(Map<String, String>) instead
74+
* @deprecated Use me.chanjar.weixin.mp.api.WxMpPayService.getPayInfo(Map<String, String>) instead
6575
*/
6676
@Deprecated
6777
Map<String, String> getNativePayInfo(String productId, String outTradeNo, double amt, String body, String ip, String notifyUrl) throws WxErrorException;
6878

6979
/**
7080
* 该接口调用“统一下单”接口,并拼装JSAPI发起支付请求需要的参数
71-
* 详见http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82
81+
* 详见http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
7282
* tradeType 交易类型 JSAPI(其他交易类型NATIVE,APP,WAP)
7383
*
7484
* @param openId 支付人openId
@@ -77,7 +87,7 @@ public interface WxMpPayService {
7787
* @param body 商品描述
7888
* @param ip 发起支付的客户端IP
7989
* @param notifyUrl 通知地址
80-
* @deprecated Use me.chanjar.weixin.mp.api.WxMpService.getPayInfo(Map<String, String>) instead
90+
* @deprecated Use me.chanjar.weixin.mp.api.WxMpPayService.getPayInfo(Map<String, String>) instead
8191
*/
8292
@Deprecated
8393
Map<String, String> getJsapiPayInfo(String openId, String outTradeNo, double amt, String body, String ip, String notifyUrl) throws WxErrorException;
@@ -137,6 +147,7 @@ public interface WxMpPayService {
137147
* </pre>
138148
* <partnerId></partnerId>微信商户平台ID
139149
* <partnerKey></partnerKey>商户平台设置的API密钥
150+
* @deprecated use me.chanjar.weixin.mp.api.WxMpPayService.sendRedpack(WxSendRedpackRequest) instead
140151
*
141152
*/
142153
@Deprecated

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public WxMpPayServiceImpl(WxMpServiceImpl wxMpService) {
5656
}
5757

5858
@Override
59+
@Deprecated
5960
public WxMpPrepayIdResult getPrepayId(String openId, String outTradeNo,
6061
double amt, String body, String tradeType, String ip,
6162
String callbackUrl) {
@@ -144,6 +145,7 @@ private void checkParameters(Map<String, String> parameters) {
144145
}
145146

146147
@Override
148+
@Deprecated
147149
public Map<String, String> getJsapiPayInfo(String openId, String outTradeNo,
148150
double amt, String body, String ip, String callbackUrl)
149151
throws WxErrorException {
@@ -164,6 +166,7 @@ public Map<String, String> getJsapiPayInfo(String openId, String outTradeNo,
164166
}
165167

166168
@Override
169+
@Deprecated
167170
public Map<String, String> getNativePayInfo(String productId,
168171
String outTradeNo, double amt, String body, String ip, String callbackUrl)
169172
throws WxErrorException {
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
package me.chanjar.weixin.mp.bean.pay;
2+
3+
import com.thoughtworks.xstream.annotations.XStreamAlias;
4+
5+
/**
6+
* 统一下单请求参数对象
7+
* Created by Binary Wang on 2016/9/25.
8+
* @author binarywang (https://github.com/binarywang)
9+
*/
10+
@XStreamAlias("xml")
11+
public class WxUnifiedOrderRequest {
12+
/**
13+
* <pre>
14+
* 公众账号ID
15+
* appid
16+
* 是
17+
* String(32)
18+
* wxd678efh567hg6787
19+
* 微信分配的公众账号ID(企业号corpid即为此appId)
20+
* </pre>
21+
*/
22+
/**
23+
* <pre>
24+
* 商户号
25+
* mch_id
26+
* 是
27+
* String(32)
28+
* 1230000109
29+
* 微信支付分配的商户号
30+
* </pre>
31+
*/
32+
/**
33+
* <pre>
34+
* 设备号
35+
* device_info
36+
* 否
37+
* String(32)
38+
* 013467007045764
39+
* 终端设备号(门店号或收银设备ID),注意:PC网页或公众号内支付请传"WEB"
40+
* </pre>
41+
*/
42+
/**
43+
* <pre>
44+
* 随机字符串
45+
* nonce_str
46+
* 是
47+
* String(32)
48+
* 5K8264ILTKCH16CQ2502SI8ZNMTM67VS
49+
* 随机字符串,不长于32位。推荐随机数生成算法
50+
* </pre>
51+
*/
52+
/**
53+
* <pre>
54+
* 签名
55+
* sign
56+
* 是
57+
* String(32)
58+
* C380BEC2BFD727A4B6845133519F3AD6
59+
* 签名,详见签名生成算法
60+
* </pre>
61+
*/
62+
/**
63+
* <pre>
64+
* 商品描述
65+
* body
66+
* 是
67+
* String(128)
68+
* 腾讯充值中心-QQ会员充值
69+
* 商品简单描述,该字段须严格按照规范传递,具体请见参数规定
70+
* </pre>
71+
*/
72+
/**
73+
* <pre>
74+
* 商品详情
75+
* detail
76+
* 否
77+
* String(6000)
78+
* { "goods_detail":[
79+
{
80+
"goods_id":"iphone6s_16G",
81+
"wxpay_goods_id":"1001",
82+
"goods_name":"iPhone6s 16G",
83+
"goods_num":1,
84+
"price":528800,
85+
"goods_category":"123456",
86+
"body":"苹果手机"
87+
},
88+
{
89+
"goods_id":"iphone6s_32G",
90+
"wxpay_goods_id":"1002",
91+
"goods_name":"iPhone6s 32G",
92+
"quantity":1,
93+
"price":608800,
94+
"goods_category":"123789",
95+
"body":"苹果手机"
96+
}
97+
]
98+
}
99+
商品详细列表,使用Json格式,传输签名前请务必使用CDATA标签将JSON文本串保护起来。
100+
goods_detail []:
101+
└ goods_id String 必填 32 商品的编号
102+
└ wxpay_goods_id String 可选 32 微信支付定义的统一商品编号
103+
└ goods_name String 必填 256 商品名称
104+
└ goods_num Int 必填 商品数量
105+
└ price Int 必填 商品单价,单位为分
106+
└ goods_category String 可选 32 商品类目ID
107+
└ body String 可选 1000 商品描述信息
108+
* </pre>
109+
*/
110+
/**
111+
* <pre>
112+
* 附加数据
113+
* attach
114+
* 否
115+
* String(127)
116+
* 深圳分店
117+
* 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
118+
* </pre>
119+
*/
120+
/**
121+
* <pre>
122+
* 商户订单号
123+
* out_trade_no
124+
* 是
125+
* String(32)
126+
* 20150806125346
127+
* 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
128+
* </pre>
129+
*/
130+
/**
131+
* <pre>
132+
* 货币类型
133+
* fee_type
134+
* 否
135+
* String(16)
136+
* CNY
137+
* 符合ISO 4217标准的三位字母代码,默认人民币:CNY,其他值列表详见货币类型
138+
* </pre>
139+
*/
140+
/**
141+
* <pre>
142+
* 总金额
143+
* total_fee
144+
* 是
145+
* Int
146+
* 888
147+
* 订单总金额,单位为分,详见支付金额
148+
* </pre>
149+
*/
150+
/**
151+
* <pre>
152+
* 终端IP
153+
* spbill_create_ip
154+
* 是
155+
* String(16)
156+
* 123.12.12.123
157+
* APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
158+
* </pre>
159+
*/
160+
/**
161+
* <pre> 交易起始时间 time_start 否 String(14) 20091225091010 订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。其他详见时间规则
162+
* </pre>
163+
*/
164+
/**
165+
* <pre> 交易结束时间 time_expire 否 String(14) 20091227091010
166+
* </pre>
167+
*/
168+
/**
169+
* <pre> 订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则
170+
* 注意:最短失效时间间隔必须大于5分钟
171+
* </pre>
172+
*/
173+
/**
174+
* <pre> 商品标记 goods_tag 否 String(32) WXG 商品标记,代金券或立减优惠功能的参数,说明详见代金券或立减优惠
175+
* </pre>
176+
*/
177+
/**
178+
* <pre> 通知地址 notify_url 是 String(256) http://www.weixin.qq.com/wxpay/pay.php 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
179+
* </pre>
180+
*/
181+
/**
182+
* <pre> 交易类型 trade_type 是 String(16) JSAPI 取值如下:JSAPI,NATIVE,APP,详细说明见参数规定
183+
* </pre>
184+
*/
185+
/**
186+
* <pre> 商品ID product_id 否 String(32) 12235413214070356458058 trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。
187+
* </pre>
188+
*/
189+
/**
190+
* <pre> 指定支付方式 limit_pay 否 String(32) no_credit no_credit--指定不能使用信用卡支付
191+
* </pre>
192+
*/
193+
/**
194+
* <pre> 用户标识 openid 否 String(128) oUpF8uMuAJO_M2pxb1Q9zNjWeS6o trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。openid如何获取,可参考【获取openid】。企业号请使用【企业号OAuth2.0接口】获取企业号内成员userid,再调用【企业号userid转openid接口】进行转换
195+
* </pre>
196+
*/
197+
}

0 commit comments

Comments
 (0)