解绑收款商户号
更新时间:2025.08.04解绑品牌门店的收款商户号。解绑成功后,商户号不能再为门店收款。
接口说明
支持商户:【普通服务商】
请求方式:【POST】/v3/brand/partner/store/brandstores/{store_id}/unbindrecipient
请求域名:【主域名】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
path 路径参数
store_id 必填 string
【品牌门店ID】 创建品牌门店后,系统为该门店分配的唯一ID。
body 包体参数
brand_id 必填 string
【品牌ID】 商家进驻微信支付品牌商家后获得的品牌ID。
mchid 必填 string(16)
【门店收款商户号】 希望解绑的门店收款商户号,仅支持解绑收款绑定状态为“已绑定”的商户号。
请求示例
Java
Go
curl
需配合微信支付工具库 WXPayUtility 使用,请参考 Java
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 UnbindRecipient { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/brand/partner/store/brandstores/{store_id}/unbindrecipient"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 UnbindRecipient client = new UnbindRecipient( 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 UnbindRecipientRequest request = new UnbindRecipientRequest(); 41 request.storeId = "1234567890123456"; 42 request.brandId = "123456789"; 43 request.mchid = "1230000109"; 44 try { 45 BrandStoresUnbindRecipientResponse response = client.run(request); 46 47 // TODO: 请求成功,继续业务逻辑 48 System.out.println(response); 49 } catch (WXPayUtility.ApiException e) { 50 // TODO: 请求失败,根据状态码执行不同的逻辑 51 e.printStackTrace(); 52 } 53 } 54 55 public BrandStoresUnbindRecipientResponse run(UnbindRecipientRequest request) { 56 String uri = PATH; 57 uri = uri.replace("{store_id}", WXPayUtility.urlEncode(request.storeId)); 58 String reqBody = WXPayUtility.toJson(request); 59 60 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 61 reqBuilder.addHeader("Accept", "application/json"); 62 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 63 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 64 reqBuilder.addHeader("Content-Type", "application/json"); 65 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 66 reqBuilder.method(METHOD, requestBody); 67 Request httpRequest = reqBuilder.build(); 68 69 // 发送HTTP请求 70 OkHttpClient client = new OkHttpClient.Builder().build(); 71 try (Response httpResponse = client.newCall(httpRequest).execute()) { 72 String respBody = WXPayUtility.extractBody(httpResponse); 73 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 74 // 2XX 成功,验证应答签名 75 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 76 httpResponse.headers(), respBody); 77 78 // 从HTTP应答报文构建返回数据 79 return WXPayUtility.fromJson(respBody, BrandStoresUnbindRecipientResponse.class); 80 } else { 81 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 82 } 83 } catch (IOException e) { 84 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 85 } 86 } 87 88 private final String mchid; 89 private final String certificateSerialNo; 90 private final PrivateKey privateKey; 91 private final String wechatPayPublicKeyId; 92 private final PublicKey wechatPayPublicKey; 93 94 public UnbindRecipient(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 95 this.mchid = mchid; 96 this.certificateSerialNo = certificateSerialNo; 97 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 98 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 99 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 100 } 101 102 public static class UnbindRecipientRequest { 103 @SerializedName("brand_id") 104 public String brandId; 105 106 @SerializedName("store_id") 107 @Expose(serialize = false) 108 public String storeId; 109 110 @SerializedName("mchid") 111 public String mchid; 112 } 113 114 public static class BrandStoresUnbindRecipientResponse { 115 @SerializedName("failed_reason") 116 public String failedReason; 117 } 118 119} 120
需配合微信支付工具库 wxpay_utility 使用,请参考 Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 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/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &UnbindRecipientRequest{ 28 StoreId: wxpay_utility.String("1234567890123456"), 29 BrandId: wxpay_utility.String("123456789"), 30 Mchid: wxpay_utility.String("1230000109"), 31 } 32 33 response, err := UnbindRecipient(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 UnbindRecipient(config *wxpay_utility.MchConfig, request *UnbindRecipientRequest) (response *BrandStoresUnbindRecipientResponse, err error) { 45 const ( 46 host = "https://api.mch.weixin.qq.com" 47 method = "POST" 48 path = "/v3/brand/partner/store/brandstores/{store_id}/unbindrecipient" 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_utility.BuildAuthorization(config.MchId(), 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 79 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 80 if err != nil { 81 return nil, err 82 } 83 84 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 85 // 2XX 成功,验证应答签名 86 err = wxpay_utility.ValidateResponse( 87 config.WechatPayPublicKeyId(), 88 config.WechatPayPublicKey(), 89 &httpResponse.Header, 90 respBody, 91 ) 92 if err != nil { 93 return nil, err 94 } 95 96 response := &BrandStoresUnbindRecipientResponse{} 97 if err := json.Unmarshal(respBody, response); err != nil { 98 return nil, err 99 } 100 101 return response, nil 102 } else { 103 return nil, wxpay_utility.NewApiException( 104 httpResponse.StatusCode, 105 httpResponse.Header, 106 respBody, 107 ) 108 } 109} 110 111type UnbindRecipientRequest struct { 112 BrandId *string `json:"brand_id,omitempty"` 113 StoreId *string `json:"store_id,omitempty"` 114 Mchid *string `json:"mchid,omitempty"` 115} 116 117func (o *UnbindRecipientRequest) MarshalJSON() ([]byte, error) { 118 type Alias UnbindRecipientRequest 119 a := &struct { 120 StoreId *string `json:"store_id,omitempty"` 121 *Alias 122 }{ 123 // 序列化时移除非 Body 字段 124 StoreId: nil, 125 Alias: (*Alias)(o), 126 } 127 return json.Marshal(a) 128} 129 130type BrandStoresUnbindRecipientResponse struct { 131 FailedReason *string `json:"failed_reason,omitempty"` 132} 133
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/brand/partner/store/brandstores/1234567890123456/unbindrecipient \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "brand_id" : "123456789", 8 "mchid" : "1230000109" 9 }' 10
应答参数
200 OK
failed_reason 选填 string
【解绑失败原因】 解绑失败原因
应答示例
200 OK
1{ 2 "failed_reason" : "example_failed_reason" 3} 4
错误码
公共错误码
文档是否有帮助