mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-08 06:37:46 +08:00
🆕【微信支付】支持服务商模式的扣款服务接口
This commit is contained in:
parent
b83435281d
commit
59074bae86
@ -62,6 +62,13 @@ public class WxWithholdNotifyResult extends BaseWxPayResult {
|
|||||||
@XStreamAlias("is_subscribe")
|
@XStreamAlias("is_subscribe")
|
||||||
private String isSubscribe;
|
private String isSubscribe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否关注子商户关联的公众号
|
||||||
|
* 非必传
|
||||||
|
*/
|
||||||
|
@XStreamAlias("sub_is_subscribe")
|
||||||
|
private String subIsSubscribe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 付款银行
|
* 付款银行
|
||||||
*/
|
*/
|
||||||
@ -191,6 +198,7 @@ public class WxWithholdNotifyResult extends BaseWxPayResult {
|
|||||||
deviceInfo = readXmlString(d, "device_info");
|
deviceInfo = readXmlString(d, "device_info");
|
||||||
openId = readXmlString(d, "openid");
|
openId = readXmlString(d, "openid");
|
||||||
isSubscribe = readXmlString(d, "is_subscribe");
|
isSubscribe = readXmlString(d, "is_subscribe");
|
||||||
|
subIsSubscribe = readXmlString(d, "sub_is_subscribe");
|
||||||
subOpenId = readXmlString(d, "sub_openid");
|
subOpenId = readXmlString(d, "sub_openid");
|
||||||
bankType = readXmlString(d, "bank_type");
|
bankType = readXmlString(d, "bank_type");
|
||||||
totalFee = readXmlInteger(d, "total_fee");
|
totalFee = readXmlInteger(d, "total_fee");
|
||||||
|
@ -86,6 +86,24 @@ public interface WxEntrustPapService {
|
|||||||
*/
|
*/
|
||||||
WxWithholdResult withhold(WxWithholdRequest wxWithholdRequest) throws WxPayException;
|
WxWithholdResult withhold(WxWithholdRequest wxWithholdRequest) throws WxPayException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务商模式的申请扣款
|
||||||
|
* <pre>
|
||||||
|
* 申请扣款
|
||||||
|
* 详见:<a href="https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter5_8.shtml">https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter5_8.shtml</a>
|
||||||
|
* 请求微信发起委托扣款,扣款额度和次数由使用的签约模板限制,
|
||||||
|
* 该扣款接口是立即扣款 无延时 扣款前无消息通知。
|
||||||
|
*
|
||||||
|
* • 特殊情况:周期扣费为通知后24小时扣费方式情况下,如果用户为首次签约(包含解约后重新签约),
|
||||||
|
* 从用户签约成功时间开始算,商户在12小时内发起的扣款,会被立即执行,无延迟。商户超过12小时以后发起的扣款,都按24小时扣费规则执行
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param wxWithholdRequest the wx withhold request
|
||||||
|
* @return wx withhold result
|
||||||
|
* @throws WxPayException the wx pay exception
|
||||||
|
*/
|
||||||
|
WxPayCommonResult withholdPartner(WxWithholdRequest wxWithholdRequest) throws WxPayException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预扣费通知
|
* 预扣费通知
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -101,6 +101,16 @@ public class WxEntrustPapServiceImpl implements WxEntrustPapService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxPayCommonResult withholdPartner(WxWithholdRequest wxWithholdRequest) throws WxPayException {
|
||||||
|
wxWithholdRequest.checkAndSign(payService.getConfig());
|
||||||
|
String url = payService.getPayBaseUrl() + "/pay/partner/pappayapply";
|
||||||
|
String responseContent = payService.post(url, wxWithholdRequest.toXML(), false);
|
||||||
|
WxPayCommonResult result = BaseWxPayResult.fromXML(responseContent, WxPayCommonResult.class);
|
||||||
|
result.checkResult(payService, wxWithholdRequest.getSignType(), true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String preWithhold(WxPreWithholdRequest wxPreWithholdRequest) throws WxPayException {
|
public String preWithhold(WxPreWithholdRequest wxPreWithholdRequest) throws WxPayException {
|
||||||
String requestParam = WxGsonBuilder.create().toJson(wxPreWithholdRequest);
|
String requestParam = WxGsonBuilder.create().toJson(wxPreWithholdRequest);
|
||||||
|
@ -177,6 +177,31 @@ public class WxEntrustPapServiceTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithholdPartner() {
|
||||||
|
String outTradeNo = "101010101";
|
||||||
|
WxWithholdRequest withholdRequest = WxWithholdRequest.newBuilder()
|
||||||
|
.attach("local")
|
||||||
|
.body("产品名字")
|
||||||
|
.contractId("202011065409471222") // 微信返回的签约协议号
|
||||||
|
.detail("产品描述")
|
||||||
|
.feeType("CNY")
|
||||||
|
//.goodsTag()
|
||||||
|
.notifyUrl("http://domain.com/api/wxpay/withhold/callback.do")
|
||||||
|
.outTradeNo(outTradeNo)
|
||||||
|
.spbillCreateIp("127.0.0.1")
|
||||||
|
.totalFee(1)
|
||||||
|
.tradeType("PAP")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
WxPayCommonResult wxPayCommonResult = this.payService.getWxEntrustPapService().withholdPartner(withholdRequest);
|
||||||
|
logger.info(wxPayCommonResult.toString());
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreWithhold() {
|
public void testPreWithhold() {
|
||||||
WxPreWithholdRequest.EstimateAmount estimateAmount = new WxPreWithholdRequest.EstimateAmount();
|
WxPreWithholdRequest.EstimateAmount estimateAmount = new WxPreWithholdRequest.EstimateAmount();
|
||||||
|
Loading…
Reference in New Issue
Block a user