Skip to content

Commit 3f42a16

Browse files
authored
🆕 #2257【微信支付】增加微信签约代扣相关接口
1 parent ed6bd01 commit 3f42a16

22 files changed

+3014
-0
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.github.binarywang.wxpay.exception.WxPayException;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.*;
6+
import me.chanjar.weixin.common.annotation.Required;
7+
8+
import java.util.Map;
9+
10+
/**
11+
* @author chenliang
12+
* @date 2021-08-02 5:12 下午
13+
*
14+
* <pre>
15+
* 微信h5纯签约入参
16+
* </pre>
17+
*/
18+
@Data
19+
@EqualsAndHashCode(callSuper = true)
20+
@Builder(builderMethodName = "newBuilder")
21+
@NoArgsConstructor
22+
@AllArgsConstructor
23+
@XStreamAlias("xml")
24+
public class WxH5EntrustRequest extends BaseWxPayRequest {
25+
26+
/**
27+
* <pre>
28+
* 协议模板ID
29+
* plan_id
30+
* 是
31+
* String(28)
32+
* 12535
33+
* 协议模板ID,分为首次签约,支付中签约,重新签约
34+
* </pre>
35+
*/
36+
@Required
37+
@XStreamAlias("plan_id")
38+
private String planId;
39+
40+
/**
41+
* <pre>
42+
* 签约协议号
43+
* contract_code
44+
* 是
45+
* String(32)
46+
* 100000
47+
* 商户侧签约协议号,由商户生成,只能是数字,大小写字母组成
48+
* </pre>
49+
*/
50+
@Required
51+
@XStreamAlias("contract_code")
52+
private String contractCode;
53+
54+
/**
55+
* <pre>
56+
* 请求序列号
57+
* request_serial
58+
* 是
59+
* int(64)
60+
* 1000
61+
* 商户请求签约时的序列号,要求唯一性,禁止使用0开头的,用户排序,纯数字
62+
* </pre>
63+
*/
64+
@Required
65+
@XStreamAlias("request_serial")
66+
private Long requestSerial;
67+
68+
/**
69+
* <pre>
70+
* 用户账户展示名称
71+
* contract_display_account
72+
* 是
73+
* string(32)
74+
* 微信代扣
75+
* 签约用户的名称,用户页面展示,不支持符号表情
76+
* </pre>
77+
*/
78+
@Required
79+
@XStreamAlias("contract_display_account")
80+
private String contractDisplayAccount;
81+
82+
/**
83+
* <pre>
84+
* 回调通知URL
85+
* notify_url
86+
* 是
87+
* string(256)
88+
* https://weixin.qq.com
89+
* 用于接收签约成功消息的回调通知地址
90+
* </pre>
91+
*/
92+
@Required
93+
@XStreamAlias("notify_url")
94+
private String notifyUrl;
95+
96+
/**
97+
* <pre>
98+
* 版本号
99+
* sign
100+
* 是
101+
* string(8)
102+
* 1.0
103+
* 固定值1.0
104+
* </pre>
105+
*/
106+
@Required
107+
@XStreamAlias("version")
108+
private String version;
109+
110+
/**
111+
* <pre>
112+
* 时间戳
113+
* timestamp
114+
* 是
115+
* string(10)
116+
* 1414488825
117+
* 系统当前时间,10位
118+
* </pre>
119+
*/
120+
@Required
121+
@XStreamAlias("timestamp")
122+
private String timestamp;
123+
124+
/**
125+
* <pre>
126+
* 客户端IP
127+
* clientip
128+
* 是
129+
* string(32)
130+
* 127.0.0.1
131+
* 用户客户端的IP地址
132+
* </pre>
133+
*/
134+
@Required
135+
@XStreamAlias("clientip")
136+
private String clientIp;
137+
138+
/**
139+
* <pre>
140+
* 回调应用appid
141+
* return_appid
142+
* 否
143+
* string(32)
144+
* wxcbda96de0b16
145+
* 用来控制签约页面结束后的返回路径,
146+
* 当指定该字段是,签约成功将返回return_appid指定的APP应用,如果不填且签约发起的浏览器ua可被微信识别,
147+
* 则挑战到浏览器,否则留在微信
148+
* </pre>
149+
*/
150+
@XStreamAlias("return_appid")
151+
private String returnAppid;
152+
153+
/**
154+
* <pre>
155+
* 商户测用户标识
156+
* outerid
157+
* 否
158+
* string(32)
159+
* 陈*(10000001)
160+
* 用于多账号签约,值与contract_display_account一样就行
161+
* </pre>
162+
*/
163+
@XStreamAlias("outerid")
164+
private String outerId;
165+
166+
167+
/**
168+
* 是否需要nonce_str
169+
*/
170+
@Override
171+
protected boolean needNonceStr() {
172+
return false;
173+
}
174+
175+
@Override
176+
protected void checkConstraints() throws WxPayException {
177+
178+
}
179+
180+
@Override
181+
protected void storeMap(Map<String, String> map) {
182+
map.put("plan_id", planId);
183+
map.put("contract_code", contractCode);
184+
map.put("request_serial", String.valueOf(requestSerial));
185+
map.put("contract_display_account", contractDisplayAccount);
186+
map.put("notify_url", notifyUrl);
187+
map.put("version", version);
188+
map.put("timestamp", timestamp);
189+
map.put("clientip", clientIp);
190+
map.put("return_appid", returnAppid);
191+
map.put("outerid", outerId);
192+
}
193+
}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
package com.github.binarywang.wxpay.bean.request;
2+
3+
import com.github.binarywang.wxpay.exception.WxPayException;
4+
import com.google.gson.FieldNamingPolicy;
5+
import com.google.gson.Gson;
6+
import com.google.gson.GsonBuilder;
7+
import com.google.gson.annotations.SerializedName;
8+
import com.thoughtworks.xstream.annotations.XStreamAlias;
9+
import lombok.*;
10+
import me.chanjar.weixin.common.annotation.Required;
11+
12+
import java.util.Map;
13+
14+
/**
15+
* @author chenliang
16+
* @date 2021-08-02 5:13 下午
17+
* <pre>
18+
* 小程序纯签约入参
19+
* </pre>
20+
*/
21+
@Data
22+
@EqualsAndHashCode(callSuper = true)
23+
@Builder(builderMethodName = "newBuilder")
24+
@NoArgsConstructor
25+
@AllArgsConstructor
26+
@XStreamAlias("xml")
27+
public class WxMaEntrustRequest extends BaseWxPayRequest {
28+
/**
29+
* <pre>
30+
* 协议模板ID
31+
* plan_id
32+
* 是
33+
* String(28)
34+
* 12535
35+
* 协议模板ID,分为首次签约,支付中签约,重新签约
36+
* </pre>
37+
*/
38+
@Required
39+
@SerializedName(value = "plan_id")
40+
@XStreamAlias("plan_id")
41+
private String planId;
42+
43+
/**
44+
* <pre>
45+
* 签约协议号
46+
* contract_code
47+
* 是
48+
* String(32)
49+
* 100000
50+
* 商户侧签约协议号,由商户生成,只能是数字,大小写字母组成
51+
* </pre>
52+
*/
53+
@Required
54+
@SerializedName(value = "contract_code")
55+
@XStreamAlias("contract_code")
56+
private String contractCode;
57+
58+
/**
59+
* <pre>
60+
* 请求序列号
61+
* request_serial
62+
* 是
63+
* int(64)
64+
* 1000
65+
* 商户请求签约时的序列号,要求唯一性,禁止使用0开头的,用户排序,纯数字
66+
* </pre>
67+
*/
68+
@Required
69+
@SerializedName(value = "request_serial")
70+
@XStreamAlias("request_serial")
71+
private Long requestSerial;
72+
73+
/**
74+
* <pre>
75+
* 用户账户展示名称
76+
* contract_display_account
77+
* 是
78+
* string(32)
79+
* 微信代扣
80+
* 签约用户的名称,用户页面展示,不支持符号表情
81+
* </pre>
82+
*/
83+
@Required
84+
@SerializedName(value = "contract_display_account")
85+
@XStreamAlias("contract_display_account")
86+
private String contractDisplayAccount;
87+
88+
/**
89+
* <pre>
90+
* 回调通知URL
91+
* notify_url
92+
* 是
93+
* string(256)
94+
* https://weixin.qq.com
95+
* 用于接收签约成功消息的回调通知地址
96+
* </pre>
97+
*/
98+
@Required
99+
@SerializedName(value = "notify_url")
100+
@XStreamAlias("notify_url")
101+
private String notifyUrl;
102+
103+
/**
104+
* <pre>
105+
* 版本号
106+
* sign
107+
* 是
108+
* string(8)
109+
* 1.0
110+
* 固定值1.0
111+
* </pre>
112+
*/
113+
@Required
114+
@XStreamAlias("version")
115+
private String version;
116+
117+
118+
/**
119+
* <pre>
120+
* 时间戳
121+
* timestamp
122+
* 是
123+
* string(10)
124+
* 1414488825
125+
* 系统当前时间,10位
126+
* </pre>
127+
*/
128+
@Required
129+
@XStreamAlias("timestamp")
130+
private String timestamp;
131+
132+
/**
133+
* <pre>
134+
* 商户侧用户标识
135+
* outerId
136+
* 否
137+
* String
138+
* 陈*(141448825)
139+
* 用户在商户侧的标识
140+
* </pre>
141+
*/
142+
@XStreamAlias("outerid")
143+
private String outerId;
144+
145+
@Override
146+
protected void checkConstraints() throws WxPayException {
147+
148+
}
149+
150+
/**
151+
* 是否需要nonce_str
152+
*/
153+
@Override
154+
protected boolean needNonceStr() {
155+
return false;
156+
}
157+
158+
@Override
159+
protected void storeMap(Map<String, String> map) {
160+
map.put("plan_id", planId);
161+
map.put("contract_code", contractCode);
162+
map.put("request_serial", String.valueOf(requestSerial));
163+
map.put("contract_display_account", contractDisplayAccount);
164+
map.put("notify_url", notifyUrl);
165+
map.put("timestamp", timestamp);
166+
map.put("outerid", outerId);
167+
}
168+
169+
@Override
170+
public String toString() {
171+
GsonBuilder gsonBuilder = new GsonBuilder();
172+
173+
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
174+
175+
Gson gson = gsonBuilder.create();
176+
177+
return gson.toJson(this);
178+
}
179+
}

0 commit comments

Comments
 (0)