Skip to content

Commit 34a974b

Browse files
committed
binarywang#392 微信支付增加企业付款到银行卡的相关接口
1 parent 230fc9f commit 34a974b

14 files changed

Lines changed: 449 additions & 100 deletions

File tree

weixin-java-pay/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
<artifactId>commons-beanutils</artifactId>
4040
<version>1.9.3</version>
4141
</dependency>
42+
<dependency>
43+
<groupId>org.bouncycastle</groupId>
44+
<artifactId>bcprov-jdk16</artifactId>
45+
<version>1.46</version>
46+
</dependency>
4247

4348
<dependency>
4449
<groupId>ch.qos.logback</groupId>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package com.github.binarywang.wxpay.bean.entpay;
2+
3+
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
4+
import com.github.binarywang.wxpay.exception.WxPayException;
5+
import com.thoughtworks.xstream.annotations.XStreamAlias;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.EqualsAndHashCode;
9+
import me.chanjar.weixin.common.annotation.Required;
10+
11+
/**
12+
* <pre>
13+
* 企业付款到银行卡的请求对象类
14+
* Created by BinaryWang on 2017/12/20.
15+
* </pre>
16+
*
17+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
18+
*/
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@Builder
22+
@XStreamAlias("xml")
23+
public class EntPayBankRequest extends BaseWxPayRequest {
24+
25+
/**
26+
* <pre>
27+
* 字段名:商户企业付款单号
28+
* 变量名:partner_trade_no
29+
* 是否必填:是
30+
* 示例值:1212121221227
31+
* 类型:string(32)
32+
* 描述:商户订单号,需保持唯一(只允许数字[0~9]或字母[A~Z]和[a~z],最短8位,最长32位)
33+
*/
34+
@Required
35+
@XStreamAlias("partner_trade_no")
36+
private String partnerTradeNo;
37+
38+
/**
39+
* <pre>
40+
* 字段名:收款方银行卡号
41+
* 变量名:enc_bank_no
42+
* 是否必填:是
43+
* 示例值:8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f
44+
* 类型:string(64)
45+
* 描述:收款方银行卡号(采用标准RSA算法,公钥由微信侧提供),详见获取RSA加密公钥API
46+
*/
47+
@Required
48+
@XStreamAlias("enc_bank_no")
49+
private String encBankNo;
50+
51+
/**
52+
* <pre>
53+
* 字段名:收款方用户名
54+
* 变量名:enc_true_name
55+
* 是否必填:是
56+
* 示例值:ca775af5f841bdf424b2e6eb86a6e21e
57+
* 类型:string(64)
58+
* 描述:收款方用户名(采用标准RSA算法,公钥由微信侧提供)详见获取RSA加密公钥API
59+
*/
60+
@Required
61+
@XStreamAlias("enc_true_name")
62+
private String encTrueName;
63+
64+
/**
65+
* <pre>
66+
* 字段名:收款方开户行
67+
* 变量名:bank_code
68+
* 是否必填:是
69+
* 示例值:1001
70+
* 类型:string(64)
71+
* 描述:银行卡所在开户行编号,详见银行编号列表
72+
*/
73+
@Required
74+
@XStreamAlias("bank_code")
75+
private String bankCode;
76+
77+
/**
78+
* <pre>
79+
* 字段名:付款金额
80+
* 变量名:amount
81+
* 是否必填:是
82+
* 示例值:100000
83+
* 类型:int
84+
* 描述:付款金额:RMB分(支付总额,不含手续费) 注:大于0的整数
85+
*/
86+
@Required
87+
@XStreamAlias("amount")
88+
private Integer amount;
89+
90+
/**
91+
* <pre>
92+
* 字段名:付款说明
93+
* 变量名:desc
94+
* 是否必填:否
95+
* 示例值:理财
96+
* 类型:string
97+
* 描述:企业付款到银行卡付款说明,即订单备注(UTF8编码,允许100个字符以内)
98+
*/
99+
@Required
100+
@XStreamAlias("desc")
101+
private String description;
102+
103+
@Override
104+
protected void checkConstraints() throws WxPayException {
105+
106+
}
107+
108+
@Override
109+
protected boolean ignoreAppid() {
110+
return true;
111+
}
112+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.github.binarywang.wxpay.bean.entpay;
2+
3+
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
import lombok.NoArgsConstructor;
8+
9+
/**
10+
* <pre>
11+
* 企业付款到银行卡的响应结果
12+
* Created by Binary Wang on 2017/12/21.
13+
* </pre>
14+
*
15+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
16+
*/
17+
@Data
18+
@EqualsAndHashCode(callSuper = true)
19+
@NoArgsConstructor
20+
@XStreamAlias("xml")
21+
public class EntPayBankResult extends BaseWxPayResult {
22+
/**
23+
* 代付金额.
24+
*/
25+
@XStreamAlias("amount")
26+
private Integer amount;
27+
28+
/**
29+
* 商户企业付款单号.
30+
*/
31+
@XStreamAlias("partner_trade_no")
32+
private String partnerTradeNo;
33+
34+
//############以下字段在return_code 和result_code都为SUCCESS的时候有返回##############
35+
/**
36+
* 微信企业付款单号.
37+
* 代付成功后,返回的内部业务单号
38+
*/
39+
@XStreamAlias("payment_no")
40+
private String paymentNo;
41+
42+
/**
43+
* 手续费金额.
44+
* RMB:分
45+
*/
46+
@XStreamAlias("cmms_amt")
47+
private String cmmsAmount;
48+
49+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.binarywang.wxpay.bean.entpay;
2+
3+
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
4+
import com.thoughtworks.xstream.annotations.XStreamAlias;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
/**
9+
* <pre>
10+
* 企业付款获取RSA加密公钥接口返回结果类
11+
* Created by BinaryWang on 2017/12/20.
12+
* </pre>
13+
*
14+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
15+
*/
16+
@Data
17+
@EqualsAndHashCode(callSuper = true)
18+
@XStreamAlias("xml")
19+
public class GetPublicKeyResult extends BaseWxPayResult {
20+
/**
21+
* 商户号.
22+
*/
23+
@XStreamAlias("mch_id")
24+
private String mchId;
25+
26+
/**
27+
* 密钥
28+
*/
29+
@XStreamAlias("pub_key")
30+
private String pubKey;
31+
}

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/BaseWxPayRequest.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ public String toXML() {
182182
return xstream.toXML(this);
183183
}
184184

185+
/**
186+
* 签名时,是否忽略signType
187+
*/
188+
protected boolean ignoreSignType() {
189+
return false;
190+
}
191+
192+
/**
193+
* 签名时,是否忽略appid
194+
*/
195+
protected boolean ignoreAppid() {
196+
return false;
197+
}
198+
185199
/**
186200
* <pre>
187201
* 检查参数,并设置签名
@@ -190,14 +204,15 @@ public String toXML() {
190204
* 3、生成签名,并设置进去
191205
* </pre>
192206
*
193-
* @param config 支付配置对象,用于读取相应系统配置信息
194-
* @param isIgnoreSignType 签名时,是否忽略signType
207+
* @param config 支付配置对象,用于读取相应系统配置信息
195208
*/
196-
public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException {
209+
public void checkAndSign(WxPayConfig config) throws WxPayException {
197210
this.checkFields();
198211

199-
if (StringUtils.isBlank(getAppid())) {
200-
this.setAppid(config.getAppId());
212+
if (!ignoreAppid()) {
213+
if (StringUtils.isBlank(getAppid())) {
214+
this.setAppid(config.getAppId());
215+
}
201216
}
202217

203218
if (StringUtils.isBlank(getMchId())) {
@@ -229,7 +244,6 @@ public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws Wx
229244

230245
//设置签名字段的值
231246
this.setSign(SignUtils.createSign(this, this.getSignType(), config.getMchKey(),
232-
isIgnoreSignType));
247+
this.ignoreSignType()));
233248
}
234-
235249
}

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayQueryCommentRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
@AllArgsConstructor
2121
@XStreamAlias("xml")
2222
public class WxPayQueryCommentRequest extends BaseWxPayRequest {
23+
@Override
24+
protected boolean ignoreSignType() {
25+
return true;
26+
}
27+
2328
/**
2429
* <pre>
2530
* 字段名:开始时间

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayRefundRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ public class WxPayRefundRequest extends BaseWxPayRequest {
157157
private String refundDesc;
158158

159159
@Override
160-
public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException {
160+
public void checkAndSign(WxPayConfig config) throws WxPayException {
161161
if (StringUtils.isBlank(this.getOpUserId())) {
162162
this.setOpUserId(config.getMchId());
163163
}
164164

165-
super.checkAndSign(config, isIgnoreSignType);
165+
super.checkAndSign(config);
166166
}
167167

168168
@Override

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ protected void checkConstraints() throws WxPayException {
349349
}
350350

351351
@Override
352-
public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws WxPayException {
352+
public void checkAndSign(WxPayConfig config) throws WxPayException {
353353
if (StringUtils.isBlank(this.getNotifyURL())) {
354354
this.setNotifyURL(config.getNotifyUrl());
355355
}
@@ -358,7 +358,7 @@ public void checkAndSign(WxPayConfig config, boolean isIgnoreSignType) throws Wx
358358
this.setTradeType(config.getTradeType());
359359
}
360360

361-
super.checkAndSign(config, isIgnoreSignType);
361+
super.checkAndSign(config);
362362
}
363363

364364
}

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/EntPaySerivce.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)