绑定收款商户号
更新时间:2025.08.04给品牌门店绑定收款商户号。绑定成功后,商户号可为门店收款。一个门店目前最多只能绑定三个收款商户号。
频率限制:5/s
接口说明
支持商户:【品牌商户】
请求方式:【POST】/brand/store/brandstores/{store_id}/bindrecipient
请求域名:【主域名】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
Wechatpay-Serial 必填 string
【微信支付公钥ID】 请传入brand_id对应的微信支付公钥ID,接口将会校验两者的关联关系,参考微信支付公钥产品简介及使用说明获取微信支付公钥ID和相关的介绍。以下两种场景将使用到微信支付公钥: 1、接收到接口的返回内容,需要使用微信支付公钥进行验签; 2、调用含有敏感信息参数(如姓名、身份证号码)的接口时,需要使用微信支付公钥加密敏感信息后再传输参数,加密指引请参考微信支付公钥加密敏感信息指引。
path 路径参数
store_id 必填 string
【品牌门店ID】 创建品牌门店后,系统为该门店分配的唯一ID。
body 包体参数
mchid 必填 string(16)
【门店收款商户号】 门店的收款商户号,仅允许填入品牌已关联的商户号,若未关联请先前往“品牌经营平台-账号管理-收款商户号管理”添加商户号。
company_name 必填 string(256)
【门店收款主体】 门店收款的主体信息,支持企业,个体户,小微。
请求示例
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/brand/store/brandstores/1234567890123456/bindrecipient \ 3 -H "Authorization: WECHATPAY-BRAND-SHA256-RSA2048 brand_id=\"XXXX\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: PUB_KEY_ID_XXXX" \ 6 -H "Content-Type: application/json" \ 7 -d '{ 8 "mchid" : "1230000109", 9 "company_name" : "腾讯科技(深圳)有限公司" 10 }' 11
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayBrandUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/brand/4015826861 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 BindRecipient { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/brand/store/brandstores/{store_id}/bindrecipient"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 32 BindRecipient client = new BindRecipient( 33 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 34 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 35 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 BindRecipientRequest request = new BindRecipientRequest(); 41 request.storeId = "1234567890123456"; 42 request.mchid = "1230000109"; 43 request.companyName = "腾讯科技(深圳)有限公司"; 44 try { 45 BrandStoresBindRecipientResponse response = client.run(request); 46 // TODO: 请求成功,继续业务逻辑 47 System.out.println(response); 48 } catch (WXPayBrandUtility.ApiException e) { 49 // TODO: 请求失败,根据状态码执行不同的逻辑 50 e.printStackTrace(); 51 } 52 } 53 54 public BrandStoresBindRecipientResponse run(BindRecipientRequest request) { 55 String uri = PATH; 56 uri = uri.replace("{store_id}", WXPayBrandUtility.urlEncode(request.storeId)); 57 String reqBody = WXPayBrandUtility.toJson(request); 58 59 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 60 reqBuilder.addHeader("Accept", "application/json"); 61 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 62 reqBuilder.addHeader("Authorization", WXPayBrandUtility.buildAuthorization(brand_id, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 63 reqBuilder.addHeader("Content-Type", "application/json"); 64 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 65 reqBuilder.method(METHOD, requestBody); 66 Request httpRequest = reqBuilder.build(); 67 68 // 发送HTTP请求 69 OkHttpClient client = new OkHttpClient.Builder().build(); 70 try (Response httpResponse = client.newCall(httpRequest).execute()) { 71 String respBody = WXPayBrandUtility.extractBody(httpResponse); 72 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 73 // 2XX 成功,验证应答签名 74 WXPayBrandUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 75 httpResponse.headers(), respBody); 76 77 // 从HTTP应答报文构建返回数据 78 return WXPayBrandUtility.fromJson(respBody, BrandStoresBindRecipientResponse.class); 79 } else { 80 throw new WXPayBrandUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 81 } 82 } catch (IOException e) { 83 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 84 } 85 } 86 87 private final String brand_id; 88 private final String certificateSerialNo; 89 private final PrivateKey privateKey; 90 private final String wechatPayPublicKeyId; 91 private final PublicKey wechatPayPublicKey; 92 93 public BindRecipient(String brand_id, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 94 this.brand_id = brand_id; 95 this.certificateSerialNo = certificateSerialNo; 96 this.privateKey = WXPayBrandUtility.loadPrivateKeyFromPath(privateKeyFilePath); 97 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 98 this.wechatPayPublicKey = WXPayBrandUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 99 } 100 101 public static class BindRecipientRequest { 102 @SerializedName("store_id") 103 @Expose(serialize = false) 104 public String storeId; 105 106 @SerializedName("mchid") 107 public String mchid; 108 109 @SerializedName("company_name") 110 public String companyName; 111 } 112 113 public static class BrandStoresBindRecipientResponse { 114 @SerializedName("store_id") 115 public String storeId; 116 117 @SerializedName("mchid") 118 public String mchid; 119 120 @SerializedName("company_name") 121 public String companyName; 122 123 @SerializedName("recipient_state") 124 public RecipientState recipientState; 125 } 126 127 public enum RecipientState { 128 @SerializedName("CONFIRMED") 129 CONFIRMED, 130 @SerializedName("ADMIN_REJECTED") 131 ADMIN_REJECTED, 132 @SerializedName("CONFIRMING") 133 CONFIRMING, 134 @SerializedName("TIMEOUT_REJECTED") 135 TIMEOUT_REJECTED 136 } 137 138} 139
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_brand_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/brand/4015826866 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 10 "strings" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 15 config, err := wxpay_brand_utility.CreateBrandConfig( 16 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 17 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 18 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &BindRecipientRequest{ 28 StoreId: wxpay_brand_utility.String("1234567890123456"), 29 Mchid: wxpay_brand_utility.String("1230000109"), 30 CompanyName: wxpay_brand_utility.String("腾讯科技(深圳)有限公司"), 31 } 32 33 response, err := BindRecipient(config, request) 34 if err != nil { 35 fmt.Printf("请求失败: %+v\n", err) 36 // TODO: 请求失败,根据状态码执行不同的处理 37 return 38 } 39 40 // TODO: 请求成功,继续业务逻辑 41 fmt.Printf("请求成功: %+v\n", response) 42} 43 44func BindRecipient(config *wxpay_brand_utility.BrandConfig, request *BindRecipientRequest) (response *BrandStoresBindRecipientResponse, err error) { 45 const ( 46 host = "https://api.mch.weixin.qq.com" 47 method = "POST" 48 path = "/brand/store/brandstores/{store_id}/bindrecipient" 49 ) 50 51 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 52 if err != nil { 53 return nil, err 54 } 55 reqUrl.Path = strings.Replace(reqUrl.Path, "{store_id}", url.PathEscape(*request.StoreId), -1) 56 reqBody, err := json.Marshal(request) 57 if err != nil { 58 return nil, err 59 } 60 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest.Header.Set("Accept", "application/json") 65 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 66 httpRequest.Header.Set("Content-Type", "application/json") 67 authorization, err := wxpay_brand_utility.BuildAuthorization(config.BrandId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 68 if err != nil { 69 return nil, err 70 } 71 httpRequest.Header.Set("Authorization", authorization) 72 73 client := &http.Client{} 74 httpResponse, err := client.Do(httpRequest) 75 if err != nil { 76 return nil, err 77 } 78 respBody, err := wxpay_brand_utility.ExtractResponseBody(httpResponse) 79 if err != nil { 80 return nil, err 81 } 82 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 83 // 2XX 成功,验证应答签名 84 err = wxpay_brand_utility.ValidateResponse( 85 config.WechatPayPublicKeyId(), 86 config.WechatPayPublicKey(), 87 &httpResponse.Header, 88 respBody, 89 ) 90 if err != nil { 91 return nil, err 92 } 93 response := &BrandStoresBindRecipientResponse{} 94 if err := json.Unmarshal(respBody, response); err != nil { 95 return nil, err 96 } 97 98 return response, nil 99 } else { 100 return nil, wxpay_brand_utility.NewApiException( 101 httpResponse.StatusCode, 102 httpResponse.Header, 103 respBody, 104 ) 105 } 106} 107 108type BindRecipientRequest struct { 109 StoreId *string `json:"store_id,omitempty"` 110 Mchid *string `json:"mchid,omitempty"` 111 CompanyName *string `json:"company_name,omitempty"` 112} 113 114func (o *BindRecipientRequest) MarshalJSON() ([]byte, error) { 115 type Alias BindRecipientRequest 116 a := &struct { 117 StoreId *string `json:"store_id,omitempty"` 118 *Alias 119 }{ 120 // 序列化时移除非 Body 字段 121 StoreId: nil, 122 Alias: (*Alias)(o), 123 } 124 return json.Marshal(a) 125} 126 127type BrandStoresBindRecipientResponse struct { 128 StoreId *string `json:"store_id,omitempty"` 129 Mchid *string `json:"mchid,omitempty"` 130 CompanyName *string `json:"company_name,omitempty"` 131 RecipientState *RecipientState `json:"recipient_state,omitempty"` 132} 133 134type RecipientState string 135 136func (e RecipientState) Ptr() *RecipientState { 137 return &e 138} 139 140const ( 141 RECIPIENTSTATE_CONFIRMED RecipientState = "CONFIRMED" 142 RECIPIENTSTATE_ADMIN_REJECTED RecipientState = "ADMIN_REJECTED" 143 RECIPIENTSTATE_CONFIRMING RecipientState = "CONFIRMING" 144 RECIPIENTSTATE_TIMEOUT_REJECTED RecipientState = "TIMEOUT_REJECTED" 145) 146
应答参数
200 OK
store_id 选填 string
【品牌门店ID】 创建品牌门店后,系统为该门店分配的唯一ID。
mchid 选填 string(16)
【门店收款商户号】 门店的收款商户号,仅支持绑定品牌已关联的商户号。
company_name 选填 string(256)
【门店收款主体】 门店收款的主体信息,支持企业,个体户,小微。
recipient_state 选填 string
【收款绑定状态】 门店收款商户号的绑定状态
可选取值
CONFIRMED: 门店已绑定此收款商户号ADMIN_REJECTED: 商户管理员已拒绝CONFIRMING: 商户号管理员确认中TIMEOUT_REJECTED: 由于商户管理员确认超时,系统自动拒绝此绑定
应答示例
200 OK
1{ 2 "store_id" : "1234567890123456", 3 "mchid" : "1230000109", 4 "company_name" : "腾讯科技(深圳)有限公司", 5 "recipient_state" : "CONFIRMED" 6} 7
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
400 | PARAM_ERROR | 门店状态暂不支持修改 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
404 | NOT_FOUND | 品牌门店不存在 | 请确认门店存在且属于该品牌 |
400 | PARAM_ERROR | 参数错误 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
429 | RATELIMIT_EXCEEDED | 请求超过频率限制 | 请稍后使用原参数重试 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后使用原参数重试 |

