查询会员卡模板列表
更新时间:2025.08.01通过此接口可查询指定某品牌的所有会员卡模板列表
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/brand/partner/card-member/cards
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
接口限频:100/秒(商户号维度)
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
query 查询参数
brand_id 必填 string(32)
【品牌ID】 商家进驻微信支付品牌商家后获得的品牌ID(灰度期间联系微信支付运营获取),用于标记该会员卡的归属方
state 选填 string
【状态】 会员卡状态信息
可选取值
CARD_EFFECTIVE: 生效中CARD_INVALID: 已失效
offset 必填 integer
【分页开始位置】 该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回。
limit 必填 integer
【分页大小】 分页大小,范围为1~20
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/brand/partner/card-member/cards?brand_id=1004&state=CARD_EFFECTIVE&offset=0&limit=20 \ 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 ListCard { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/brand/partner/card-member/cards"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 ListCard client = new ListCard( 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 ListCardRequest request = new ListCardRequest(); 41 request.brandId = "1004"; 42 request.state = CardState.CARD_EFFECTIVE; 43 request.offset = 0L; 44 request.limit = 20L; 45 try { 46 ListCardResponse response = client.run(request); 47 // TODO: 请求成功,继续业务逻辑 48 System.out.println(response); 49 } catch (WXPayUtility.ApiException e) { 50 // TODO: 请求失败,根据状态码执行不同的逻辑 51 e.printStackTrace(); 52 } 53 } 54 55 public ListCardResponse run(ListCardRequest request) { 56 String uri = PATH; 57 Map<String, Object> args = new HashMap<>(); 58 args.put("brand_id", request.brandId); 59 args.put("state", request.state); 60 args.put("offset", request.offset); 61 args.put("limit", request.limit); 62 String queryString = WXPayUtility.urlEncode(args); 63 if (!queryString.isEmpty()) { 64 uri = uri + "?" + queryString; 65 } 66 67 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 68 reqBuilder.addHeader("Accept", "application/json"); 69 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 70 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 71 reqBuilder.method(METHOD, null); 72 Request httpRequest = reqBuilder.build(); 73 74 // 发送HTTP请求 75 OkHttpClient client = new OkHttpClient.Builder().build(); 76 try (Response httpResponse = client.newCall(httpRequest).execute()) { 77 String respBody = WXPayUtility.extractBody(httpResponse); 78 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 79 // 2XX 成功,验证应答签名 80 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 81 httpResponse.headers(), respBody); 82 83 // 从HTTP应答报文构建返回数据 84 return WXPayUtility.fromJson(respBody, ListCardResponse.class); 85 } else { 86 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 87 } 88 } catch (IOException e) { 89 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 90 } 91 } 92 93 private final String mchid; 94 private final String certificateSerialNo; 95 private final PrivateKey privateKey; 96 private final String wechatPayPublicKeyId; 97 private final PublicKey wechatPayPublicKey; 98 99 public ListCard(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 100 this.mchid = mchid; 101 this.certificateSerialNo = certificateSerialNo; 102 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 103 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 104 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 105 } 106 107 public static class ListCardRequest { 108 @SerializedName("brand_id") 109 @Expose(serialize = false) 110 public String brandId; 111 112 @SerializedName("offset") 113 @Expose(serialize = false) 114 public Long offset; 115 116 @SerializedName("limit") 117 @Expose(serialize = false) 118 public Long limit; 119 120 @SerializedName("state") 121 @Expose(serialize = false) 122 public CardState state; 123 } 124 125 public static class ListCardResponse { 126 @SerializedName("data") 127 public List<Card> data; 128 129 @SerializedName("total_count") 130 public Long totalCount; 131 132 @SerializedName("offset") 133 public Long offset; 134 135 @SerializedName("limit") 136 public Long limit; 137 } 138 139 public enum CardState { 140 @SerializedName("CARD_EFFECTIVE") 141 CARD_EFFECTIVE, 142 @SerializedName("CARD_INVALID") 143 CARD_INVALID 144 } 145 146 public static class Card { 147 @SerializedName("out_request_no") 148 public String outRequestNo; 149 150 @SerializedName("card_id") 151 public String cardId; 152 153 @SerializedName("brand_id") 154 public String brandId; 155 156 @SerializedName("appid") 157 public String appid; 158 159 @SerializedName("card_type") 160 public CardType cardType; 161 162 @SerializedName("card_title") 163 public String cardTitle; 164 165 @SerializedName("card_color") 166 public String cardColor; 167 168 @SerializedName("card_picture_url") 169 public String cardPictureUrl; 170 171 @SerializedName("code_mode") 172 public CodeMode codeMode; 173 174 @SerializedName("code_type") 175 public CodeType codeType; 176 177 @SerializedName("code_jump_information") 178 public CodeJumpInfo codeJumpInformation; 179 180 @SerializedName("benefits") 181 public String benefits; 182 183 @SerializedName("notify_url") 184 public String notifyUrl; 185 186 @SerializedName("need_pinned") 187 public Boolean needPinned; 188 189 @SerializedName("need_display_level") 190 public Boolean needDisplayLevel; 191 192 @SerializedName("init_level") 193 public String initLevel; 194 195 @SerializedName("service_phone") 196 public String servicePhone; 197 198 @SerializedName("legal_agreement") 199 public String legalAgreement; 200 201 @SerializedName("valid_date_information") 202 public DateInfo validDateInformation; 203 204 @SerializedName("member_information") 205 public MemberInfo memberInformation; 206 207 @SerializedName("points_information") 208 public PointsInfo pointsInformation; 209 210 @SerializedName("balance_information") 211 public BalanceInfo balanceInformation; 212 213 @SerializedName("purchase_information") 214 public PurchaseInfo purchaseInformation; 215 216 @SerializedName("user_information") 217 public UserInfoForm userInformation; 218 219 @SerializedName("state") 220 public CardState state; 221 222 @SerializedName("create_time") 223 public String createTime; 224 225 @SerializedName("modify_time") 226 public String modifyTime; 227 228 @SerializedName("support_user_active_join") 229 public Boolean supportUserActiveJoin; 230 231 @SerializedName("purchase_membership") 232 public Boolean purchaseMembership; 233 } 234 235 public enum CardType { 236 @SerializedName("PURCHASE") 237 PURCHASE, 238 @SerializedName("NORMAL") 239 NORMAL, 240 @SerializedName("BALANCE") 241 BALANCE 242 } 243 244 public enum CodeMode { 245 @SerializedName("SYSTEM_ALLOCATE") 246 SYSTEM_ALLOCATE, 247 @SerializedName("MERCHANT_ALLOCATE") 248 MERCHANT_ALLOCATE 249 } 250 251 public enum CodeType { 252 @SerializedName("NONE_CODE") 253 NONE_CODE, 254 @SerializedName("BAR_CODE") 255 BAR_CODE, 256 @SerializedName("QR_CODE") 257 QR_CODE, 258 @SerializedName("BAR_CODE_AND_QR_CODE") 259 BAR_CODE_AND_QR_CODE, 260 @SerializedName("JUMP_MINI_PROGRAM") 261 JUMP_MINI_PROGRAM 262 } 263 264 public static class CodeJumpInfo { 265 @SerializedName("jump_appid") 266 public String jumpAppid; 267 268 @SerializedName("jump_path") 269 public String jumpPath; 270 } 271 272 public static class DateInfo { 273 @SerializedName("type") 274 public DateType type; 275 276 @SerializedName("available_begin_time") 277 public String availableBeginTime; 278 279 @SerializedName("available_end_time") 280 public String availableEndTime; 281 282 @SerializedName("available_day_after_receive") 283 public Long availableDayAfterReceive; 284 } 285 286 public static class MemberInfo { 287 @SerializedName("jump_appid") 288 public String jumpAppid; 289 290 @SerializedName("jump_path") 291 public String jumpPath; 292 } 293 294 public static class PointsInfo { 295 @SerializedName("jump_appid") 296 public String jumpAppid; 297 298 @SerializedName("jump_path") 299 public String jumpPath; 300 } 301 302 public static class BalanceInfo { 303 @SerializedName("jump_appid") 304 public String jumpAppid; 305 306 @SerializedName("jump_path") 307 public String jumpPath; 308 } 309 310 public static class PurchaseInfo { 311 @SerializedName("price") 312 public Long price; 313 314 @SerializedName("jump_appid") 315 public String jumpAppid; 316 317 @SerializedName("jump_path") 318 public String jumpPath; 319 } 320 321 public static class UserInfoForm { 322 @SerializedName("common_field_list") 323 public List<CommonFieldFlag> commonFieldList; 324 325 @SerializedName("custom_field_list") 326 public List<UserCustomFieldForm> customFieldList; 327 } 328 329 public enum DateType { 330 @SerializedName("FIX_TIME_RANGE") 331 FIX_TIME_RANGE, 332 @SerializedName("FIX_TERM") 333 FIX_TERM, 334 @SerializedName("PERMANENT") 335 PERMANENT 336 } 337 338 public enum CommonFieldFlag { 339 @SerializedName("USER_FORM_FLAG_SEX") 340 USER_FORM_FLAG_SEX, 341 @SerializedName("USER_FORM_FLAG_NAME") 342 USER_FORM_FLAG_NAME, 343 @SerializedName("USER_FORM_FLAG_BIRTHDAY") 344 USER_FORM_FLAG_BIRTHDAY, 345 @SerializedName("USER_FORM_FLAG_ADDRESS") 346 USER_FORM_FLAG_ADDRESS, 347 @SerializedName("USER_FORM_FLAG_EMAIL") 348 USER_FORM_FLAG_EMAIL, 349 @SerializedName("USER_FORM_FLAG_CITY") 350 USER_FORM_FLAG_CITY 351 } 352 353 public static class UserCustomFieldForm { 354 @SerializedName("type") 355 public CustomFieldType type; 356 357 @SerializedName("name") 358 public String name; 359 360 @SerializedName("values") 361 public List<String> values; 362 } 363 364 public enum CustomFieldType { 365 @SerializedName("CHECK_BOX") 366 CHECK_BOX, 367 @SerializedName("RADIO") 368 RADIO 369 } 370 371} 372
需配合微信支付工具库 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 "time" 10) 11 12func main() { 13 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 14 config, err := wxpay_utility.CreateMchConfig( 15 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 16 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 17 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 18 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 19 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 20 ) 21 if err != nil { 22 fmt.Println(err) 23 return 24 } 25 26 request := &ListCardRequest{ 27 BrandId: wxpay_utility.String("1004"), 28 State: CARDSTATE_CARD_EFFECTIVE.Ptr(), 29 Offset: wxpay_utility.Int64(0), 30 Limit: wxpay_utility.Int64(20), 31 } 32 33 response, err := ListCard(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 ListCard(config *wxpay_utility.MchConfig, request *ListCardRequest) (response *ListCardResponse, err error) { 45 const ( 46 host = "https://api.mch.weixin.qq.com" 47 method = "GET" 48 path = "/v3/brand/partner/card-member/cards" 49 ) 50 51 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 52 if err != nil { 53 return nil, err 54 } 55 query := reqUrl.Query() 56 if request.BrandId != nil { 57 query.Add("brand_id", *request.BrandId) 58 } 59 if request.State != nil { 60 query.Add("state", fmt.Sprintf("%v", *request.State)) 61 } 62 if request.Offset != nil { 63 query.Add("offset", fmt.Sprintf("%v", *request.Offset)) 64 } 65 if request.Limit != nil { 66 query.Add("limit", fmt.Sprintf("%v", *request.Limit)) 67 } 68 reqUrl.RawQuery = query.Encode() 69 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 70 if err != nil { 71 return nil, err 72 } 73 httpRequest.Header.Set("Accept", "application/json") 74 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 75 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 76 if err != nil { 77 return nil, err 78 } 79 httpRequest.Header.Set("Authorization", authorization) 80 81 client := &http.Client{} 82 httpResponse, err := client.Do(httpRequest) 83 if err != nil { 84 return nil, err 85 } 86 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 87 if err != nil { 88 return nil, err 89 } 90 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 91 // 2XX 成功,验证应答签名 92 err = wxpay_utility.ValidateResponse( 93 config.WechatPayPublicKeyId(), 94 config.WechatPayPublicKey(), 95 &httpResponse.Header, 96 respBody, 97 ) 98 if err != nil { 99 return nil, err 100 } 101 response := &ListCardResponse{} 102 if err := json.Unmarshal(respBody, response); err != nil { 103 return nil, err 104 } 105 106 return response, nil 107 } else { 108 return nil, wxpay_utility.NewApiException( 109 httpResponse.StatusCode, 110 httpResponse.Header, 111 respBody, 112 ) 113 } 114} 115 116type ListCardRequest struct { 117 BrandId *string `json:"brand_id,omitempty"` 118 Offset *int64 `json:"offset,omitempty"` 119 Limit *int64 `json:"limit,omitempty"` 120 State *CardState `json:"state,omitempty"` 121} 122 123func (o *ListCardRequest) MarshalJSON() ([]byte, error) { 124 type Alias ListCardRequest 125 a := &struct { 126 BrandId *string `json:"brand_id,omitempty"` 127 Offset *int64 `json:"offset,omitempty"` 128 Limit *int64 `json:"limit,omitempty"` 129 State *CardState `json:"state,omitempty"` 130 *Alias 131 }{ 132 // 序列化时移除非 Body 字段 133 BrandId: nil, 134 Offset: nil, 135 Limit: nil, 136 State: nil, 137 Alias: (*Alias)(o), 138 } 139 return json.Marshal(a) 140} 141 142type ListCardResponse struct { 143 Data []Card `json:"data,omitempty"` 144 TotalCount *int64 `json:"total_count,omitempty"` 145 Offset *int64 `json:"offset,omitempty"` 146 Limit *int64 `json:"limit,omitempty"` 147} 148 149type CardState string 150 151func (e CardState) Ptr() *CardState { 152 return &e 153} 154 155const ( 156 CARDSTATE_CARD_EFFECTIVE CardState = "CARD_EFFECTIVE" 157 CARDSTATE_CARD_INVALID CardState = "CARD_INVALID" 158) 159 160type Card struct { 161 OutRequestNo *string `json:"out_request_no,omitempty"` 162 CardId *string `json:"card_id,omitempty"` 163 BrandId *string `json:"brand_id,omitempty"` 164 Appid *string `json:"appid,omitempty"` 165 CardType *CardType `json:"card_type,omitempty"` 166 CardTitle *string `json:"card_title,omitempty"` 167 CardColor *string `json:"card_color,omitempty"` 168 CardPictureUrl *string `json:"card_picture_url,omitempty"` 169 CodeMode *CodeMode `json:"code_mode,omitempty"` 170 CodeType *CodeType `json:"code_type,omitempty"` 171 CodeJumpInformation *CodeJumpInfo `json:"code_jump_information,omitempty"` 172 Benefits *string `json:"benefits,omitempty"` 173 NotifyUrl *string `json:"notify_url,omitempty"` 174 NeedPinned *bool `json:"need_pinned,omitempty"` 175 NeedDisplayLevel *bool `json:"need_display_level,omitempty"` 176 InitLevel *string `json:"init_level,omitempty"` 177 ServicePhone *string `json:"service_phone,omitempty"` 178 LegalAgreement *string `json:"legal_agreement,omitempty"` 179 ValidDateInformation *DateInfo `json:"valid_date_information,omitempty"` 180 MemberInformation *MemberInfo `json:"member_information,omitempty"` 181 PointsInformation *PointsInfo `json:"points_information,omitempty"` 182 BalanceInformation *BalanceInfo `json:"balance_information,omitempty"` 183 PurchaseInformation *PurchaseInfo `json:"purchase_information,omitempty"` 184 UserInformation *UserInfoForm `json:"user_information,omitempty"` 185 State *CardState `json:"state,omitempty"` 186 CreateTime *time.Time `json:"create_time,omitempty"` 187 ModifyTime *time.Time `json:"modify_time,omitempty"` 188 SupportUserActiveJoin *bool `json:"support_user_active_join,omitempty"` 189 PurchaseMembership *bool `json:"purchase_membership,omitempty"` 190} 191 192type CardType string 193 194func (e CardType) Ptr() *CardType { 195 return &e 196} 197 198const ( 199 CARDTYPE_PURCHASE CardType = "PURCHASE" 200 CARDTYPE_NORMAL CardType = "NORMAL" 201 CARDTYPE_BALANCE CardType = "BALANCE" 202) 203 204type CodeMode string 205 206func (e CodeMode) Ptr() *CodeMode { 207 return &e 208} 209 210const ( 211 CODEMODE_SYSTEM_ALLOCATE CodeMode = "SYSTEM_ALLOCATE" 212 CODEMODE_MERCHANT_ALLOCATE CodeMode = "MERCHANT_ALLOCATE" 213) 214 215type CodeType string 216 217func (e CodeType) Ptr() *CodeType { 218 return &e 219} 220 221const ( 222 CODETYPE_NONE_CODE CodeType = "NONE_CODE" 223 CODETYPE_BAR_CODE CodeType = "BAR_CODE" 224 CODETYPE_QR_CODE CodeType = "QR_CODE" 225 CODETYPE_BAR_CODE_AND_QR_CODE CodeType = "BAR_CODE_AND_QR_CODE" 226 CODETYPE_JUMP_MINI_PROGRAM CodeType = "JUMP_MINI_PROGRAM" 227) 228 229type CodeJumpInfo struct { 230 JumpAppid *string `json:"jump_appid,omitempty"` 231 JumpPath *string `json:"jump_path,omitempty"` 232} 233 234type DateInfo struct { 235 Type *DateType `json:"type,omitempty"` 236 AvailableBeginTime *time.Time `json:"available_begin_time,omitempty"` 237 AvailableEndTime *time.Time `json:"available_end_time,omitempty"` 238 AvailableDayAfterReceive *int64 `json:"available_day_after_receive,omitempty"` 239} 240 241type MemberInfo struct { 242 JumpAppid *string `json:"jump_appid,omitempty"` 243 JumpPath *string `json:"jump_path,omitempty"` 244} 245 246type PointsInfo struct { 247 JumpAppid *string `json:"jump_appid,omitempty"` 248 JumpPath *string `json:"jump_path,omitempty"` 249} 250 251type BalanceInfo struct { 252 JumpAppid *string `json:"jump_appid,omitempty"` 253 JumpPath *string `json:"jump_path,omitempty"` 254} 255 256type PurchaseInfo struct { 257 Price *int64 `json:"price,omitempty"` 258 JumpAppid *string `json:"jump_appid,omitempty"` 259 JumpPath *string `json:"jump_path,omitempty"` 260} 261 262type UserInfoForm struct { 263 CommonFieldList []CommonFieldFlag `json:"common_field_list,omitempty"` 264 CustomFieldList []UserCustomFieldForm `json:"custom_field_list,omitempty"` 265} 266 267type DateType string 268 269func (e DateType) Ptr() *DateType { 270 return &e 271} 272 273const ( 274 DATETYPE_FIX_TIME_RANGE DateType = "FIX_TIME_RANGE" 275 DATETYPE_FIX_TERM DateType = "FIX_TERM" 276 DATETYPE_PERMANENT DateType = "PERMANENT" 277) 278 279type CommonFieldFlag string 280 281func (e CommonFieldFlag) Ptr() *CommonFieldFlag { 282 return &e 283} 284 285const ( 286 COMMONFIELDFLAG_USER_FORM_FLAG_SEX CommonFieldFlag = "USER_FORM_FLAG_SEX" 287 COMMONFIELDFLAG_USER_FORM_FLAG_NAME CommonFieldFlag = "USER_FORM_FLAG_NAME" 288 COMMONFIELDFLAG_USER_FORM_FLAG_BIRTHDAY CommonFieldFlag = "USER_FORM_FLAG_BIRTHDAY" 289 COMMONFIELDFLAG_USER_FORM_FLAG_ADDRESS CommonFieldFlag = "USER_FORM_FLAG_ADDRESS" 290 COMMONFIELDFLAG_USER_FORM_FLAG_EMAIL CommonFieldFlag = "USER_FORM_FLAG_EMAIL" 291 COMMONFIELDFLAG_USER_FORM_FLAG_CITY CommonFieldFlag = "USER_FORM_FLAG_CITY" 292) 293 294type UserCustomFieldForm struct { 295 Type *CustomFieldType `json:"type,omitempty"` 296 Name *string `json:"name,omitempty"` 297 Values []string `json:"values,omitempty"` 298} 299 300type CustomFieldType string 301 302func (e CustomFieldType) Ptr() *CustomFieldType { 303 return &e 304} 305 306const ( 307 CUSTOMFIELDTYPE_CHECK_BOX CustomFieldType = "CHECK_BOX" 308 CUSTOMFIELDTYPE_RADIO CustomFieldType = "RADIO" 309) 310
应答参数
折叠全部参数
200 OK
data 选填 array[object]
【会员卡模板列表】 符合条件的会员卡模板列表
out_request_no 必填 string(128)
【商家请求单号】 商家创建会员卡模板凭据号。商家自定义,注意保持唯一性,仅供参考的格式:品牌ID+时间戳+流水号。字符仅允许包含英文半角的数字、字母、连接线-和下划线_。
card_id 必填 string(32)
【会员卡模板 ID】 商家创建会员卡模板成功后系统返回的会员卡模板ID
brand_id 必填 string(32)
【品牌ID】 商家进驻微信支付品牌商家后获得的品牌ID(灰度期间联系微信支付运营获取),用于标记该会员卡的归属方
appid 必填 string
【商家AppID】 商家的AppID,可以是服务号、订阅号、公众号、小程序的AppID。1、该AppID用于获取会员OpenID。2、该AppID需要与会员卡归属品牌有B-A关系。
card_type 必填 string
【会员卡类型】 支持付费、普通、储值 3 种类型。目前仅支持普通会员卡,填写付费和储值类型时会返回错误。
可选取值
PURCHASE: 付费NORMAL: 普通BALANCE: 储值
card_title 必填 string(10)
【卡名称】 1.可用于展示在卡面的名称 2.支持最长10个中文字 3.支持中文字、英文字符、标点
card_color 必填 string(7)
【卡背景颜色】 用于卡片正面设计的RGB颜色编码,仅支持十六进制
card_picture_url 选填 string(256)
【卡图片】 商家自定义会员卡背景图。仅支持通过图片上传API接口获取的图片URL地址。支持JPG/JPEG/PNG格式,建议尺寸716px*320px,且图片小于1M。查看以下链接后传入:图片要求示例,图片上传API指引。不传时没有默认卡图。
code_mode 必填 string
【会员卡code分配类型】 1、会员卡code是会员在一个会员卡模板下唯一身份标识,平台支持2种分配类型:
(1)SYSTEM_ALLOCATE 微信支付系统分配,用户领取会员卡时从微信系统分配24位数字作为会员code,并在「用户开通会员卡」事件通知中返回;
(2)MERCHANT_ALLOCATE 商家分配,商家同步会员开通结果时传入,用户开卡成功或失败都以商家传入的code作为会员卡code。选择商家分配模式时,开通事件通知中不返回 user_card_code。
2、会员卡创建后,code分配模式不支持修改。
可选取值
SYSTEM_ALLOCATE: 系统分配MERCHANT_ALLOCATE: 商家分配
code_type 必填 string
【会员码展示类型】 会员码支持不展示码/二维码/条形码/二维码+条形码/跳转商家小程序5种设置。
可选取值
NONE_CODE: 不显示任何码型BAR_CODE: 条形码QR_CODE: 二维码BAR_CODE_AND_QR_CODE: 条形码和二维码JUMP_MINI_PROGRAM: 跳转商家小程序
code_jump_information 选填 object
【会员码跳转信息】 会员码跳转的小程序信息,当会员码展示类型为跳转商家小程序时必填。
jump_appid 选填 string(32)
【会员码跳转AppID】 会员码跳转的小程序AppID
jump_path 选填 string(128)
【会员码跳转路径】 会员码跳转的小程序路径
benefits 选填 string(32)
【会员权益】 会员权益是指平台、品牌或服务机构为付费会员(或等级会员)提供的专属优惠、服务或特权。支持用户主动入会时必填。若该值不为空,则会返回该字段。
notify_url 选填 string(256)
【回调地址】 商家接收开卡成功回调通知的地址,需按照notify_url填写注意事项规范填写。支持用户主动入会时必填。若该值不为空,则会返回该字段。
need_pinned 选填 boolean
【是否置顶】 置顶卡是界面中的一种特殊展示模块,通过人工设置,使其固定在内容列表的顶部位置,确保用户优先看到。默认为false。同一个品牌下允许存在多张置顶卡,按照更新时间倒序排序。
need_display_level 选填 boolean
【是否展示会员等级】 是否在会员卡面向用户展示等级信息,默认不展示(false)
init_level 选填 string(10)
【会员初始等级】 展示字段,商家可以自定义填写内容。如果选择了展示会员等级,必填init_level,作为新用户开卡后的初始等级。如因商家业务规则需要变更某会员等级,可通过更新用户会员卡接口更新等级信息。
service_phone 选填 string(32)
【服务电话】 展示在会员卡详情内,建议填写商家固定电话
legal_agreement 选填 string(20480)
【商家法务协议】 指用户与商家之间签订的具有法律效力的合同文件,旨在明确双方在交易、服务提供、权利义务等方面的规则,以保障交易安全、规范商业行为,并在纠纷发生时提供法律依据。不支持链接跳转,支持使用\n代表换行,只支持纯文本展示。支持用户主动入会时必填。若该值不为空,则会返回该字段。
valid_date_information 必填 object
【会员卡有效期】 会员卡有效期
type 必填 string
【有效期类型】 传入会员卡有效期时必填。1.该有效期为会员卡激活后的有效期 2.支持绝对有效期&相对有效期设置 3.绝对有效期:固定过期时间,需遵循 RFC3339 标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。yyyy-MM-DD 表示年月日;T 字符用于分隔日期和时间部分;HH:mm:ss 表示具体的时分秒;TIMEZONE 表示时区(例如,+08:00 对应东八区时间,即北京时间)。示例:2015-05-20T13:29:35+08:00 表示北京时间2015年5月20日13点29分35秒。 4.相对有效期:用户激活后x天后有效,x为天数。最多支持10,957天(30年) 5.永久有效 6.过期后卡状态变为“已过期” 7.过期后不再出现服务项,且无法给用户发送会员服务消息通知
可选取值
FIX_TIME_RANGE: 必填available_begin_time和available_end_time,会员卡在此时间[available_begin_time, available_end_time)范围内有效FIX_TERM: 必填available_day_after_receive,会员卡在用户领取之后available_day_after_receive天内有效PERMANENT: 会员卡激活后永久有效
available_begin_time 选填 string
【有效期开始时间】 type为FIX_TIME_RANGE时专用, 表示有效期开始时间。需需遵循 RFC3339 标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。yyyy-MM-DD 表示年月日;T 字符用于分隔日期和时间部分;HH:mm:ss 表示具体的时分秒;TIMEZONE 表示时区(例如,+08:00 对应东八区时间,即北京时间)。示例:2015-05-20T13:29:35+08:00 表示北京时间2015年5月20日13点29分35秒。
available_end_time 选填 string
【有效期结束时间】 type为FIX_TIME_RANGE时专用,表示有效期结束时间。需需遵循 RFC3339 标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。yyyy-MM-DD 表示年月日;T 字符用于分隔日期和时间部分;HH:mm:ss 表示具体的时分秒;TIMEZONE 表示时区(例如,+08:00 对应东八区时间,即北京时间)。示例:2015-05-20T13:29:35+08:00 表示北京时间2015年5月20日13点29分35秒。
available_day_after_receive 选填 integer
【领取后N天内有效】 type为FIX_TERM时专用,表示领取后N个自然天内有效。最长不超过30年(10958 天)
member_information 必填 object
【会员中心信息】 用户点击会员卡卡面的跳转信息
jump_appid 必填 string(32)
【会员中心跳转AppID】 用户点击会员卡卡面后跳转的小程序AppID
jump_path 必填 string(128)
【会员中心跳转路径】 用户点击会员卡卡面后跳转的小程序路径
points_information 选填 object
【积分信息】 若商家名片会员卡使用该功能,需传入跳转商家小程序的信息。否则不启动该功能。
jump_appid 选填 string(32)
【积分跳转AppID】 会员积分跳转的小程序AppID
jump_path 选填 string(128)
【积分跳转路径】 会员积分跳转的小程序路径
balance_information 选填 object
【储值信息】 若商家名片会员卡使用该功能,需传入跳转商家小程序的信息。否则不启动该功能。
jump_appid 选填 string(32)
【储值小程序AppID】 点击储值额跳转的小程序AppID
jump_path 选填 string(128)
【储值小程序路径】 点击储值额跳转的小程序页面路径,建议为储值充值页面
purchase_information 选填 object
【付费会员信息】 若商家名片会员卡使用该功能,需传入跳转商家小程序的信息及会员价格。否则不启动该功能。
price 选填 integer
【付费会员价格】 指用户为获取特定商家提供的会员权益而需支付的费用金额。(单位:分)
jump_appid 选填 string(32)
【付费会员跳转AppID】 用户购买付费会员时跳转的付费会员的AppID
jump_path 选填 string(128)
【付费会员跳转路径】 用户购买付费会员时购买跳转的路径
user_information 选填 object
【用户开卡信息】 用户开通会员卡时可填写的信息。用户可以选择不填写,不影响开通会员卡;用户填写的内容会在开卡回调中返回给商家。
common_field_list 选填 array[string]
【平台提供的通用开卡信息字段】 平台提供的通用开卡信息字段。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。
可选取值
USER_FORM_FLAG_SEX: 用户开卡时需填写性别,字段内容可选男或女。USER_FORM_FLAG_NAME: 用户开卡时需填写姓名USER_FORM_FLAG_BIRTHDAY: 用户开卡时需填写生日,字段内容需遵循 RFC3339 标准的full-date格式:yyyy-MM-DD,表示年月日。年份必须为 4 位数,月份和日期不足两位时需补零。 示例:2015-05-20。USER_FORM_FLAG_ADDRESS: 用户开卡时需填写地址USER_FORM_FLAG_EMAIL: 用户开卡时需填写邮箱,字段内容需为合法邮箱。USER_FORM_FLAG_CITY: 用户开卡时需填写城市,字段格式需为:"省份,城市",第一项省份,第二项城市,用英文逗号分隔。
custom_field_list 选填 array[object]
【商家自定义的开卡信息字段】 商家自定义的开卡信息字段。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。当前最多只允许传入1项。
type 选填 string
【字段类型】 选择所需的字段类型
可选取值
CHECK_BOX: 用户可从商家提供的选项中选择多项RADIO: 用户可从商家提供的选项中选择一项
name 选填 string(32)
【字段名称】 信息项的名称。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。
values 选填 array[string(8)]
【字段值】 信息项的值列表。
特殊规则:列表最多支持10个,单个列表限制8个字符。若商户创建会员卡模板时设置该值,则查询结果中会返回给商户。
state 必填 string
【状态】 会员卡状态信息
可选取值
CARD_EFFECTIVE: 生效中CARD_INVALID: 已失效
create_time 必填 string
【创建时间】 创建会员卡的时间,需遵循 RFC3339 标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。yyyy-MM-DD 表示年月日;T 字符用于分隔日期和时间部分;HH:mm:ss 表示具体的时分秒;TIMEZONE 表示时区(例如,+08:00 对应东八区时间,即北京时间)。示例:2015-05-20T13:29:35+08:00 表示北京时间2015年5月20日13点29分35秒。
modify_time 必填 string
【更新时间】 更新会员卡的时间,需遵循 RFC3339 标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。yyyy-MM-DD 表示年月日;T 字符用于分隔日期和时间部分;HH:mm:ss 表示具体的时分秒;TIMEZONE 表示时区(例如,+08:00 对应东八区时间,即北京时间)。示例:2015-05-20T13:29:35+08:00 表示北京时间2015年5月20日13点29分35秒。
support_user_active_join 选填 boolean
【是否支持用户主动入会】 true 表示允许用户在微信支付内主动开通这张会员卡,用户可以通过商家名片、支付相关入会入口,以及商家小程序或 H5 的入会流程填写开卡信息并开通;false 表示用户不能在微信支付内主动开通,只能由商家通过导入等方式开通。
purchase_membership 选填 boolean
【是否为付费会员】 true 表示该会员卡是付费会员,false 表示不是。
total_count 必填 integer
【总数量】 总数量
offset 必填 integer
【分页开始位置】 该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回。
limit 必填 integer
【分页大小】 分页大小,范围为1~20
应答示例
200 OK
1{ 2 "data" : [ 3 { 4 "out_request_no" : "100002322019090134234sfdf", 5 "card_id" : "pbLatjvWOibDc5-TBnbUk1pD12o0", 6 "brand_id" : "1004", 7 "appid" : "wxea9c30890f48d5ae", 8 "card_type" : "NORMAL", 9 "card_title" : "测试卡", 10 "card_color" : "#FFFF00", 11 "card_picture_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/0", 12 "code_mode" : "SYSTEM_ALLOCATE", 13 "code_type" : "BAR_CODE", 14 "code_jump_information" : { 15 "jump_appid" : "wxea9c30a90fs8d3fe", 16 "jump_path" : "/pages/code/code" 17 }, 18 "benefits" : "会员折扣、专属价", 19 "notify_url" : "https://www.weixin.qq.com/wxpay/notify.php", 20 "need_pinned" : true, 21 "need_display_level" : true, 22 "init_level" : "白银会员", 23 "service_phone" : "010-8877xxxx", 24 "legal_agreement" : "商家需在 48 小时内发货,若商品存在质量问题,用户可在 7 天内申请退货。", 25 "valid_date_information" : { 26 "type" : "PERMANENT", 27 "available_begin_time" : "2020-05-20T13:29:35.120+08:00", 28 "available_end_time" : "2020-05-20T13:29:35.120+08:00", 29 "available_day_after_receive" : 30 30 }, 31 "member_information" : { 32 "jump_appid" : "wxea9c30a90fs8d3fe", 33 "jump_path" : "/pages/points/points" 34 }, 35 "points_information" : { 36 "jump_appid" : "wxea9c30a90fs8d3fe", 37 "jump_path" : "/pages/points/points" 38 }, 39 "balance_information" : { 40 "jump_appid" : "wxea9c30a90fs8d3fe", 41 "jump_path" : "/pages/balance/balance" 42 }, 43 "purchase_information" : { 44 "price" : 100, 45 "jump_appid" : "wxea9c30a90fs8d3fe", 46 "jump_path" : "/pages/purchase/purchase" 47 }, 48 "user_information" : { 49 "common_field_list" : [ 50 "USER_FORM_FLAG_SEX" 51 ], 52 "custom_field_list" : [ 53 { 54 "type" : "CHECK_BOX", 55 "name" : "喜欢的运动", 56 "values" : [ 57 "篮球" 58 ] 59 } 60 ] 61 }, 62 "state" : "CARD_EFFECTIVE", 63 "create_time" : "2020-05-20T13:29:35.120+08:00", 64 "modify_time" : "2020-05-20T13:29:35.120+08:00", 65 "support_user_active_join" : true, 66 "purchase_membership" : false 67 } 68 ], 69 "total_count" : 20, 70 "offset" : 0, 71 "limit" : 20 72} 73
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
