删除品牌门店
更新时间:2025.08.04根据品牌门店ID,删除品牌门店。
频率限制:5/s
接口说明
支持商户:【品牌商户】
请求方式:【DELETE】/brand/store/brandstores/{store_id}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Wechatpay-Serial 必填 string
【微信支付公钥ID】 请传入brand_id对应的微信支付公钥ID,接口将会校验两者的关联关系,参考微信支付公钥产品简介及使用说明获取微信支付公钥ID和相关的介绍。以下两种场景将使用到微信支付公钥: 1、接收到接口的返回内容,需要使用微信支付公钥进行验签; 2、调用含有敏感信息参数(如姓名、身份证号码)的接口时,需要使用微信支付公钥加密敏感信息后再传输参数,加密指引请参考微信支付公钥加密敏感信息指引。
path 路径参数
store_id 必填 string
【品牌门店ID】 创建品牌门店后,系统为该门店分配的唯一ID。
请求示例
DELETE
1curl -X DELETE \ 2 https://api.mch.weixin.qq.com/brand/store/brandstores/1234567890123456 \ 3 -H "Authorization: WECHATPAY-BRAND-SHA256-RSA2048 brand_id=\"XXXX\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: PUB_KEY_ID_XXXX" 6
需配合微信支付工具库 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 DeleteBrandStore { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "DELETE"; 28 private static String PATH = "/brand/store/brandstores/{store_id}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 32 DeleteBrandStore client = new DeleteBrandStore( 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 DeleteBrandStoreRequest request = new DeleteBrandStoreRequest(); 41 request.storeId = "1234567890123456"; 42 try { 43 client.run(request); 44 } catch (WXPayBrandUtility.ApiException e) { 45 // TODO: 请求失败,根据状态码执行不同的逻辑 46 e.printStackTrace(); 47 } 48 } 49 50 public void run(DeleteBrandStoreRequest request) { 51 String uri = PATH; 52 uri = uri.replace("{store_id}", WXPayBrandUtility.urlEncode(request.storeId)); 53 54 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 55 reqBuilder.addHeader("Accept", "application/json"); 56 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 57 reqBuilder.addHeader("Authorization", WXPayBrandUtility.buildAuthorization(brand_id, certificateSerialNo, privateKey, METHOD, uri, null)); 58 reqBuilder.method(METHOD, null); 59 Request httpRequest = reqBuilder.build(); 60 61 // 发送HTTP请求 62 OkHttpClient client = new OkHttpClient.Builder().build(); 63 try (Response httpResponse = client.newCall(httpRequest).execute()) { 64 String respBody = WXPayBrandUtility.extractBody(httpResponse); 65 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 66 // 2XX 成功,验证应答签名 67 WXPayBrandUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 68 httpResponse.headers(), respBody); 69 70 return; 71 } else { 72 throw new WXPayBrandUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 73 } 74 } catch (IOException e) { 75 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 76 } 77 } 78 79 private final String brand_id; 80 private final String certificateSerialNo; 81 private final PrivateKey privateKey; 82 private final String wechatPayPublicKeyId; 83 private final PublicKey wechatPayPublicKey; 84 85 public DeleteBrandStore(String brand_id, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 86 this.brand_id = brand_id; 87 this.certificateSerialNo = certificateSerialNo; 88 this.privateKey = WXPayBrandUtility.loadPrivateKeyFromPath(privateKeyFilePath); 89 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 90 this.wechatPayPublicKey = WXPayBrandUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 91 } 92 93 public static class DeleteBrandStoreRequest { 94 @SerializedName("store_id") 95 @Expose(serialize = false) 96 public String storeId; 97 } 98 99} 100
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_brand_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/brand/4015826866 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9 "strings" 10) 11 12func main() { 13 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 14 config, err := wxpay_brand_utility.CreateBrandConfig( 15 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 16 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 17 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 18 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 19 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 20 ) 21 if err != nil { 22 fmt.Println(err) 23 return 24 } 25 26 request := &DeleteBrandStoreRequest{ 27 StoreId: wxpay_brand_utility.String("1234567890123456"), 28 } 29 30 err = DeleteBrandStore(config, request) 31 if err != nil { 32 fmt.Printf("请求失败: %+v\n", err) 33 // TODO: 请求失败,根据状态码执行不同的处理 34 return 35 } 36 37 // TODO: 请求成功,继续业务逻辑 38 fmt.Println("请求成功") 39} 40 41func DeleteBrandStore(config *wxpay_brand_utility.BrandConfig, request *DeleteBrandStoreRequest) (err error) { 42 const ( 43 host = "https://api.mch.weixin.qq.com" 44 method = "DELETE" 45 path = "/brand/store/brandstores/{store_id}" 46 ) 47 48 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 49 if err != nil { 50 return err 51 } 52 reqUrl.Path = strings.Replace(reqUrl.Path, "{store_id}", url.PathEscape(*request.StoreId), -1) 53 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 54 if err != nil { 55 return err 56 } 57 httpRequest.Header.Set("Accept", "application/json") 58 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 59 authorization, err := wxpay_brand_utility.BuildAuthorization(config.BrandId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 60 if err != nil { 61 return err 62 } 63 httpRequest.Header.Set("Authorization", authorization) 64 65 client := &http.Client{} 66 httpResponse, err := client.Do(httpRequest) 67 if err != nil { 68 return err 69 } 70 respBody, err := wxpay_brand_utility.ExtractResponseBody(httpResponse) 71 if err != nil { 72 return err 73 } 74 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 75 // 2XX 成功,验证应答签名 76 err = wxpay_brand_utility.ValidateResponse( 77 config.WechatPayPublicKeyId(), 78 config.WechatPayPublicKey(), 79 &httpResponse.Header, 80 respBody, 81 ) 82 if err != nil { 83 return err 84 } 85 return nil 86 } else { 87 return wxpay_brand_utility.NewApiException( 88 httpResponse.StatusCode, 89 httpResponse.Header, 90 respBody, 91 ) 92 } 93} 94 95type DeleteBrandStoreRequest struct { 96 StoreId *string `json:"store_id,omitempty"` 97} 98 99func (o *DeleteBrandStoreRequest) MarshalJSON() ([]byte, error) { 100 type Alias DeleteBrandStoreRequest 101 a := &struct { 102 StoreId *string `json:"store_id,omitempty"` 103 *Alias 104 }{ 105 // 序列化时移除非 Body 字段 106 StoreId: nil, 107 Alias: (*Alias)(o), 108 } 109 return json.Marshal(a) 110} 111
应答参数
无应答包体
应答示例
204 No Content
1'无应答包体' 2
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
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 | 系统异常,请稍后重试 | 请稍后使用原参数重试 |

