diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java index 86c487a8c..288e8b933 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxWithholdNotifyResult.java @@ -62,6 +62,13 @@ public class WxWithholdNotifyResult extends BaseWxPayResult { @XStreamAlias("is_subscribe") private String isSubscribe; + /** + * 是否关注子商户关联的公众号 + * 非必传 + */ + @XStreamAlias("sub_is_subscribe") + private String subIsSubscribe; + /** * 付款银行 */ @@ -191,6 +198,7 @@ public class WxWithholdNotifyResult extends BaseWxPayResult { deviceInfo = readXmlString(d, "device_info"); openId = readXmlString(d, "openid"); isSubscribe = readXmlString(d, "is_subscribe"); + subIsSubscribe = readXmlString(d, "sub_is_subscribe"); subOpenId = readXmlString(d, "sub_openid"); bankType = readXmlString(d, "bank_type"); totalFee = readXmlInteger(d, "total_fee"); diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java index 24a5c3bec..168e43696 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/WxEntrustPapService.java @@ -86,6 +86,24 @@ public interface WxEntrustPapService { */ WxWithholdResult withhold(WxWithholdRequest wxWithholdRequest) throws WxPayException; + /** + * 服务商模式的申请扣款 + *
+ * 申请扣款 + * 详见:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter5_8.shtml + * 请求微信发起委托扣款,扣款额度和次数由使用的签约模板限制, + * 该扣款接口是立即扣款 无延时 扣款前无消息通知。 + * + * • 特殊情况:周期扣费为通知后24小时扣费方式情况下,如果用户为首次签约(包含解约后重新签约), + * 从用户签约成功时间开始算,商户在12小时内发起的扣款,会被立即执行,无延迟。商户超过12小时以后发起的扣款,都按24小时扣费规则执行 + *+ * + * @param wxWithholdRequest the wx withhold request + * @return wx withhold result + * @throws WxPayException the wx pay exception + */ + WxPayCommonResult withholdPartner(WxWithholdRequest wxWithholdRequest) throws WxPayException; + /** * 预扣费通知 *
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java
index 0b4dba893..951c1d5a8 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java
@@ -101,6 +101,16 @@ public class WxEntrustPapServiceImpl implements WxEntrustPapService {
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
public String preWithhold(WxPreWithholdRequest wxPreWithholdRequest) throws WxPayException {
String requestParam = WxGsonBuilder.create().toJson(wxPreWithholdRequest);
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java
index 6be405897..ca20d0c51 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceTest.java
@@ -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
public void testPreWithhold() {
WxPreWithholdRequest.EstimateAmount estimateAmount = new WxPreWithholdRequest.EstimateAmount();