删除分账接收方

更新时间:2025.08.21

服务商发起删除分账接收方请求。删除后,不再支持品牌主或门店分到该分账接收方。

接口说明

支持商户:【普通服务商】

请求方式:【POST】/v3/brand/profitsharing/receivers/delete

请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点

     【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看

请求参数

Header  HTTP头参数

 Authorization  必填 string

请参考签名认证生成认证信息


 Accept  必填 string

请设置为application/json


 Content-Type  必填 string

请设置为application/json


body  包体参数

 brand_mchid  必填   string(32)

【品牌主商户号】 品牌主商户号,即绑定具体品牌的商户号,填写微信支付分配的商户号


 appid  必填   string(32)

【公众账号ID】 微信分配的公众账号ID


 sub_appid  选填   string(32)

【子商户公众账号ID】 品牌主的公众账号ID,分账接收方类型包含PERSONAL_SUB_OPENID时必填


 type  必填   string(32)

【接收方类型】 分账接收方类型,枚举值:

  1. MERCHANT_ID:商户号(mch_id或者sub_mch_id)

  2. PERSONAL_OPENID:个人OpenID(由服务商的AppID转换得到)

  3. PERSONAL_SUB_OPENID:个人OpenID(由品牌主的AppID转换得到)


 account  必填   string(64)

【接收方账号】 分账接收方账号

  1. 分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号(mch_id或者sub_mch_id)

  2. 分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人OpenID(由服务商的AppID转换得到)

  3. 分账接收方类型为PERSONAL_SUB_OPENID时,分账接收方账号为个人OpenID(由品牌主的AppID转换得到)

请求示例

Java
Go
curl

需配合微信支付工具库 WXPayUtility 使用,请参考 iwiki-document:inline_state 

1package com.java.demo;
2
3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/partner/4014985777
4
5import com.google.gson.annotations.SerializedName;
6import com.google.gson.annotations.Expose;
7import okhttp3.MediaType;
8import okhttp3.OkHttpClient;
9import okhttp3.Request;
10import okhttp3.RequestBody;
11import okhttp3.Response;
12
13import java.io.IOException;
14import java.io.UncheckedIOException;
15import java.security.PrivateKey;
16import java.security.PublicKey;
17import java.util.ArrayList;
18import java.util.HashMap;
19import java.util.List;
20import java.util.Map;
21
22/**
23 * 删除分账接收方
24 */
25public class DeleteReceiver {
26  private static String HOST = "https://api.mch.weixin.qq.com";
27  private static String METHOD = "POST";
28  private static String PATH = "/v3/brand/profitsharing/receivers/delete";
29
30  public static void main(String[] args) {
31    // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340
32    DeleteReceiver client = new DeleteReceiver(
33      "19xxxxxxxx",                    // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340
34      "1DDE55AD98Exxxxxxxxxx",         // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924
35      "/path/to/apiclient_key.pem",    // 商户API证书私钥文件路径,本地文件路径
36      "PUB_KEY_ID_xxxxxxxxxxxxx",      // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589
37      "/path/to/wxp_pub.pem"           // 微信支付公钥文件路径,本地文件路径
38    );
39
40    DeleteReceiverRequest request = new DeleteReceiverRequest();
41    request.brandMchid = "1900000108";
42    request.appid = "wx8888888888888888";
43    request.subAppid = "wx8888888888888889";
44    request.type = "MERCHANT_ID";
45    request.account = "1900000109";
46    try {
47      DeleteReceiverResponse response = client.run(request);
48
49      // TODO: 请求成功,继续业务逻辑
50      System.out.println(response);
51    } catch (WXPayUtility.ApiException e) {
52      // TODO: 请求失败,根据状态码执行不同的逻辑
53      e.printStackTrace();
54    }
55  }
56
57  public DeleteReceiverResponse run(DeleteReceiverRequest request) {
58    String uri = PATH;
59    String reqBody = WXPayUtility.toJson(request);
60
61    Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
62    reqBuilder.addHeader("Accept", "application/json");
63    reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
64    reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody));
65    reqBuilder.addHeader("Content-Type", "application/json");
66    RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody);
67    reqBuilder.method(METHOD, requestBody);
68    Request httpRequest = reqBuilder.build();
69
70    // 发送HTTP请求
71    OkHttpClient client = new OkHttpClient.Builder().build();
72    try (Response httpResponse = client.newCall(httpRequest).execute()) {
73      String respBody = WXPayUtility.extractBody(httpResponse);
74      if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
75        // 2XX 成功,验证应答签名
76        WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
77            httpResponse.headers(), respBody);
78
79        // 从HTTP应答报文构建返回数据
80        return WXPayUtility.fromJson(respBody, DeleteReceiverResponse.class);
81      } else {
82        throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
83      }
84    } catch (IOException e) {
85      throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
86    }
87  }
88
89  private final String mchid;
90  private final String certificateSerialNo;
91  private final PrivateKey privateKey;
92  private final String wechatPayPublicKeyId;
93  private final PublicKey wechatPayPublicKey;
94
95  public DeleteReceiver(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
96    this.mchid = mchid;
97    this.certificateSerialNo = certificateSerialNo;
98    this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
99    this.wechatPayPublicKeyId = wechatPayPublicKeyId;
100    this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
101  }
102
103  public static class DeleteReceiverRequest {
104    @SerializedName("brand_mchid")
105    public String brandMchid;
106  
107    @SerializedName("appid")
108    public String appid;
109  
110    @SerializedName("sub_appid")
111    public String subAppid;
112  
113    @SerializedName("type")
114    public String type;
115  
116    @SerializedName("account")
117    public String account;
118  }
119  
120  public static class DeleteReceiverResponse {
121    @SerializedName("brand_mchid")
122    public String brandMchid;
123  
124    @SerializedName("type")
125    public String type;
126  
127    @SerializedName("account")
128    public String account;
129  }
130  
131}
132

应答参数

200 OK

 brand_mchid  必填   string(32)

【品牌主商户号】 品牌主商户号,即绑定具体品牌的商户号,填写微信支付分配的商户号。


 type  必填   string(32)

【接收方类型】 分账接收方类型,枚举值:

  1. MERCHANT_ID:商户ID

  2. PERSONAL_OPENID:个人OpenID(由父商户AppID转换得到)

  3. PERSONAL_SUB_OPENID:个人OpenID(由品牌主的AppID转换得到)


 account  必填   string(64)

【接收方账号】 分账接收方账号

  1. 分账接收方类型为MERCHANT_ID时,分账接收方账号为商户号(mch_id或者sub_mch_id)

  2. 分账接收方类型为PERSONAL_OPENID时,分账接收方账号为个人OpenID(由服务商的AppID转换得到)

  3. 分账接收方类型为PERSONAL_SUB_OPENID时,分账接收方账号为个人OpenID(由品牌主的AppID转换得到)

应答示例

200 OK

1{
2  "brand_mchid" : "1900000108",
3  "type" : "MERCHANT_ID",
4  "account" : "1900000109"
5}
6

 

错误码

公共错误码

状态码

错误码

描述

解决方案

400

PARAM_ERROR

参数错误

请根据错误提示正确传入参数

400

INVALID_REQUEST

HTTP 请求不符合微信支付 APIv3 接口规则

请参阅 接口规则

401

SIGN_ERROR

验证不通过

请参阅 签名常见问题

500

SYSTEM_ERROR

系统异常,请稍后重试

请稍后重试

 

更多技术问题
技术咨询
反馈
咨询
目录
置顶