🆕 #1667 微信支付增加电商收付通-二级商户进件相关接口

电商收付通二级商户进件

Co-authored-by: 曾浩 <epdcgsi@dingtalk.com>
This commit is contained in:
cloudX
2020-08-18 10:19:16 +08:00
committed by GitHub
parent a2783832d4
commit 17c20422e2
9 changed files with 1274 additions and 5 deletions

View File

@@ -0,0 +1,55 @@
package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
import com.github.binarywang.wxpay.exception.WxPayException;
/**
* <pre>
* 电商收付通相关服务类.
* 接口规则https://wechatpay-api.gitbook.io/wechatpay-api-v3
* </pre>
*
* @author cloudX
* @date 2020/08/17
*/
public interface EcommerceService {
/**
* <pre>
* 二级商户进件API
* 接口地址: https://api.mch.weixin.qq.com/v3/ecommerce/applyments/
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_1.shtml
*
* </pre>
*
* @param request 请求对象
* @return .
*/
ApplymentsResult createApply(ApplymentsRequest request) throws WxPayException;
/**
* <pre>
* 查询申请状态API
* 请求URL: https://api.mch.weixin.qq.com/v3/ecommerce/applyments/{applyment_id}
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_2.shtml
* </pre>
*
* @param applymentId 申请单ID
* @return .
*/
ApplymentsStatusResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException;
/**
* <pre>
* 查询申请状态API
* 请求URL: https://api.mch.weixin.qq.com/v3/ecommerce/applyments/out-request-no/{out_request_no}
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/applyments/chapter3_2.shtml
* </pre>
*
* @param outRequestNo 业务申请编号
* @return .
*/
ApplymentsStatusResult queryApplyStatusByOutRequestNo(String outRequestNo) throws WxPayException;
}

View File

@@ -126,6 +126,12 @@ public interface WxPayService {
*/
PayScoreService getPayScoreService();
/**
* 获取电商收付通服务类
* @return
*/
EcommerceService getEcommerceService();
/**
* 设置企业付款服务类,允许开发者自定义实现类.
*

View File

@@ -62,6 +62,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
private ProfitSharingService profitSharingService = new ProfitSharingServiceImpl(this);
private RedpackService redpackService = new RedpackServiceImpl(this);
private PayScoreService payScoreService = new PayScoreServiceImpl(this);
private EcommerceService ecommerceService = new EcommerceServiceImpl(this);
/**
* The Config.
@@ -88,6 +89,11 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
return this.redpackService;
}
@Override
public EcommerceService getEcommerceService() {
return ecommerceService;
}
@Override
public void setEntPayService(EntPayService entPayService) {
this.entPayService = entPayService;

View File

@@ -0,0 +1,52 @@
package com.github.binarywang.wxpay.service.impl;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.EcommerceService;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.URI;
public class EcommerceServiceImpl implements EcommerceService {
private static final Gson GSON = new GsonBuilder().create();
private WxPayService payService;
/**
*
* @param payService
*/
public EcommerceServiceImpl(WxPayService payService) {
this.payService = payService;
}
@Override
public ApplymentsResult createApply(ApplymentsRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/applyments/", this.payService.getPayBaseUrl());
RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
String result = this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(result, ApplymentsResult.class);
}
@Override
public ApplymentsStatusResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException {
String url = String.format("%s/v3/ecommerce/applyments/%s", this.payService.getPayBaseUrl(), applymentId);
String result = this.payService.getV3(URI.create(url));
return GSON.fromJson(result, ApplymentsStatusResult.class);
}
@Override
public ApplymentsStatusResult queryApplyStatusByOutRequestNo(String outRequestNo) throws WxPayException {
String url = String.format("%s/v3/ecommerce/applyments/out-request-no/%s", this.payService.getPayBaseUrl(), outRequestNo);
String result = this.payService.getV3(URI.create(url));
return GSON.fromJson(result, ApplymentsStatusResult.class);
}
}