File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed 
main/java/com/github/binarywang/wxpay 
test/java/com/github/binarywang/wxpay/service/impl Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,13 @@ public class WxWithholdNotifyResult extends BaseWxPayResult {
6262 @ XStreamAlias ("is_subscribe" )
6363 private  String  isSubscribe ;
6464
65+  /** 
66+  * 是否关注子商户关联的公众号 
67+  * 非必传 
68+  */ 
69+  @ XStreamAlias ("sub_is_subscribe" )
70+  private  String  subIsSubscribe ;
71+ 
6572 /** 
6673 * 付款银行 
6774 */ 
@@ -191,6 +198,7 @@ protected void loadXml(Document d) {
191198 deviceInfo  = readXmlString (d , "device_info" );
192199 openId  = readXmlString (d , "openid" );
193200 isSubscribe  = readXmlString (d , "is_subscribe" );
201+  subIsSubscribe  = readXmlString (d , "sub_is_subscribe" );
194202 subOpenId  = readXmlString (d , "sub_openid" );
195203 bankType  = readXmlString (d , "bank_type" );
196204 totalFee  = readXmlInteger (d , "total_fee" );
Original file line number Diff line number Diff line change @@ -86,6 +86,24 @@ public interface WxEntrustPapService {
8686 */ 
8787 WxWithholdResult  withhold (WxWithholdRequest  wxWithholdRequest ) throws  WxPayException ;
8888
89+  /** 
90+  * 服务商模式的申请扣款 
91+  * <pre> 
92+  * 申请扣款 
93+  * 详见:<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> 
94+  * 请求微信发起委托扣款,扣款额度和次数由使用的签约模板限制, 
95+  * 该扣款接口是立即扣款 无延时 扣款前无消息通知。 
96+  * 
97+  * • 特殊情况:周期扣费为通知后24小时扣费方式情况下,如果用户为首次签约(包含解约后重新签约), 
98+  * 从用户签约成功时间开始算,商户在12小时内发起的扣款,会被立即执行,无延迟。商户超过12小时以后发起的扣款,都按24小时扣费规则执行 
99+  * </pre> 
100+  * 
101+  * @param wxWithholdRequest the wx withhold request 
102+  * @return wx withhold result 
103+  * @throws WxPayException the wx pay exception 
104+  */ 
105+  WxPayCommonResult  withholdPartner (WxWithholdRequest  wxWithholdRequest ) throws  WxPayException ;
106+ 
89107 /** 
90108 * 预扣费通知 
91109 * <pre> 
Original file line number Diff line number Diff line change @@ -101,6 +101,16 @@ public WxWithholdResult withhold(WxWithholdRequest wxWithholdRequest) throws WxP
101101 return  result ;
102102 }
103103
104+  @ Override 
105+  public  WxPayCommonResult  withholdPartner (WxWithholdRequest  wxWithholdRequest ) throws  WxPayException  {
106+  wxWithholdRequest .checkAndSign (payService .getConfig ());
107+  String  url  = payService .getPayBaseUrl () + "/pay/partner/pappayapply" ;
108+  String  responseContent  = payService .post (url , wxWithholdRequest .toXML (), false );
109+  WxPayCommonResult  result  = BaseWxPayResult .fromXML (responseContent , WxPayCommonResult .class );
110+  result .checkResult (payService , wxWithholdRequest .getSignType (), true );
111+  return  result ;
112+  }
113+ 
104114 @ Override 
105115 public  String  preWithhold (WxPreWithholdRequest  wxPreWithholdRequest ) throws  WxPayException  {
106116 String  requestParam  = WxGsonBuilder .create ().toJson (wxPreWithholdRequest );
Original file line number Diff line number Diff line change @@ -177,6 +177,31 @@ public void testWithhold() {
177177 }
178178 }
179179
180+  @ Test 
181+  public  void  testWithholdPartner () {
182+  String  outTradeNo  = "101010101" ;
183+  WxWithholdRequest  withholdRequest  = WxWithholdRequest .newBuilder ()
184+  .attach ("local" )
185+  .body ("产品名字" )
186+  .contractId ("202011065409471222" ) // 微信返回的签约协议号 
187+  .detail ("产品描述" )
188+  .feeType ("CNY" )
189+  //.goodsTag() 
190+  .notifyUrl ("http://domain.com/api/wxpay/withhold/callback.do" )
191+  .outTradeNo (outTradeNo )
192+  .spbillCreateIp ("127.0.0.1" )
193+  .totalFee (1 )
194+  .tradeType ("PAP" )
195+  .build ();
196+ 
197+  try  {
198+  WxPayCommonResult  wxPayCommonResult  = this .payService .getWxEntrustPapService ().withholdPartner (withholdRequest );
199+  logger .info (wxPayCommonResult .toString ());
200+  } catch  (WxPayException  e ) {
201+  e .printStackTrace ();
202+  }
203+  }
204+ 
180205 @ Test 
181206 public  void  testPreWithhold () {
182207 WxPreWithholdRequest .EstimateAmount  estimateAmount  = new  WxPreWithholdRequest .EstimateAmount ();
                                 You can’t perform that action at this time. 
               
                  
0 commit comments