创建会员卡模板
更新时间:2025.06.22通过此接口可以创建一张会员卡模板,创建成功将获得会员卡模板card_id
接口说明
支持商户:【普通服务商】
请求方式:【POST】/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
Content-Type 必填 string
请设置为application/json
body 包体参数
out_request_no 必填 string(128)
【商家请求单号】 商家创建会员卡模板凭据号。商家自定义,注意保持唯一性,仅供参考的格式:品牌ID+时间戳+流水号。字符仅允许包含英文半角的数字、字母、连接线-
和下划线_
。
brand_id 必填 string(32)
【品牌ID】 商家进驻微信支付品牌商家后获得的品牌ID(灰度期间联系微信支付运营获取),用于标记该会员卡的归属方
appid 必填 string(32)
【商家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 微信支付系统分配,用户领取会员卡时从微信系统分配12位数字作为会员code;(2)MERCHANT_ALLOCATE 商家预存code,商家可提前通过导入预存code接口导入code,用户领取会员卡时平台从商家导入的code中随机分配作为会员code。 2、会员卡code分配模式若为“系统分配”,不支持修改为“商家分配”。
可选取值
SYSTEM_ALLOCATE
: 系统分配MERCHANT_ALLOCATE
: 商家分配
code_type 必填 string
【会员码型】 会员码支持不展示码/二维码/条形码/二维码+条形码/跳转商家小程序5种设置。当会员码型为跳转商家小程序时,必填code_jump_information
。
可选取值
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(2048)
【商家法务协议】 指用户与商家之间签订的具有法律效力的合同文件,旨在明确双方在交易、服务提供、权利义务等方面的规则,以保障交易安全、规范商业行为,并在纠纷发生时提供法律依据。若该值不为空,则会返回该字段。
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.过期后不再出现服务项,且无法给用户发送会员服务消息通知 可选取值
available_begin_time 选填 string(32) 【有效期开始时间】 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(32) 【有效期结束时间】 type为FIX_TERM_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] 【平台提供的通用开卡信息字段】 平台提供的通用开卡信息字段。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。 可选取值
custom_field_list 选填 array[object] 【商家自定义的开卡信息字段】 商家自定义的开卡信息字段。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。当前最多只允许传入1项。
|
请求示例
需配合微信支付工具库 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 CreateCard { 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/card-member/cards"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 CreateCard client = new CreateCard( 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 CreateCardRequest request = new CreateCardRequest(); 41 request.outRequestNo = "100002322019090134234sfdf"; 42 request.brandId = "1004"; 43 request.appid = "wxea9c30890f48d5ae"; 44 request.cardType = CardType.NORMAL; 45 request.cardTitle = "测试卡"; 46 request.cardColor = "#FFFF00"; 47 request.cardPictureUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/0"; 48 request.codeMode = CodeMode.SYSTEM_ALLOCATE; 49 request.codeType = CodeType.BAR_CODE; 50 request.codeJumpInformation = new CodeJumpInfo(); 51 request.codeJumpInformation.jumpAppid = "wxea9c30a90fs8d3fe"; 52 request.codeJumpInformation.jumpPath = "/pages/code/code"; 53 request.benefits = "会员折扣、专属价"; 54 request.notifyUrl = "https://www.weixin.qq.com/wxpay/notify.php"; 55 request.needPinned = true; 56 request.needDisplayLevel = true; 57 request.initLevel = "白银会员"; 58 request.servicePhone = "010-8877xxxx"; 59 request.legalAgreement = "商家需在 48 小时内发货,若商品存在质量问题,用户可在 7 天内申请退货。"; 60 request.validDateInformation = new DateInfo(); 61 request.validDateInformation.type = DateType.PERMANENT; 62 request.validDateInformation.availableBeginTime = "2020-05-20T13:29:35.120+08:00"; 63 request.validDateInformation.availableEndTime = "2020-05-20T13:29:35.120+08:00"; 64 request.validDateInformation.availableDayAfterReceive = 30L; 65 request.memberInformation = new MemberInfo(); 66 request.memberInformation.jumpAppid = "wxea9c30a90fs8d3fe"; 67 request.memberInformation.jumpPath = "/pages/points/points"; 68 request.pointsInformation = new PointsInfo(); 69 request.pointsInformation.jumpAppid = "wxea9c30a90fs8d3fe"; 70 request.pointsInformation.jumpPath = "/pages/points/points"; 71 request.balanceInformation = new BalanceInfo(); 72 request.balanceInformation.jumpAppid = "wxea9c30a90fs8d3fe"; 73 request.balanceInformation.jumpPath = "/pages/balance/balance"; 74 request.purchaseInformation = new PurchaseInfo(); 75 request.purchaseInformation.price = 100L; 76 request.purchaseInformation.jumpAppid = "wxea9c30a90fs8d3fe"; 77 request.purchaseInformation.jumpPath = "/pages/purchase/purchase"; 78 request.userInformation = new UserInfoForm(); 79 request.userInformation.commonFieldList = new ArrayList<>(); 80 { 81 request.userInformation.commonFieldList.add(CommonFieldFlag.USER_FORM_FLAG_SEX); 82 }; 83 request.userInformation.customFieldList = new ArrayList<>(); 84 { 85 UserCustomFieldForm customFieldListItem = new UserCustomFieldForm(); 86 customFieldListItem.type = CustomFieldType.CHECK_BOX; 87 customFieldListItem.name = "喜欢的运动"; 88 customFieldListItem.values = new ArrayList<>(); 89 { 90 customFieldListItem.values.add("篮球"); 91 }; 92 request.userInformation.customFieldList.add(customFieldListItem); 93 }; 94 try { 95 Card response = client.run(request); 96 97 // TODO: 请求成功,继续业务逻辑 98 System.out.println(response); 99 } catch (WXPayUtility.ApiException e) { 100 // TODO: 请求失败,根据状态码执行不同的逻辑 101 e.printStackTrace(); 102 } 103 } 104 105 public Card run(CreateCardRequest request) { 106 String uri = PATH; 107 String reqBody = WXPayUtility.toJson(request); 108 109 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 110 reqBuilder.addHeader("Accept", "application/json"); 111 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 112 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 113 reqBuilder.addHeader("Content-Type", "application/json"); 114 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 115 reqBuilder.method(METHOD, requestBody); 116 Request httpRequest = reqBuilder.build(); 117 118 // 发送HTTP请求 119 OkHttpClient client = new OkHttpClient.Builder().build(); 120 try (Response httpResponse = client.newCall(httpRequest).execute()) { 121 String respBody = WXPayUtility.extractBody(httpResponse); 122 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 123 // 2XX 成功,验证应答签名 124 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 125 httpResponse.headers(), respBody); 126 127 // 从HTTP应答报文构建返回数据 128 return WXPayUtility.fromJson(respBody, Card.class); 129 } else { 130 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 131 } 132 } catch (IOException e) { 133 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 134 } 135 } 136 137 private final String mchid; 138 private final String certificateSerialNo; 139 private final PrivateKey privateKey; 140 private final String wechatPayPublicKeyId; 141 private final PublicKey wechatPayPublicKey; 142 143 public CreateCard(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 144 this.mchid = mchid; 145 this.certificateSerialNo = certificateSerialNo; 146 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 147 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 148 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 149 } 150 151 public static class CreateCardRequest { 152 @SerializedName("out_request_no") 153 public String outRequestNo; 154 155 @SerializedName("brand_id") 156 public String brandId; 157 158 @SerializedName("appid") 159 public String appid; 160 161 @SerializedName("card_type") 162 public CardType cardType; 163 164 @SerializedName("card_title") 165 public String cardTitle; 166 167 @SerializedName("card_color") 168 public String cardColor; 169 170 @SerializedName("card_picture_url") 171 public String cardPictureUrl; 172 173 @SerializedName("code_mode") 174 public CodeMode codeMode; 175 176 @SerializedName("code_type") 177 public CodeType codeType; 178 179 @SerializedName("code_jump_information") 180 public CodeJumpInfo codeJumpInformation; 181 182 @SerializedName("benefits") 183 public String benefits; 184 185 @SerializedName("notify_url") 186 public String notifyUrl; 187 188 @SerializedName("need_pinned") 189 public Boolean needPinned; 190 191 @SerializedName("need_display_level") 192 public Boolean needDisplayLevel; 193 194 @SerializedName("init_level") 195 public String initLevel; 196 197 @SerializedName("service_phone") 198 public String servicePhone; 199 200 @SerializedName("legal_agreement") 201 public String legalAgreement; 202 203 @SerializedName("valid_date_information") 204 public DateInfo validDateInformation; 205 206 @SerializedName("member_information") 207 public MemberInfo memberInformation; 208 209 @SerializedName("points_information") 210 public PointsInfo pointsInformation; 211 212 @SerializedName("balance_information") 213 public BalanceInfo balanceInformation; 214 215 @SerializedName("purchase_information") 216 public PurchaseInfo purchaseInformation; 217 218 @SerializedName("user_information") 219 public UserInfoForm userInformation; 220 } 221 222 public static class Card { 223 @SerializedName("out_request_no") 224 public String outRequestNo; 225 226 @SerializedName("card_id") 227 public String cardId; 228 229 @SerializedName("brand_id") 230 public String brandId; 231 232 @SerializedName("appid") 233 public String appid; 234 235 @SerializedName("card_type") 236 public CardType cardType; 237 238 @SerializedName("card_title") 239 public String cardTitle; 240 241 @SerializedName("card_color") 242 public String cardColor; 243 244 @SerializedName("card_picture_url") 245 public String cardPictureUrl; 246 247 @SerializedName("code_mode") 248 public CodeMode codeMode; 249 250 @SerializedName("code_type") 251 public CodeType codeType; 252 253 @SerializedName("code_jump_information") 254 public CodeJumpInfo codeJumpInformation; 255 256 @SerializedName("benefits") 257 public String benefits; 258 259 @SerializedName("notify_url") 260 public String notifyUrl; 261 262 @SerializedName("need_pinned") 263 public Boolean needPinned; 264 265 @SerializedName("need_display_level") 266 public Boolean needDisplayLevel; 267 268 @SerializedName("init_level") 269 public String initLevel; 270 271 @SerializedName("service_phone") 272 public String servicePhone; 273 274 @SerializedName("legal_agreement") 275 public String legalAgreement; 276 277 @SerializedName("valid_date_information") 278 public DateInfo validDateInformation; 279 280 @SerializedName("member_information") 281 public MemberInfo memberInformation; 282 283 @SerializedName("points_information") 284 public PointsInfo pointsInformation; 285 286 @SerializedName("balance_information") 287 public BalanceInfo balanceInformation; 288 289 @SerializedName("purchase_information") 290 public PurchaseInfo purchaseInformation; 291 292 @SerializedName("user_information") 293 public UserInfoForm userInformation; 294 295 @SerializedName("state") 296 public CardState state; 297 298 @SerializedName("create_time") 299 public String createTime; 300 301 @SerializedName("modify_time") 302 public String modifyTime; 303 } 304 305 public enum CardType { 306 @SerializedName("PURCHASE") 307 PURCHASE, 308 @SerializedName("NORMAL") 309 NORMAL, 310 @SerializedName("BALANCE") 311 BALANCE 312 } 313 314 public enum CodeMode { 315 @SerializedName("SYSTEM_ALLOCATE") 316 SYSTEM_ALLOCATE, 317 @SerializedName("MERCHANT_ALLOCATE") 318 MERCHANT_ALLOCATE 319 } 320 321 public enum CodeType { 322 @SerializedName("NONE_CODE") 323 NONE_CODE, 324 @SerializedName("BAR_CODE") 325 BAR_CODE, 326 @SerializedName("QR_CODE") 327 QR_CODE, 328 @SerializedName("BAR_CODE_AND_QR_CODE") 329 BAR_CODE_AND_QR_CODE, 330 @SerializedName("JUMP_MINI_PROGRAM") 331 JUMP_MINI_PROGRAM 332 } 333 334 public static class CodeJumpInfo { 335 @SerializedName("jump_appid") 336 public String jumpAppid; 337 338 @SerializedName("jump_path") 339 public String jumpPath; 340 } 341 342 public static class DateInfo { 343 @SerializedName("type") 344 public DateType type; 345 346 @SerializedName("available_begin_time") 347 public String availableBeginTime; 348 349 @SerializedName("available_end_time") 350 public String availableEndTime; 351 352 @SerializedName("available_day_after_receive") 353 public Long availableDayAfterReceive; 354 } 355 356 public static class MemberInfo { 357 @SerializedName("jump_appid") 358 public String jumpAppid; 359 360 @SerializedName("jump_path") 361 public String jumpPath; 362 } 363 364 public static class PointsInfo { 365 @SerializedName("jump_appid") 366 public String jumpAppid; 367 368 @SerializedName("jump_path") 369 public String jumpPath; 370 } 371 372 public static class BalanceInfo { 373 @SerializedName("jump_appid") 374 public String jumpAppid; 375 376 @SerializedName("jump_path") 377 public String jumpPath; 378 } 379 380 public static class PurchaseInfo { 381 @SerializedName("price") 382 public Long price; 383 384 @SerializedName("jump_appid") 385 public String jumpAppid; 386 387 @SerializedName("jump_path") 388 public String jumpPath; 389 } 390 391 public static class UserInfoForm { 392 @SerializedName("common_field_list") 393 public List<CommonFieldFlag> commonFieldList; 394 395 @SerializedName("custom_field_list") 396 public List<UserCustomFieldForm> customFieldList; 397 } 398 399 public enum CardState { 400 @SerializedName("CARD_EFFECTIVE") 401 CARD_EFFECTIVE, 402 @SerializedName("CARD_INVALID") 403 CARD_INVALID 404 } 405 406 public enum DateType { 407 @SerializedName("FIX_TIME_RANGE") 408 FIX_TIME_RANGE, 409 @SerializedName("FIX_TERM") 410 FIX_TERM, 411 @SerializedName("PERMANENT") 412 PERMANENT 413 } 414 415 public enum CommonFieldFlag { 416 @SerializedName("USER_FORM_FLAG_SEX") 417 USER_FORM_FLAG_SEX, 418 @SerializedName("USER_FORM_FLAG_NAME") 419 USER_FORM_FLAG_NAME, 420 @SerializedName("USER_FORM_FLAG_BIRTHDAY") 421 USER_FORM_FLAG_BIRTHDAY, 422 @SerializedName("USER_FORM_FLAG_ADDRESS") 423 USER_FORM_FLAG_ADDRESS, 424 @SerializedName("USER_FORM_FLAG_EMAIL") 425 USER_FORM_FLAG_EMAIL, 426 @SerializedName("USER_FORM_FLAG_CITY") 427 USER_FORM_FLAG_CITY 428 } 429 430 public static class UserCustomFieldForm { 431 @SerializedName("type") 432 public CustomFieldType type; 433 434 @SerializedName("name") 435 public String name; 436 437 @SerializedName("values") 438 public List<String> values; 439 } 440 441 public enum CustomFieldType { 442 @SerializedName("CHECK_BOX") 443 CHECK_BOX, 444 @SerializedName("RADIO") 445 RADIO 446 } 447 448} 449
需配合微信支付工具库 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) 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 := &CreateCardRequest{ 27 OutRequestNo: wxpay_utility.String("100002322019090134234sfdf"), 28 BrandId: wxpay_utility.String("1004"), 29 Appid: wxpay_utility.String("wxea9c30890f48d5ae"), 30 CardType: CARDTYPE_NORMAL.Ptr(), 31 CardTitle: wxpay_utility.String("测试卡"), 32 CardColor: wxpay_utility.String("#FFFF00"), 33 CardPictureUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/0"), 34 CodeMode: CODEMODE_SYSTEM_ALLOCATE.Ptr(), 35 CodeType: CODETYPE_BAR_CODE.Ptr(), 36 CodeJumpInformation: &CodeJumpInfo{ 37 JumpAppid: wxpay_utility.String("wxea9c30a90fs8d3fe"), 38 JumpPath: wxpay_utility.String("/pages/code/code"), 39 }, 40 Benefits: wxpay_utility.String("会员折扣、专属价"), 41 NotifyUrl: wxpay_utility.String("https://www.weixin.qq.com/wxpay/notify.php"), 42 NeedPinned: wxpay_utility.Bool(true), 43 NeedDisplayLevel: wxpay_utility.Bool(true), 44 InitLevel: wxpay_utility.String("白银会员"), 45 ServicePhone: wxpay_utility.String("010-8877xxxx"), 46 LegalAgreement: wxpay_utility.String("商家需在 48 小时内发货,若商品存在质量问题,用户可在 7 天内申请退货。"), 47 ValidDateInformation: &DateInfo{ 48 Type: DATETYPE_PERMANENT.Ptr(), 49 AvailableBeginTime: wxpay_utility.String("2020-05-20T13:29:35.120+08:00"), 50 AvailableEndTime: wxpay_utility.String("2020-05-20T13:29:35.120+08:00"), 51 AvailableDayAfterReceive: wxpay_utility.Int64(30), 52 }, 53 MemberInformation: &MemberInfo{ 54 JumpAppid: wxpay_utility.String("wxea9c30a90fs8d3fe"), 55 JumpPath: wxpay_utility.String("/pages/points/points"), 56 }, 57 PointsInformation: &PointsInfo{ 58 JumpAppid: wxpay_utility.String("wxea9c30a90fs8d3fe"), 59 JumpPath: wxpay_utility.String("/pages/points/points"), 60 }, 61 BalanceInformation: &BalanceInfo{ 62 JumpAppid: wxpay_utility.String("wxea9c30a90fs8d3fe"), 63 JumpPath: wxpay_utility.String("/pages/balance/balance"), 64 }, 65 PurchaseInformation: &PurchaseInfo{ 66 Price: wxpay_utility.Int64(100), 67 JumpAppid: wxpay_utility.String("wxea9c30a90fs8d3fe"), 68 JumpPath: wxpay_utility.String("/pages/purchase/purchase"), 69 }, 70 UserInformation: &UserInfoForm{ 71 CommonFieldList: []CommonFieldFlag{COMMONFIELDFLAG_USER_FORM_FLAG_SEX}, 72 CustomFieldList: []UserCustomFieldForm{UserCustomFieldForm{ 73 Type: CUSTOMFIELDTYPE_CHECK_BOX.Ptr(), 74 Name: wxpay_utility.String("喜欢的运动"), 75 Values: []string{"篮球"}, 76 }}, 77 }, 78 } 79 80 response, err := CreateCard(config, request) 81 if err != nil { 82 fmt.Printf("请求失败: %+v\n", err) 83 // TODO: 请求失败,根据状态码执行不同的处理 84 return 85 } 86 87 // TODO: 请求成功,继续业务逻辑 88 fmt.Printf("请求成功: %+v\n", response) 89} 90 91func CreateCard(config *wxpay_utility.MchConfig, request *CreateCardRequest) (response *Card, err error) { 92 const ( 93 host = "https://api.mch.weixin.qq.com" 94 method = "POST" 95 path = "/v3/brand/partner/card-member/cards" 96 ) 97 98 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 99 if err != nil { 100 return nil, err 101 } 102 reqBody, err := json.Marshal(request) 103 if err != nil { 104 return nil, err 105 } 106 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 107 if err != nil { 108 return nil, err 109 } 110 httpRequest.Header.Set("Accept", "application/json") 111 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 112 httpRequest.Header.Set("Content-Type", "application/json") 113 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 114 if err != nil { 115 return nil, err 116 } 117 httpRequest.Header.Set("Authorization", authorization) 118 119 client := &http.Client{} 120 httpResponse, err := client.Do(httpRequest) 121 if err != nil { 122 return nil, err 123 } 124 125 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 126 if err != nil { 127 return nil, err 128 } 129 130 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 131 // 2XX 成功,验证应答签名 132 err = wxpay_utility.ValidateResponse( 133 config.WechatPayPublicKeyId(), 134 config.WechatPayPublicKey(), 135 &httpResponse.Header, 136 respBody, 137 ) 138 if err != nil { 139 return nil, err 140 } 141 142 if err := json.Unmarshal(respBody, response); err != nil { 143 return nil, err 144 } 145 146 return response, nil 147 } else { 148 return nil, wxpay_utility.NewApiException( 149 httpResponse.StatusCode, 150 httpResponse.Header, 151 respBody, 152 ) 153 } 154} 155 156type CreateCardRequest struct { 157 OutRequestNo *string `json:"out_request_no,omitempty"` 158 BrandId *string `json:"brand_id,omitempty"` 159 Appid *string `json:"appid,omitempty"` 160 CardType *CardType `json:"card_type,omitempty"` 161 CardTitle *string `json:"card_title,omitempty"` 162 CardColor *string `json:"card_color,omitempty"` 163 CardPictureUrl *string `json:"card_picture_url,omitempty"` 164 CodeMode *CodeMode `json:"code_mode,omitempty"` 165 CodeType *CodeType `json:"code_type,omitempty"` 166 CodeJumpInformation *CodeJumpInfo `json:"code_jump_information,omitempty"` 167 Benefits *string `json:"benefits,omitempty"` 168 NotifyUrl *string `json:"notify_url,omitempty"` 169 NeedPinned *bool `json:"need_pinned,omitempty"` 170 NeedDisplayLevel *bool `json:"need_display_level,omitempty"` 171 InitLevel *string `json:"init_level,omitempty"` 172 ServicePhone *string `json:"service_phone,omitempty"` 173 LegalAgreement *string `json:"legal_agreement,omitempty"` 174 ValidDateInformation *DateInfo `json:"valid_date_information,omitempty"` 175 MemberInformation *MemberInfo `json:"member_information,omitempty"` 176 PointsInformation *PointsInfo `json:"points_information,omitempty"` 177 BalanceInformation *BalanceInfo `json:"balance_information,omitempty"` 178 PurchaseInformation *PurchaseInfo `json:"purchase_information,omitempty"` 179 UserInformation *UserInfoForm `json:"user_information,omitempty"` 180} 181 182type Card struct { 183 OutRequestNo *string `json:"out_request_no,omitempty"` 184 CardId *string `json:"card_id,omitempty"` 185 BrandId *string `json:"brand_id,omitempty"` 186 Appid *string `json:"appid,omitempty"` 187 CardType *CardType `json:"card_type,omitempty"` 188 CardTitle *string `json:"card_title,omitempty"` 189 CardColor *string `json:"card_color,omitempty"` 190 CardPictureUrl *string `json:"card_picture_url,omitempty"` 191 CodeMode *CodeMode `json:"code_mode,omitempty"` 192 CodeType *CodeType `json:"code_type,omitempty"` 193 CodeJumpInformation *CodeJumpInfo `json:"code_jump_information,omitempty"` 194 Benefits *string `json:"benefits,omitempty"` 195 NotifyUrl *string `json:"notify_url,omitempty"` 196 NeedPinned *bool `json:"need_pinned,omitempty"` 197 NeedDisplayLevel *bool `json:"need_display_level,omitempty"` 198 InitLevel *string `json:"init_level,omitempty"` 199 ServicePhone *string `json:"service_phone,omitempty"` 200 LegalAgreement *string `json:"legal_agreement,omitempty"` 201 ValidDateInformation *DateInfo `json:"valid_date_information,omitempty"` 202 MemberInformation *MemberInfo `json:"member_information,omitempty"` 203 PointsInformation *PointsInfo `json:"points_information,omitempty"` 204 BalanceInformation *BalanceInfo `json:"balance_information,omitempty"` 205 PurchaseInformation *PurchaseInfo `json:"purchase_information,omitempty"` 206 UserInformation *UserInfoForm `json:"user_information,omitempty"` 207 State *CardState `json:"state,omitempty"` 208 CreateTime *string `json:"create_time,omitempty"` 209 ModifyTime *string `json:"modify_time,omitempty"` 210} 211 212type CardType string 213 214func (e CardType) Ptr() *CardType { 215 return &e 216} 217 218const ( 219 CARDTYPE_PURCHASE CardType = "PURCHASE" 220 CARDTYPE_NORMAL CardType = "NORMAL" 221 CARDTYPE_BALANCE CardType = "BALANCE" 222) 223 224type CodeMode string 225 226func (e CodeMode) Ptr() *CodeMode { 227 return &e 228} 229 230const ( 231 CODEMODE_SYSTEM_ALLOCATE CodeMode = "SYSTEM_ALLOCATE" 232 CODEMODE_MERCHANT_ALLOCATE CodeMode = "MERCHANT_ALLOCATE" 233) 234 235type CodeType string 236 237func (e CodeType) Ptr() *CodeType { 238 return &e 239} 240 241const ( 242 CODETYPE_NONE_CODE CodeType = "NONE_CODE" 243 CODETYPE_BAR_CODE CodeType = "BAR_CODE" 244 CODETYPE_QR_CODE CodeType = "QR_CODE" 245 CODETYPE_BAR_CODE_AND_QR_CODE CodeType = "BAR_CODE_AND_QR_CODE" 246 CODETYPE_JUMP_MINI_PROGRAM CodeType = "JUMP_MINI_PROGRAM" 247) 248 249type CodeJumpInfo struct { 250 JumpAppid *string `json:"jump_appid,omitempty"` 251 JumpPath *string `json:"jump_path,omitempty"` 252} 253 254type DateInfo struct { 255 Type *DateType `json:"type,omitempty"` 256 AvailableBeginTime *string `json:"available_begin_time,omitempty"` 257 AvailableEndTime *string `json:"available_end_time,omitempty"` 258 AvailableDayAfterReceive *int64 `json:"available_day_after_receive,omitempty"` 259} 260 261type MemberInfo struct { 262 JumpAppid *string `json:"jump_appid,omitempty"` 263 JumpPath *string `json:"jump_path,omitempty"` 264} 265 266type PointsInfo struct { 267 JumpAppid *string `json:"jump_appid,omitempty"` 268 JumpPath *string `json:"jump_path,omitempty"` 269} 270 271type BalanceInfo struct { 272 JumpAppid *string `json:"jump_appid,omitempty"` 273 JumpPath *string `json:"jump_path,omitempty"` 274} 275 276type PurchaseInfo struct { 277 Price *int64 `json:"price,omitempty"` 278 JumpAppid *string `json:"jump_appid,omitempty"` 279 JumpPath *string `json:"jump_path,omitempty"` 280} 281 282type UserInfoForm struct { 283 CommonFieldList []CommonFieldFlag `json:"common_field_list,omitempty"` 284 CustomFieldList []UserCustomFieldForm `json:"custom_field_list,omitempty"` 285} 286 287type CardState string 288 289func (e CardState) Ptr() *CardState { 290 return &e 291} 292 293const ( 294 CARDSTATE_CARD_EFFECTIVE CardState = "CARD_EFFECTIVE" 295 CARDSTATE_CARD_INVALID CardState = "CARD_INVALID" 296) 297 298type DateType string 299 300func (e DateType) Ptr() *DateType { 301 return &e 302} 303 304const ( 305 DATETYPE_FIX_TIME_RANGE DateType = "FIX_TIME_RANGE" 306 DATETYPE_FIX_TERM DateType = "FIX_TERM" 307 DATETYPE_PERMANENT DateType = "PERMANENT" 308) 309 310type CommonFieldFlag string 311 312func (e CommonFieldFlag) Ptr() *CommonFieldFlag { 313 return &e 314} 315 316const ( 317 COMMONFIELDFLAG_USER_FORM_FLAG_SEX CommonFieldFlag = "USER_FORM_FLAG_SEX" 318 COMMONFIELDFLAG_USER_FORM_FLAG_NAME CommonFieldFlag = "USER_FORM_FLAG_NAME" 319 COMMONFIELDFLAG_USER_FORM_FLAG_BIRTHDAY CommonFieldFlag = "USER_FORM_FLAG_BIRTHDAY" 320 COMMONFIELDFLAG_USER_FORM_FLAG_ADDRESS CommonFieldFlag = "USER_FORM_FLAG_ADDRESS" 321 COMMONFIELDFLAG_USER_FORM_FLAG_EMAIL CommonFieldFlag = "USER_FORM_FLAG_EMAIL" 322 COMMONFIELDFLAG_USER_FORM_FLAG_CITY CommonFieldFlag = "USER_FORM_FLAG_CITY" 323) 324 325type UserCustomFieldForm struct { 326 Type *CustomFieldType `json:"type,omitempty"` 327 Name *string `json:"name,omitempty"` 328 Values []string `json:"values,omitempty"` 329} 330 331type CustomFieldType string 332 333func (e CustomFieldType) Ptr() *CustomFieldType { 334 return &e 335} 336 337const ( 338 CUSTOMFIELDTYPE_CHECK_BOX CustomFieldType = "CHECK_BOX" 339 CUSTOMFIELDTYPE_RADIO CustomFieldType = "RADIO" 340) 341
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/brand/partner/card-member/cards \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "out_request_no" : "100002322019090134234sfdf", 8 "brand_id" : "1004", 9 "appid" : "wxea9c30890f48d5ae", 10 "card_type" : "NORMAL", 11 "card_title" : "测试卡", 12 "card_color" : "#FFFF00", 13 "card_picture_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/0", 14 "code_mode" : "SYSTEM_ALLOCATE", 15 "code_type" : "BAR_CODE", 16 "code_jump_information" : { 17 "jump_appid" : "wxea9c30a90fs8d3fe", 18 "jump_path" : "/pages/code/code" 19 }, 20 "benefits" : "会员折扣、专属价", 21 "notify_url" : "https://www.weixin.qq.com/wxpay/notify.php", 22 "need_pinned" : true, 23 "need_display_level" : true, 24 "init_level" : "白银会员", 25 "service_phone" : "010-8877xxxx", 26 "legal_agreement" : "商家需在 48 小时内发货,若商品存在质量问题,用户可在 7 天内申请退货。", 27 "valid_date_information" : { 28 "type" : "PERMANENT", 29 "available_begin_time" : "2020-05-20T13:29:35.120+08:00", 30 "available_end_time" : "2020-05-20T13:29:35.120+08:00", 31 "available_day_after_receive" : 30 32 }, 33 "member_information" : { 34 "jump_appid" : "wxea9c30a90fs8d3fe", 35 "jump_path" : "/pages/points/points" 36 }, 37 "points_information" : { 38 "jump_appid" : "wxea9c30a90fs8d3fe", 39 "jump_path" : "/pages/points/points" 40 }, 41 "balance_information" : { 42 "jump_appid" : "wxea9c30a90fs8d3fe", 43 "jump_path" : "/pages/balance/balance" 44 }, 45 "purchase_information" : { 46 "price" : 100, 47 "jump_appid" : "wxea9c30a90fs8d3fe", 48 "jump_path" : "/pages/purchase/purchase" 49 }, 50 "user_information" : { 51 "common_field_list" : [ 52 "USER_FORM_FLAG_SEX" 53 ], 54 "custom_field_list" : [ 55 { 56 "type" : "CHECK_BOX", 57 "name" : "喜欢的运动", 58 "values" : [ 59 "篮球" 60 ] 61 } 62 ] 63 } 64 }' 65
应答参数
200 OK
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 微信支付系统分配,用户领取会员卡时从微信系统分配12位数字作为会员code;(2)MERCHANT_ALLOCATE 商家预存code,商家可提前通过导入预存code接口导入code,用户领取会员卡时平台从商家导入的code中随机分配作为会员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(2048)
【商家法务协议】 商家法务协议是用户与商家之间签订的具有法律效力的合同文件,旨在明确双方在交易、服务提供、权利义务等方面的规则,以保障交易安全、规范商业行为,并在纠纷发生时提供法律依据。
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.过期后不再出现服务项,且无法给用户发送会员服务消息通知 可选取值
available_begin_time 选填 string(32) 【有效期开始时间】 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(32) 【有效期结束时间】 type为FIX_TERM_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] 【平台提供的通用开卡信息字段】 平台提供的通用开卡信息字段。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。 可选取值
custom_field_list 选填 array[object] 【商家自定义的开卡信息字段】 商家自定义的开卡信息字段。若商户在会员卡模板中设置该值,则查询结果中会返回给商户。当前最多只允许传入1项。
|
state 必填 string
【状态】 会员卡状态信息
可选取值
CARD_EFFECTIVE
: 生效中CARD_INVALID
: 已失效
create_time 必填 string(32)
【创建时间】 创建会员卡的时间,需遵循 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(32)
【更新时间】 更新会员卡的时间,需遵循 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秒。
应答示例
200 OK
1{ 2 "out_request_no" : "100002322019090134234sfdf", 3 "card_id" : "pbLatjvWOibDc5-TBnbUk1pD12o0", 4 "brand_id" : "1004", 5 "appid" : "wxea9c30890f48d5ae", 6 "card_type" : "NORMAL", 7 "card_title" : "测试卡", 8 "card_color" : "#FFFF00", 9 "card_picture_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/0", 10 "code_mode" : "SYSTEM_ALLOCATE", 11 "code_type" : "BAR_CODE", 12 "code_jump_information" : { 13 "jump_appid" : "wxea9c30a90fs8d3fe", 14 "jump_path" : "/pages/code/code" 15 }, 16 "benefits" : "会员折扣、专属价", 17 "notify_url" : "https://www.weixin.qq.com/wxpay/notify.php", 18 "need_pinned" : true, 19 "need_display_level" : true, 20 "init_level" : "白银会员", 21 "service_phone" : "010-8877xxxx", 22 "legal_agreement" : "商家需在 48 小时内发货,若商品存在质量问题,用户可在 7 天内申请退货。", 23 "valid_date_information" : { 24 "type" : "PERMANENT", 25 "available_begin_time" : "2020-05-20T13:29:35.120+08:00", 26 "available_end_time" : "2020-05-20T13:29:35.120+08:00", 27 "available_day_after_receive" : 30 28 }, 29 "member_information" : { 30 "jump_appid" : "wxea9c30a90fs8d3fe", 31 "jump_path" : "/pages/points/points" 32 }, 33 "points_information" : { 34 "jump_appid" : "wxea9c30a90fs8d3fe", 35 "jump_path" : "/pages/points/points" 36 }, 37 "balance_information" : { 38 "jump_appid" : "wxea9c30a90fs8d3fe", 39 "jump_path" : "/pages/balance/balance" 40 }, 41 "purchase_information" : { 42 "price" : 100, 43 "jump_appid" : "wxea9c30a90fs8d3fe", 44 "jump_path" : "/pages/purchase/purchase" 45 }, 46 "user_information" : { 47 "common_field_list" : [ 48 "USER_FORM_FLAG_SEX" 49 ], 50 "custom_field_list" : [ 51 { 52 "type" : "CHECK_BOX", 53 "name" : "喜欢的运动", 54 "values" : [ 55 "篮球" 56 ] 57 } 58 ] 59 }, 60 "state" : "CARD_EFFECTIVE", 61 "create_time" : "2020-05-20T13:29:35.120+08:00", 62 "modify_time" : "2020-05-20T13:29:35.120+08:00" 63} 64
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | INVALID_REQUEST | 品牌ID与商家AppID没有绑定 | 请登录品牌经营平台进行绑定 |
400 | INVALID_REQUEST | need_display_level为true时,init_level不能为空 | 请填写init_level |