🆕 #1923 【微信支付】电商收付通增加添加、删除分账接收方等接口

This commit is contained in:
cloudX
2021-01-15 15:21:52 +08:00
committed by GitHub
parent ecbefea5e5
commit 43771f6048
5 changed files with 275 additions and 4 deletions

View File

@@ -0,0 +1,120 @@
package com.github.binarywang.wxpay.bean.ecommerce;
import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 添加分账接收方API
* <pre>
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_7.shtml
* </pre>
*/
@Data
@NoArgsConstructor
public class ProfitSharingReceiverRequest implements Serializable {
/**
* <pre>
* 字段名公众账号ID
* 变量名appid
* 是否必填:是
* 类型string32
* 描述:
* 电商平台的appid公众号APPID或者小程序APPID
* 示例值wx8888888888888888
* </pre>
*/
@SerializedName(value = "appid")
private String appid;
/**
* <pre>
* 字段名:接收方类型
* 变量名type
* 是否必填:是
* 类型string32
* 描述:
* 分账接收方的类型,枚举值:
* MERCHANT_ID商户
* PERSONAL_OPENID个人
* 示例值MERCHANT_ID
* </pre>
*/
@SerializedName(value = "type")
private String type;
/**
* <pre>
* 字段名:接收方账号
* 变量名account
* 是否必填:是
* 类型string64
* 描述:
* 分账接收方的账号
* 类型是MERCHANT_ID时是商户号
* 类型是PERSONAL_OPENID时是个人openidopenid获取方法
* 示例值190001001
* </pre>
*/
@SerializedName(value = "account")
private String account;
/**
* <pre>
* 字段名:接收方名称
* 变量名name
* 是否必填:是
* 类型string256
* 描述:
* 分账接收方的名称当type为MERCHANT_ID时接收方名称是商户全称。
* 示例值:张三网络公司
* </pre>
*/
@SerializedName(value = "name")
private String name;
/**
* <pre>
* 字段名:接收方名称的密文
* 变量名encrypted_name
* 是否必填:否
* 类型string10240
* 描述:
* 1、分账接收方类型是PERSONAL_OPENID时是个人姓名的密文选传传则校验
* 此字段的加密的方式为:
* 2、使用微信支付平台证书中的公钥
* 3、使用RSAES-OAEP算法进行加密
* 4、将请求中HTTP头部的Wechatpay-Serial设置为证书序列号
* 字段加密: 使用APIv3定义的方式加密
* 示例值hu89ohu89ohu89o
* </pre>
*/
@SpecEncrypt
@SerializedName(value = "encrypted_name")
private String encryptedName;
/**
* <pre>
* 字段名:与分账方的关系类型
* 变量名relation_type
* 是否必填:是
* 类型string32
* 描述:
* 子商户与接收方的关系。
* 枚举值:
* SUPPLIER供应商
* DISTRIBUTOR分销商
* SERVICE_PROVIDER服务商
* PLATFORM平台
* OTHERS其他
* 示例值SUPPLIER
* </pre>
*/
@SerializedName(value = "relation_type")
private String relationType;
}

View File

@@ -0,0 +1,44 @@
package com.github.binarywang.wxpay.bean.ecommerce;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@NoArgsConstructor
public class ProfitSharingReceiverResult implements Serializable {
/**
* <pre>
* 字段名:接收方类型
* 变量名type
* 是否必填:是
* 类型string32
* 描述:
* 分账接收方的类型,枚举值:
* MERCHANT_ID商户
* PERSONAL_OPENID个人
* 示例值MERCHANT_ID
* </pre>
*/
@SerializedName(value = "type")
private String type;
/**
* <pre>
* 字段名:接收方账号
* 变量名account
* 是否必填:是
* 类型string64
* 描述:
* 分账接收方的账号
* 类型是MERCHANT_ID时是商户号
* 类型是PERSONAL_OPENID时是个人openidopenid获取方法
* 示例值190001001
* </pre>
*/
@SerializedName(value = "account")
private String account;
}

View File

@@ -251,6 +251,30 @@ public interface EcommerceService {
*/
ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) throws WxPayException;
/**
* <pre>
* 添加分账接收方API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_7.shtml
* </pre>
*
* @param request 添加分账接收方
* @return 返回数据 profit sharing result
* @throws WxPayException the wx pay exception
*/
ProfitSharingReceiverResult addReceivers(ProfitSharingReceiverRequest request) throws WxPayException;
/**
* <pre>
* 删除分账接收方API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/profitsharing/chapter3_8.shtml
* </pre>
*
* @param request 删除分账接收方
* @return 返回数据 profit sharing result
* @throws WxPayException the wx pay exception
*/
ProfitSharingReceiverResult deleteReceivers(ProfitSharingReceiverRequest request) throws WxPayException;
/**
* <pre>
* 请求分账回退API

View File

@@ -203,6 +203,20 @@ public class EcommerceServiceImpl implements EcommerceService {
return GSON.fromJson(response, ProfitSharingResult.class);
}
@Override
public ProfitSharingReceiverResult addReceivers(ProfitSharingReceiverRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/profitsharing/receivers/add", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(request));
return GSON.fromJson(response, ProfitSharingReceiverResult.class);
}
@Override
public ProfitSharingReceiverResult deleteReceivers(ProfitSharingReceiverRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/profitsharing/receivers/delete", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(request));
return GSON.fromJson(response, ProfitSharingReceiverResult.class);
}
@Override
public ReturnOrdersResult returnOrders(ReturnOrdersRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/profitsharing/returnorders", this.payService.getPayBaseUrl());