获得品牌已授权且在生效中的产品权限信息
更新时间:2026.01.29获得品牌已授权且在生效中的产品权限信息
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/brand-basic/partner/brands/{brand_id}/product-authorities
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
接口限频:10/秒(商户号维度)
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
brand_id 必填 string
【品牌名称】 授权的品牌ID
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/brand-basic/partner/brands/brand_id_example/product-authorities \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
需配合微信支付工具库 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 GetBrandProducts { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/brand-basic/partner/brands/{brand_id}/product-authorities"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 GetBrandProducts client = new GetBrandProducts( 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 GetBrandProductsRequest request = new GetBrandProductsRequest(); 41 request.brandId = "brandId_example"; 42 try { 43 GetBrandProductsResponse response = client.run(request); 44 // TODO: 请求成功,继续业务逻辑 45 System.out.println(response); 46 } catch (WXPayUtility.ApiException e) { 47 // TODO: 请求失败,根据状态码执行不同的逻辑 48 e.printStackTrace(); 49 } 50 } 51 52 public GetBrandProductsResponse run(GetBrandProductsRequest request) { 53 String uri = PATH; 54 uri = uri.replace("{brand_id}", WXPayUtility.urlEncode(request.brandId)); 55 56 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 57 reqBuilder.addHeader("Accept", "application/json"); 58 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 59 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 60 reqBuilder.method(METHOD, null); 61 Request httpRequest = reqBuilder.build(); 62 63 // 发送HTTP请求 64 OkHttpClient client = new OkHttpClient.Builder().build(); 65 try (Response httpResponse = client.newCall(httpRequest).execute()) { 66 String respBody = WXPayUtility.extractBody(httpResponse); 67 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 68 // 2XX 成功,验证应答签名 69 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 70 httpResponse.headers(), respBody); 71 72 // 从HTTP应答报文构建返回数据 73 return WXPayUtility.fromJson(respBody, GetBrandProductsResponse.class); 74 } else { 75 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 76 } 77 } catch (IOException e) { 78 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 79 } 80 } 81 82 private final String mchid; 83 private final String certificateSerialNo; 84 private final PrivateKey privateKey; 85 private final String wechatPayPublicKeyId; 86 private final PublicKey wechatPayPublicKey; 87 88 public GetBrandProducts(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 89 this.mchid = mchid; 90 this.certificateSerialNo = certificateSerialNo; 91 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 92 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 93 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 94 } 95 96 public static class GetBrandProductsRequest { 97 @SerializedName("brand_id") 98 @Expose(serialize = false) 99 public String brandId; 100 } 101 102 public static class GetBrandProductsResponse { 103 @SerializedName("brand_id") 104 public String brandId; 105 106 @SerializedName("authorization_type") 107 public AuthorizationType authorizationType; 108 109 @SerializedName("authorization_product") 110 public List<BrandProductAuthority> authorizationProduct; 111 112 @SerializedName("update_time") 113 public String updateTime; 114 } 115 116 public enum AuthorizationType { 117 @SerializedName("AUTHORIZATION_TYPE_HOSTING") 118 AUTHORIZATION_TYPE_HOSTING, 119 @SerializedName("AUTHORIZATION_TYPE_PARTLY") 120 AUTHORIZATION_TYPE_PARTLY 121 } 122 123 public enum BrandProductAuthority { 124 @SerializedName("BRAND_PRODUCT_AUTHORITY_MERCHANT_CARD") 125 BRAND_PRODUCT_AUTHORITY_MERCHANT_CARD, 126 @SerializedName("BRAND_PRODUCT_AUTHORITY_CARD_LINK") 127 BRAND_PRODUCT_AUTHORITY_CARD_LINK, 128 @SerializedName("BRAND_PRODUCT_AUTHORITY_PRODUCT_COUPON") 129 BRAND_PRODUCT_AUTHORITY_PRODUCT_COUPON, 130 @SerializedName("BRAND_PRODUCT_AUTHORITY_SHAKE_COUPON") 131 BRAND_PRODUCT_AUTHORITY_SHAKE_COUPON, 132 @SerializedName("BRAND_PRODUCT_AUTHORITY_BRAND_PAY_GIFT") 133 BRAND_PRODUCT_AUTHORITY_BRAND_PAY_GIFT, 134 @SerializedName("BRAND_PRODUCT_AUTHORITY_BRAND_STORE") 135 BRAND_PRODUCT_AUTHORITY_BRAND_STORE, 136 @SerializedName("BRAND_PRODUCT_AUTHORITY_PAYMENT_MERCHANT_MANAGE") 137 BRAND_PRODUCT_AUTHORITY_PAYMENT_MERCHANT_MANAGE, 138 @SerializedName("BRAND_PRODUCT_AUTHORITY_APPID_MANAGE") 139 BRAND_PRODUCT_AUTHORITY_APPID_MANAGE, 140 @SerializedName("BRAND_PRODUCT_AUTHORITY_FINDER_MANAGE") 141 BRAND_PRODUCT_AUTHORITY_FINDER_MANAGE, 142 @SerializedName("BRAND_PRODUCT_AUTHORITY_CATEGORY_MANAGE") 143 BRAND_PRODUCT_AUTHORITY_CATEGORY_MANAGE 144 } 145 146} 147
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9 "strings" 10 "time" 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 := &GetBrandProductsRequest{ 28 BrandId: wxpay_utility.String("BrandId_example"), 29 } 30 31 response, err := GetBrandProducts(config, request) 32 if err != nil { 33 fmt.Printf("请求失败: %+v\n", err) 34 // TODO: 请求失败,根据状态码执行不同的处理 35 return 36 } 37 38 // TODO: 请求成功,继续业务逻辑 39 fmt.Printf("请求成功: %+v\n", response) 40} 41 42func GetBrandProducts(config *wxpay_utility.MchConfig, request *GetBrandProductsRequest) (response *GetBrandProductsResponse, err error) { 43 const ( 44 host = "https://api.mch.weixin.qq.com" 45 method = "GET" 46 path = "/v3/brand-basic/partner/brands/{brand_id}/product-authorities" 47 ) 48 49 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 50 if err != nil { 51 return nil, err 52 } 53 reqUrl.Path = strings.Replace(reqUrl.Path, "{brand_id}", url.PathEscape(*request.BrandId), -1) 54 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 55 if err != nil { 56 return nil, err 57 } 58 httpRequest.Header.Set("Accept", "application/json") 59 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 60 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest.Header.Set("Authorization", authorization) 65 66 client := &http.Client{} 67 httpResponse, err := client.Do(httpRequest) 68 if err != nil { 69 return nil, err 70 } 71 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 72 if err != nil { 73 return nil, err 74 } 75 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 76 // 2XX 成功,验证应答签名 77 err = wxpay_utility.ValidateResponse( 78 config.WechatPayPublicKeyId(), 79 config.WechatPayPublicKey(), 80 &httpResponse.Header, 81 respBody, 82 ) 83 if err != nil { 84 return nil, err 85 } 86 response := &GetBrandProductsResponse{} 87 if err := json.Unmarshal(respBody, response); err != nil { 88 return nil, err 89 } 90 91 return response, nil 92 } else { 93 return nil, wxpay_utility.NewApiException( 94 httpResponse.StatusCode, 95 httpResponse.Header, 96 respBody, 97 ) 98 } 99} 100 101type GetBrandProductsRequest struct { 102 BrandId *string `json:"brand_id,omitempty"` 103} 104 105func (o *GetBrandProductsRequest) MarshalJSON() ([]byte, error) { 106 type Alias GetBrandProductsRequest 107 a := &struct { 108 BrandId *string `json:"brand_id,omitempty"` 109 *Alias 110 }{ 111 // 序列化时移除非 Body 字段 112 BrandId: nil, 113 Alias: (*Alias)(o), 114 } 115 return json.Marshal(a) 116} 117 118type GetBrandProductsResponse struct { 119 BrandId *string `json:"brand_id,omitempty"` 120 AuthorizationType *AuthorizationType `json:"authorization_type,omitempty"` 121 AuthorizationProduct []BrandProductAuthority `json:"authorization_product,omitempty"` 122 UpdateTime *time.Time `json:"update_time,omitempty"` 123} 124 125type AuthorizationType string 126 127func (e AuthorizationType) Ptr() *AuthorizationType { 128 return &e 129} 130 131const ( 132 AUTHORIZATIONTYPE_AUTHORIZATION_TYPE_HOSTING AuthorizationType = "AUTHORIZATION_TYPE_HOSTING" 133 AUTHORIZATIONTYPE_AUTHORIZATION_TYPE_PARTLY AuthorizationType = "AUTHORIZATION_TYPE_PARTLY" 134) 135 136type BrandProductAuthority string 137 138func (e BrandProductAuthority) Ptr() *BrandProductAuthority { 139 return &e 140} 141 142const ( 143 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_MERCHANT_CARD BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_MERCHANT_CARD" 144 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_CARD_LINK BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_CARD_LINK" 145 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_PRODUCT_COUPON BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_PRODUCT_COUPON" 146 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_SHAKE_COUPON BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_SHAKE_COUPON" 147 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_BRAND_PAY_GIFT BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_BRAND_PAY_GIFT" 148 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_BRAND_STORE BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_BRAND_STORE" 149 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_PAYMENT_MERCHANT_MANAGE BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_PAYMENT_MERCHANT_MANAGE" 150 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_APPID_MANAGE BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_APPID_MANAGE" 151 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_FINDER_MANAGE BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_FINDER_MANAGE" 152 BRANDPRODUCTAUTHORITY_BRAND_PRODUCT_AUTHORITY_CATEGORY_MANAGE BrandProductAuthority = "BRAND_PRODUCT_AUTHORITY_CATEGORY_MANAGE" 153) 154
应答参数
200 OK
brand_id 必填 string
【品牌ID】 授权的品牌ID
authorization_type 必填 string
【授权类型】 授权类型
可选取值
AUTHORIZATION_TYPE_HOSTING: 全托管模式AUTHORIZATION_TYPE_PARTLY: 部分授权
authorization_product 选填 array[string]
【授权产品权限】 品牌已授权产品权限
可选取值
BRAND_PRODUCT_AUTHORITY_MERCHANT_CARD: 商家名片产品权限BRAND_PRODUCT_AUTHORITY_CARD_LINK: 交易连接名片产品权限BRAND_PRODUCT_AUTHORITY_PRODUCT_COUPON: 商品券产品权限BRAND_PRODUCT_AUTHORITY_SHAKE_COUPON: 摇优惠产品权限BRAND_PRODUCT_AUTHORITY_BRAND_PAY_GIFT: 品牌支付有礼产品权限BRAND_PRODUCT_AUTHORITY_BRAND_STORE: 品牌门店产品权限BRAND_PRODUCT_AUTHORITY_PAYMENT_MERCHANT_MANAGE: 收款商户号管理产品权限BRAND_PRODUCT_AUTHORITY_APPID_MANAGE: 下单AppID管理产品权限BRAND_PRODUCT_AUTHORITY_FINDER_MANAGE: 视频号管理产品权限BRAND_PRODUCT_AUTHORITY_CATEGORY_MANAGE: 品类管理产品
update_time 必填 string
【更新时间】 产品权限更新时间,为微信支付记录的权限数据更新时间。格式:遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。yyyy-MM-DD 表示年月日;T 字符用于分隔日期和时间部分;HH:mm:ss 表示具体的时分秒;TIMEZONE 表示时区(例如,+08:00 对应东八区时间,即北京时间)。示例:2025-05-20T13:29:35+08:00 表示北京时间2025年5月20日13点29分35秒。
应答示例
200 OK
1{ 2 "brand_id" : "example_brand_id", 3 "authorization_type" : "AUTHORIZATION_TYPE_HOSTING", 4 "authorization_product" : [ 5 "BRAND_PRODUCT_AUTHORITY_MERCHANT_CARD" 6 ], 7 "update_time" : "2025-05-20T13:29:35+08:00" 8} 9
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
429 | FREQUENCY_LIMITED | 请求过快,达到接口频率限制 | 请降低请求频率 |
400 | INVALID_REQUEST | 异常错误,请重试,如反复出现,可联系微信支付技术支持获取更多帮助 | 异常错误,请重试,如反复出现,可联系微信支付技术支持获取更多帮助 |
403 | NO_AUTH | 无操作权限,请开通品牌经营管理权限 | 请开通品牌经营管理权限 |
400 | PARAM_ERROR | 品牌ID错误,或未建立授权关系 | 请先与品牌建立授权关系 |

