查询会员卡模板列表

更新时间:2025.06.22

通过此接口可查询指定某品牌的所有会员卡模板列表

接口说明

支持商户:【普通服务商】

请求方式:【GET】/v3/brand/partner/card-member/cards

请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点

     【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看

请求参数

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

【分页大小】 分页大小

请求示例

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 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
48      // TODO: 请求成功,继续业务逻辑
49      System.out.println(response);
50    } catch (WXPayUtility.ApiException e) {
51      // TODO: 请求失败,根据状态码执行不同的逻辑
52      e.printStackTrace();
53    }
54  }
55
56  public ListCardResponse run(ListCardRequest request) {
57    String uri = PATH;
58    Map<String, Object> args = new HashMap<>();
59    args.put("brand_id", request.brandId);
60    args.put("state", request.state);
61    args.put("offset", request.offset);
62    args.put("limit", request.limit);
63    uri = uri + "?" + WXPayUtility.urlEncode(args);
64
65    Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
66    reqBuilder.addHeader("Accept", "application/json");
67    reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
68    reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null));
69    reqBuilder.method(METHOD, null);
70    Request httpRequest = reqBuilder.build();
71
72    // 发送HTTP请求
73    OkHttpClient client = new OkHttpClient.Builder().build();
74    try (Response httpResponse = client.newCall(httpRequest).execute()) {
75      String respBody = WXPayUtility.extractBody(httpResponse);
76      if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
77        // 2XX 成功,验证应答签名
78        WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
79            httpResponse.headers(), respBody);
80
81        // 从HTTP应答报文构建返回数据
82        return WXPayUtility.fromJson(respBody, ListCardResponse.class);
83      } else {
84        throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
85      }
86    } catch (IOException e) {
87      throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
88    }
89  }
90
91  private final String mchid;
92  private final String certificateSerialNo;
93  private final PrivateKey privateKey;
94  private final String wechatPayPublicKeyId;
95  private final PublicKey wechatPayPublicKey;
96
97  public ListCard(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
98    this.mchid = mchid;
99    this.certificateSerialNo = certificateSerialNo;
100    this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
101    this.wechatPayPublicKeyId = wechatPayPublicKeyId;
102    this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
103  }
104
105  public static class ListCardRequest {
106    @SerializedName("brand_id")
107    @Expose(serialize = false)
108    public String brandId;
109  
110    @SerializedName("offset")
111    @Expose(serialize = false)
112    public Long offset;
113  
114    @SerializedName("limit")
115    @Expose(serialize = false)
116    public Long limit;
117  
118    @SerializedName("state")
119    @Expose(serialize = false)
120    public CardState state;
121  }
122  
123  public static class ListCardResponse {
124    @SerializedName("data")
125    public List<Card> data;
126  
127    @SerializedName("total_count")
128    public Long totalCount;
129  
130    @SerializedName("offset")
131    public Long offset;
132  
133    @SerializedName("limit")
134    public Long limit;
135  }
136  
137  public enum CardState {
138    @SerializedName("CARD_EFFECTIVE")
139    CARD_EFFECTIVE,
140    @SerializedName("CARD_INVALID")
141    CARD_INVALID
142  }
143  
144  public static class Card {
145    @SerializedName("out_request_no")
146    public String outRequestNo;
147  
148    @SerializedName("card_id")
149    public String cardId;
150  
151    @SerializedName("brand_id")
152    public String brandId;
153  
154    @SerializedName("appid")
155    public String appid;
156  
157    @SerializedName("card_type")
158    public CardType cardType;
159  
160    @SerializedName("card_title")
161    public String cardTitle;
162  
163    @SerializedName("card_color")
164    public String cardColor;
165  
166    @SerializedName("card_picture_url")
167    public String cardPictureUrl;
168  
169    @SerializedName("code_mode")
170    public CodeMode codeMode;
171  
172    @SerializedName("code_type")
173    public CodeType codeType;
174  
175    @SerializedName("code_jump_information")
176    public CodeJumpInfo codeJumpInformation;
177  
178    @SerializedName("benefits")
179    public String benefits;
180  
181    @SerializedName("notify_url")
182    public String notifyUrl;
183  
184    @SerializedName("need_pinned")
185    public Boolean needPinned;
186  
187    @SerializedName("need_display_level")
188    public Boolean needDisplayLevel;
189  
190    @SerializedName("init_level")
191    public String initLevel;
192  
193    @SerializedName("service_phone")
194    public String servicePhone;
195  
196    @SerializedName("legal_agreement")
197    public String legalAgreement;
198  
199    @SerializedName("valid_date_information")
200    public DateInfo validDateInformation;
201  
202    @SerializedName("member_information")
203    public MemberInfo memberInformation;
204  
205    @SerializedName("points_information")
206    public PointsInfo pointsInformation;
207  
208    @SerializedName("balance_information")
209    public BalanceInfo balanceInformation;
210  
211    @SerializedName("purchase_information")
212    public PurchaseInfo purchaseInformation;
213  
214    @SerializedName("user_information")
215    public UserInfoForm userInformation;
216  
217    @SerializedName("state")
218    public CardState state;
219  
220    @SerializedName("create_time")
221    public String createTime;
222  
223    @SerializedName("modify_time")
224    public String modifyTime;
225  }
226  
227  public enum CardType {
228    @SerializedName("PURCHASE")
229    PURCHASE,
230    @SerializedName("NORMAL")
231    NORMAL,
232    @SerializedName("BALANCE")
233    BALANCE
234  }
235  
236  public enum CodeMode {
237    @SerializedName("SYSTEM_ALLOCATE")
238    SYSTEM_ALLOCATE,
239    @SerializedName("MERCHANT_ALLOCATE")
240    MERCHANT_ALLOCATE
241  }
242  
243  public enum CodeType {
244    @SerializedName("NONE_CODE")
245    NONE_CODE,
246    @SerializedName("BAR_CODE")
247    BAR_CODE,
248    @SerializedName("QR_CODE")
249    QR_CODE,
250    @SerializedName("BAR_CODE_AND_QR_CODE")
251    BAR_CODE_AND_QR_CODE,
252    @SerializedName("JUMP_MINI_PROGRAM")
253    JUMP_MINI_PROGRAM
254  }
255  
256  public static class CodeJumpInfo {
257    @SerializedName("jump_appid")
258    public String jumpAppid;
259  
260    @SerializedName("jump_path")
261    public String jumpPath;
262  }
263  
264  public static class DateInfo {
265    @SerializedName("type")
266    public DateType type;
267  
268    @SerializedName("available_begin_time")
269    public String availableBeginTime;
270  
271    @SerializedName("available_end_time")
272    public String availableEndTime;
273  
274    @SerializedName("available_day_after_receive")
275    public Long availableDayAfterReceive;
276  }
277  
278  public static class MemberInfo {
279    @SerializedName("jump_appid")
280    public String jumpAppid;
281  
282    @SerializedName("jump_path")
283    public String jumpPath;
284  }
285  
286  public static class PointsInfo {
287    @SerializedName("jump_appid")
288    public String jumpAppid;
289  
290    @SerializedName("jump_path")
291    public String jumpPath;
292  }
293  
294  public static class BalanceInfo {
295    @SerializedName("jump_appid")
296    public String jumpAppid;
297  
298    @SerializedName("jump_path")
299    public String jumpPath;
300  }
301  
302  public static class PurchaseInfo {
303    @SerializedName("price")
304    public Long price;
305  
306    @SerializedName("jump_appid")
307    public String jumpAppid;
308  
309    @SerializedName("jump_path")
310    public String jumpPath;
311  }
312  
313  public static class UserInfoForm {
314    @SerializedName("common_field_list")
315    public List<CommonFieldFlag> commonFieldList;
316  
317    @SerializedName("custom_field_list")
318    public List<UserCustomFieldForm> customFieldList;
319  }
320  
321  public enum DateType {
322    @SerializedName("FIX_TIME_RANGE")
323    FIX_TIME_RANGE,
324    @SerializedName("FIX_TERM")
325    FIX_TERM,
326    @SerializedName("PERMANENT")
327    PERMANENT
328  }
329  
330  public enum CommonFieldFlag {
331    @SerializedName("USER_FORM_FLAG_SEX")
332    USER_FORM_FLAG_SEX,
333    @SerializedName("USER_FORM_FLAG_NAME")
334    USER_FORM_FLAG_NAME,
335    @SerializedName("USER_FORM_FLAG_BIRTHDAY")
336    USER_FORM_FLAG_BIRTHDAY,
337    @SerializedName("USER_FORM_FLAG_ADDRESS")
338    USER_FORM_FLAG_ADDRESS,
339    @SerializedName("USER_FORM_FLAG_EMAIL")
340    USER_FORM_FLAG_EMAIL,
341    @SerializedName("USER_FORM_FLAG_CITY")
342    USER_FORM_FLAG_CITY
343  }
344  
345  public static class UserCustomFieldForm {
346    @SerializedName("type")
347    public CustomFieldType type;
348  
349    @SerializedName("name")
350    public String name;
351  
352    @SerializedName("values")
353    public List<String> values;
354  }
355  
356  public enum CustomFieldType {
357    @SerializedName("CHECK_BOX")
358    CHECK_BOX,
359    @SerializedName("RADIO")
360    RADIO
361  }
362  
363}
364

应答参数

200 OK

 data  选填   array[object]

【会员卡模板列表】 符合条件的会员卡模板列表

属性

 total_count  必填   integer

【总数量】 总数量


 offset  必填   integer

【分页开始位置】 该次请求的分页开始位置,从0开始计数,例如offset=10,表示从第11条记录开始返回。


 limit  必填   integer

【分页大小】 分页大小

应答示例

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    }
66  ],
67  "total_count" : 20,
68  "offset" : 0,
69  "limit" : 20
70}
71

 

错误码

公共错误码

状态码

错误码

描述

解决方案

400

PARAM_ERROR

参数错误

请根据错误提示正确传入参数

400

INVALID_REQUEST

HTTP 请求不符合微信支付 APIv3 接口规则

请参阅 接口规则

401

SIGN_ERROR

验证不通过

请参阅 签名常见问题

500

SYSTEM_ERROR

系统异常,请稍后重试

请稍后重试

 

更多技术问题
技术咨询
反馈
咨询
目录
置顶