向用户发放商品券
更新时间:2025.08.28品牌方可以通过本接口向用户发放指定商品券批次,能否发放受限于商品券批次的发放限额:
商品券批次总预算
商品券批次每日预算(如果有)
商品券批次每人限领(如果有)
前置条件:
已创建商品券批次,商品券批次处于
SENDING状态商品券批次所属商品券的
usage_mode不为PROGRESSIVE_BUNDLEusage_mode为PROGRESSIVE_BUNDLE的批次在批次组内,不可使用本接口,请使用【向用户发放商品券批次组API】
接口说明
支持商户:【品牌商户】
请求方式:【POST】/brand/marketing/product-coupon/users/{openid}/coupons
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
接口限频:500/秒(品牌ID维度)
请求参数
折叠全部参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Content-Type 必填 string
请设置为application/json
Wechatpay-Serial 必填 string
【微信支付公钥ID】 请传入brand_id对应的微信支付公钥ID,接口将会校验两者的关联关系,参考微信支付公钥产品简介及使用说明获取微信支付公钥ID和相关的介绍。以下两种场景将使用到微信支付公钥: 1、接收到接口的返回内容,需要使用微信支付公钥进行验签; 2、调用含有敏感信息参数(如姓名、身份证号码)的接口时,需要使用微信支付公钥加密敏感信息后再传输参数,加密指引请参考微信支付公钥加密敏感信息指引。
path 路径参数
openid 必填 string
【用户OpenID】 OpenID信息,用户在AppID下的唯一标识,获取方式参考OpenID
body 包体参数
product_coupon_id 必填 string
【商品券ID】 商品券的唯一标识,创建商品券时由微信支付生成
stock_id 必填 string
【批次ID】 商品券批次的唯一标识,商品券批次创建时由微信支付生成(可使用【创建商品券API】或【添加商品券批次API】创建),请确保该批次属于 product_coupon_id 对应的商品券
coupon_code 选填 string(40)
【用户商品券Code】 用户商品券的唯一标识,给用户发券时需要为该用户的券分配,可使用 数字、大小写字母、下划线_、短横线- 组成,长度不超过40个字符。
当且仅当 coupon_code_mode 为 API_ASSIGN 时必传,其他模式下用户商品券Code由微信支付分配,不允许传入。
appid 必填 string
【公众账号ID】 公众账号ID也称AppID,是(微信开放平台、微信公众平台)为开发者提供的一个唯一标识,用于识别开发者的应用程序(APP、小程序、公众号)。 开发者需要先在微信开放平台或微信公众平台中申请ID,然后在品牌经营平台中绑定,详见品牌经营平台指引。
send_request_no 必填 string(128)
【发券请求单号】 品牌给用户发券的请求流水号,品牌侧需保持唯一性,可使用 数字、大小写字母、下划线_、短横线- 组成,长度在6-128个字符之间
attach 选填 string(150)
【自定义附加信息】 发券时品牌方可以使用该字段附带自定义附加信息,长度限制150个UTF-8字符。微信支付不会解析该信息,仅在查询用户商品券和回调中原样返回。
注: 发券渠道多样,只有品牌方通过此接口发放以及调用「向用户预发放商品券」接口并在领券组件中发放的券才会在查询和回调中携带此字段,其他渠道发放的券 attach 为空。
coupon_tag_info 选填 object
【用户商品券标签信息】 用户商品券标签信息
coupon_tag_list 选填 array[string]
【用户商品券标签列表】 用户商品券标签列表
可选取值
MEMBER: 会员标签,标识该用户商品券为会员券MEMBER_ACTIVITY: 会员活动标签,标识该用户券为会员活动券
member_tag_info 选填 object
【会员标签信息】 当用户商品券标签列表中有MEMBER时,该字段必填
member_card_id 选填 string
【会员卡模板ID】 通过商家名片会员API创建会员卡模板成功后,获得的会员卡模板ID
请求示例
POST
发送会员券
1curl -X POST \ 2 https://api.mch.weixin.qq.com/brand/marketing/product-coupon/users/oh-394z-6CGkNoJrsDLTTUKiAnp4/coupons \ 3 -H "Authorization: WECHATPAY-BRAND-SHA256-RSA2048 brand_id=\"XXXX\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: PUB_KEY_ID_XXXX" \ 6 -H "Content-Type: application/json" \ 7 -d '{ 8 "coupon_code" : "Code_123456", 9 "product_coupon_id" : "1000000013", 10 "appid" : "wx233544546545989", 11 "attach" : "any attach content", 12 "coupon_tag_info" : { 13 "coupon_tag_list" : [ 14 "MEMBER" 15 ], 16 "member_tag_info" : { 17 "member_card_id" : "MemberCardId_1234567890" 18 } 19 }, 20 "stock_id" : "1000000013001", 21 "send_request_no" : "MCHSEND202003101234" 22 }' 23
发放普通券
1curl -X POST \ 2 https://api.mch.weixin.qq.com/brand/marketing/product-coupon/users/oh-394z-6CGkNoJrsDLTTUKiAnp4/coupons \ 3 -H "Authorization: WECHATPAY-BRAND-SHA256-RSA2048 brand_id=\"XXXX\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: PUB_KEY_ID_XXXX" \ 6 -H "Content-Type: application/json" \ 7 -d '{ 8 "coupon_code" : "Code_123456", 9 "product_coupon_id" : "1000000013", 10 "appid" : "wx233544546545989", 11 "attach" : "any attach content", 12 "stock_id" : "1000000013001", 13 "send_request_no" : "MCHSEND202003101234" 14 }' 15
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayBrandUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/brand/4015826861 4 5import com.google.gson.annotations.SerializedName; 6import com.google.gson.annotations.Expose; 7import okhttp3.MediaType; 8import okhttp3.OkHttpClient; 9import okhttp3.Request; 10import okhttp3.RequestBody; 11import okhttp3.Response; 12 13import java.io.IOException; 14import java.io.UncheckedIOException; 15import java.security.PrivateKey; 16import java.security.PublicKey; 17import java.util.ArrayList; 18import java.util.HashMap; 19import java.util.List; 20import java.util.Map; 21 22/** 23 * 向用户发放商品券 24 */ 25public class SendUserProductCoupon { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/brand/marketing/product-coupon/users/{openid}/coupons"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 32 SendUserProductCoupon client = new SendUserProductCoupon( 33 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 34 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 35 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 SendUserProductCouponRequest request = new SendUserProductCouponRequest(); 41 request.productCouponId = "1000000013"; 42 request.stockId = "1000000013001"; 43 request.couponCode = "Code_123456"; 44 request.appid = "wx233544546545989"; 45 request.openid = "oh-394z-6CGkNoJrsDLTTUKiAnp4"; 46 request.sendRequestNo = "MCHSEND202003101234"; 47 request.attach = "any attach content"; 48 request.couponTagInfo = new CouponTagInfo(); 49 request.couponTagInfo.couponTagList = new ArrayList<>(); 50 { 51 request.couponTagInfo.couponTagList.add(UserProductCouponTag.MEMBER); 52 }; 53 request.couponTagInfo.memberTagInfo = new MemberTagInfo(); 54 request.couponTagInfo.memberTagInfo.memberCardId = "MemberCardId_1234567890"; 55 try { 56 UserProductCouponEntity response = client.run(request); 57 // TODO: 请求成功,继续业务逻辑 58 System.out.println(response); 59 } catch (WXPayBrandUtility.ApiException e) { 60 // TODO: 请求失败,根据状态码执行不同的逻辑 61 e.printStackTrace(); 62 } 63 } 64 65 public UserProductCouponEntity run(SendUserProductCouponRequest request) { 66 String uri = PATH; 67 uri = uri.replace("{openid}", WXPayBrandUtility.urlEncode(request.openid)); 68 String reqBody = WXPayBrandUtility.toJson(request); 69 70 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 71 reqBuilder.addHeader("Accept", "application/json"); 72 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 73 reqBuilder.addHeader("Authorization", WXPayBrandUtility.buildAuthorization(brand_id, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 74 reqBuilder.addHeader("Content-Type", "application/json"); 75 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 76 reqBuilder.method(METHOD, requestBody); 77 Request httpRequest = reqBuilder.build(); 78 79 // 发送HTTP请求 80 OkHttpClient client = new OkHttpClient.Builder().build(); 81 try (Response httpResponse = client.newCall(httpRequest).execute()) { 82 String respBody = WXPayBrandUtility.extractBody(httpResponse); 83 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 84 // 2XX 成功,验证应答签名 85 WXPayBrandUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 86 httpResponse.headers(), respBody); 87 88 // 从HTTP应答报文构建返回数据 89 return WXPayBrandUtility.fromJson(respBody, UserProductCouponEntity.class); 90 } else { 91 throw new WXPayBrandUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 92 } 93 } catch (IOException e) { 94 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 95 } 96 } 97 98 private final String brand_id; 99 private final String certificateSerialNo; 100 private final PrivateKey privateKey; 101 private final String wechatPayPublicKeyId; 102 private final PublicKey wechatPayPublicKey; 103 104 public SendUserProductCoupon(String brand_id, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 105 this.brand_id = brand_id; 106 this.certificateSerialNo = certificateSerialNo; 107 this.privateKey = WXPayBrandUtility.loadPrivateKeyFromPath(privateKeyFilePath); 108 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 109 this.wechatPayPublicKey = WXPayBrandUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 110 } 111 112 public static class SendUserProductCouponRequest { 113 @SerializedName("product_coupon_id") 114 public String productCouponId; 115 116 @SerializedName("stock_id") 117 public String stockId; 118 119 @SerializedName("coupon_code") 120 public String couponCode; 121 122 @SerializedName("appid") 123 public String appid; 124 125 @SerializedName("openid") 126 @Expose(serialize = false) 127 public String openid; 128 129 @SerializedName("send_request_no") 130 public String sendRequestNo; 131 132 @SerializedName("attach") 133 public String attach; 134 135 @SerializedName("coupon_tag_info") 136 public CouponTagInfo couponTagInfo; 137 } 138 139 public static class UserProductCouponEntity { 140 @SerializedName("coupon_code") 141 public String couponCode; 142 143 @SerializedName("coupon_state") 144 public UserProductCouponState couponState; 145 146 @SerializedName("valid_begin_time") 147 public String validBeginTime; 148 149 @SerializedName("valid_end_time") 150 public String validEndTime; 151 152 @SerializedName("receive_time") 153 public String receiveTime; 154 155 @SerializedName("send_request_no") 156 public String sendRequestNo; 157 158 @SerializedName("send_channel") 159 public UserProductCouponSendChannel sendChannel; 160 161 @SerializedName("confirm_request_no") 162 public String confirmRequestNo; 163 164 @SerializedName("confirm_time") 165 public String confirmTime; 166 167 @SerializedName("deactivate_request_no") 168 public String deactivateRequestNo; 169 170 @SerializedName("deactivate_time") 171 public String deactivateTime; 172 173 @SerializedName("deactivate_reason") 174 public String deactivateReason; 175 176 @SerializedName("single_usage_detail") 177 public CouponUsageDetail singleUsageDetail; 178 179 @SerializedName("product_coupon") 180 public ProductCouponEntity productCoupon; 181 182 @SerializedName("stock") 183 public StockEntity stock; 184 185 @SerializedName("attach") 186 public String attach; 187 188 @SerializedName("channel_custom_info") 189 public String channelCustomInfo; 190 191 @SerializedName("coupon_tag_info") 192 public CouponTagInfo couponTagInfo; 193 } 194 195 public static class CouponTagInfo { 196 @SerializedName("coupon_tag_list") 197 public List<UserProductCouponTag> couponTagList; 198 199 @SerializedName("member_tag_info") 200 public MemberTagInfo memberTagInfo; 201 } 202 203 public enum UserProductCouponState { 204 @SerializedName("CONFIRMING") 205 CONFIRMING, 206 @SerializedName("PENDING") 207 PENDING, 208 @SerializedName("EFFECTIVE") 209 EFFECTIVE, 210 @SerializedName("USED") 211 USED, 212 @SerializedName("EXPIRED") 213 EXPIRED, 214 @SerializedName("DELETED") 215 DELETED, 216 @SerializedName("DEACTIVATED") 217 DEACTIVATED 218 } 219 220 public enum UserProductCouponSendChannel { 221 @SerializedName("BRAND_MANAGE") 222 BRAND_MANAGE, 223 @SerializedName("API") 224 API, 225 @SerializedName("RECEIVE_COMPONENT") 226 RECEIVE_COMPONENT, 227 @SerializedName("MEMBER") 228 MEMBER, 229 @SerializedName("STICKER_GIFT") 230 STICKER_GIFT 231 } 232 233 public static class CouponUsageDetail { 234 @SerializedName("use_request_no") 235 public String useRequestNo; 236 237 @SerializedName("use_time") 238 public String useTime; 239 240 @SerializedName("return_request_no") 241 public String returnRequestNo; 242 243 @SerializedName("return_time") 244 public String returnTime; 245 246 @SerializedName("associated_order_info") 247 public UserProductCouponAssociatedOrderInfo associatedOrderInfo; 248 249 @SerializedName("associated_pay_score_order_info") 250 public UserProductCouponAssociatedPayScoreOrderInfo associatedPayScoreOrderInfo; 251 252 @SerializedName("saved_amount") 253 public Long savedAmount; 254 255 @SerializedName("use_product_no_list") 256 public List<String> useProductNoList; 257 } 258 259 public static class ProductCouponEntity { 260 @SerializedName("product_coupon_id") 261 public String productCouponId; 262 263 @SerializedName("scope") 264 public ProductCouponScope scope; 265 266 @SerializedName("type") 267 public ProductCouponType type; 268 269 @SerializedName("usage_mode") 270 public UsageMode usageMode; 271 272 @SerializedName("single_usage_info") 273 public SingleUsageInfo singleUsageInfo; 274 275 @SerializedName("progressive_bundle_usage_info") 276 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 277 278 @SerializedName("display_info") 279 public ProductCouponDisplayInfo displayInfo; 280 281 @SerializedName("out_product_no") 282 public String outProductNo; 283 284 @SerializedName("state") 285 public ProductCouponState state; 286 287 @SerializedName("deactivate_request_no") 288 public String deactivateRequestNo; 289 290 @SerializedName("deactivate_time") 291 public String deactivateTime; 292 293 @SerializedName("deactivate_reason") 294 public String deactivateReason; 295 296 @SerializedName("available_product_no_list") 297 public List<String> availableProductNoList; 298 299 @SerializedName("business_mode") 300 public ProductCouponBusinessMode businessMode; 301 } 302 303 public static class StockEntity { 304 @SerializedName("product_coupon_id") 305 public String productCouponId; 306 307 @SerializedName("stock_id") 308 public String stockId; 309 310 @SerializedName("remark") 311 public String remark; 312 313 @SerializedName("coupon_code_mode") 314 public CouponCodeMode couponCodeMode; 315 316 @SerializedName("coupon_code_count_info") 317 public CouponCodeCountInfo couponCodeCountInfo; 318 319 @SerializedName("stock_send_rule") 320 public StockSendRule stockSendRule; 321 322 @SerializedName("single_usage_rule") 323 public SingleUsageRule singleUsageRule; 324 325 @SerializedName("usage_rule_display_info") 326 public UsageRuleDisplayInfo usageRuleDisplayInfo; 327 328 @SerializedName("coupon_display_info") 329 public CouponDisplayInfo couponDisplayInfo; 330 331 @SerializedName("notify_config") 332 public NotifyConfig notifyConfig; 333 334 @SerializedName("store_scope") 335 public StockStoreScope storeScope; 336 337 @SerializedName("sent_count_info") 338 public StockSentCountInfo sentCountInfo; 339 340 @SerializedName("state") 341 public StockState state; 342 343 @SerializedName("deactivate_request_no") 344 public String deactivateRequestNo; 345 346 @SerializedName("deactivate_time") 347 public String deactivateTime; 348 349 @SerializedName("deactivate_reason") 350 public String deactivateReason; 351 } 352 353 public enum UserProductCouponTag { 354 @SerializedName("MEMBER") 355 MEMBER, 356 @SerializedName("MEMBER_ACTIVITY") 357 MEMBER_ACTIVITY 358 } 359 360 public static class MemberTagInfo { 361 @SerializedName("member_card_id") 362 public String memberCardId; 363 } 364 365 public static class UserProductCouponAssociatedOrderInfo { 366 @SerializedName("transaction_id") 367 public String transactionId; 368 369 @SerializedName("out_trade_no") 370 public String outTradeNo; 371 372 @SerializedName("mchid") 373 public String mchid; 374 375 @SerializedName("sub_mchid") 376 public String subMchid; 377 } 378 379 public static class UserProductCouponAssociatedPayScoreOrderInfo { 380 @SerializedName("order_id") 381 public String orderId; 382 383 @SerializedName("out_order_no") 384 public String outOrderNo; 385 386 @SerializedName("mchid") 387 public String mchid; 388 389 @SerializedName("sub_mchid") 390 public String subMchid; 391 } 392 393 public enum ProductCouponScope { 394 @SerializedName("ALL") 395 ALL, 396 @SerializedName("SINGLE") 397 SINGLE, 398 @SerializedName("CATEGORY") 399 CATEGORY 400 } 401 402 public enum ProductCouponType { 403 @SerializedName("NORMAL") 404 NORMAL, 405 @SerializedName("DISCOUNT") 406 DISCOUNT, 407 @SerializedName("EXCHANGE") 408 EXCHANGE 409 } 410 411 public enum UsageMode { 412 @SerializedName("SINGLE") 413 SINGLE, 414 @SerializedName("PROGRESSIVE_BUNDLE") 415 PROGRESSIVE_BUNDLE 416 } 417 418 public static class SingleUsageInfo { 419 @SerializedName("normal_coupon") 420 public NormalCouponUsageRule normalCoupon; 421 422 @SerializedName("discount_coupon") 423 public DiscountCouponUsageRule discountCoupon; 424 } 425 426 public static class ProgressiveBundleUsageInfo { 427 @SerializedName("count") 428 public Long count; 429 430 @SerializedName("interval_days") 431 public Long intervalDays; 432 } 433 434 public static class ProductCouponDisplayInfo { 435 @SerializedName("name") 436 public String name; 437 438 @SerializedName("image_url") 439 public String imageUrl; 440 441 @SerializedName("background_url") 442 public String backgroundUrl; 443 444 @SerializedName("detail_image_url_list") 445 public List<String> detailImageUrlList; 446 447 @SerializedName("original_price") 448 public Long originalPrice; 449 450 @SerializedName("combo_package_list") 451 public List<ComboPackage> comboPackageList; 452 } 453 454 public enum ProductCouponState { 455 @SerializedName("AUDITING") 456 AUDITING, 457 @SerializedName("EFFECTIVE") 458 EFFECTIVE, 459 @SerializedName("DEACTIVATED") 460 DEACTIVATED 461 } 462 463 public enum ProductCouponBusinessMode { 464 @SerializedName("FREE") 465 FREE 466 } 467 468 public enum CouponCodeMode { 469 @SerializedName("WECHATPAY") 470 WECHATPAY, 471 @SerializedName("UPLOAD") 472 UPLOAD, 473 @SerializedName("API_ASSIGN") 474 API_ASSIGN 475 } 476 477 public static class CouponCodeCountInfo { 478 @SerializedName("total_count") 479 public Long totalCount; 480 481 @SerializedName("available_count") 482 public Long availableCount; 483 } 484 485 public static class StockSendRule { 486 @SerializedName("max_count") 487 public Long maxCount; 488 489 @SerializedName("max_count_per_day") 490 public Long maxCountPerDay; 491 492 @SerializedName("max_count_per_user") 493 public Long maxCountPerUser; 494 } 495 496 public static class SingleUsageRule { 497 @SerializedName("coupon_available_period") 498 public CouponAvailablePeriod couponAvailablePeriod; 499 500 @SerializedName("normal_coupon") 501 public NormalCouponUsageRule normalCoupon; 502 503 @SerializedName("discount_coupon") 504 public DiscountCouponUsageRule discountCoupon; 505 506 @SerializedName("exchange_coupon") 507 public ExchangeCouponUsageRule exchangeCoupon; 508 } 509 510 public static class UsageRuleDisplayInfo { 511 @SerializedName("coupon_usage_method_list") 512 public List<CouponUsageMethod> couponUsageMethodList = new ArrayList<CouponUsageMethod>(); 513 514 @SerializedName("mini_program_appid") 515 public String miniProgramAppid; 516 517 @SerializedName("mini_program_path") 518 public String miniProgramPath; 519 520 @SerializedName("app_path") 521 public String appPath; 522 523 @SerializedName("usage_description") 524 public String usageDescription; 525 526 @SerializedName("coupon_available_store_info") 527 public CouponAvailableStoreInfo couponAvailableStoreInfo; 528 529 @SerializedName("app_jump_type") 530 public AppJumpType appJumpType; 531 532 @SerializedName("passcode_link") 533 public String passcodeLink; 534 } 535 536 public static class CouponDisplayInfo { 537 @SerializedName("code_display_mode") 538 public CouponCodeDisplayMode codeDisplayMode; 539 540 @SerializedName("background_color") 541 public String backgroundColor; 542 543 @SerializedName("entrance_mini_program") 544 public EntranceMiniProgram entranceMiniProgram; 545 546 @SerializedName("entrance_official_account") 547 public EntranceOfficialAccount entranceOfficialAccount; 548 } 549 550 public static class NotifyConfig { 551 @SerializedName("notify_appid") 552 public String notifyAppid; 553 } 554 555 public enum StockStoreScope { 556 @SerializedName("NONE") 557 NONE, 558 @SerializedName("ALL") 559 ALL, 560 @SerializedName("SPECIFIC") 561 SPECIFIC 562 } 563 564 public static class StockSentCountInfo { 565 @SerializedName("total_count") 566 public Long totalCount; 567 568 @SerializedName("today_count") 569 public Long todayCount; 570 } 571 572 public enum StockState { 573 @SerializedName("AUDITING") 574 AUDITING, 575 @SerializedName("SENDING") 576 SENDING, 577 @SerializedName("PAUSED") 578 PAUSED, 579 @SerializedName("STOPPED") 580 STOPPED, 581 @SerializedName("DEACTIVATED") 582 DEACTIVATED 583 } 584 585 public static class NormalCouponUsageRule { 586 @SerializedName("threshold") 587 public Long threshold; 588 589 @SerializedName("discount_amount") 590 public Long discountAmount; 591 } 592 593 public static class DiscountCouponUsageRule { 594 @SerializedName("threshold") 595 public Long threshold; 596 597 @SerializedName("percent_off") 598 public Long percentOff; 599 } 600 601 public static class ComboPackage { 602 @SerializedName("name") 603 public String name; 604 605 @SerializedName("pick_count") 606 public Long pickCount; 607 608 @SerializedName("choice_list") 609 public List<ComboPackageChoice> choiceList = new ArrayList<ComboPackageChoice>(); 610 } 611 612 public static class CouponAvailablePeriod { 613 @SerializedName("available_begin_time") 614 public String availableBeginTime; 615 616 @SerializedName("available_end_time") 617 public String availableEndTime; 618 619 @SerializedName("available_days") 620 public Long availableDays; 621 622 @SerializedName("wait_days_after_receive") 623 public Long waitDaysAfterReceive; 624 625 @SerializedName("weekly_available_period") 626 public FixedWeekPeriod weeklyAvailablePeriod; 627 628 @SerializedName("irregular_available_period_list") 629 public List<TimePeriod> irregularAvailablePeriodList; 630 631 @SerializedName("available_seconds") 632 public Long availableSeconds; 633 } 634 635 public static class ExchangeCouponUsageRule { 636 @SerializedName("threshold") 637 public Long threshold; 638 639 @SerializedName("exchange_price") 640 public Long exchangePrice; 641 } 642 643 public enum CouponUsageMethod { 644 @SerializedName("OFFLINE") 645 OFFLINE, 646 @SerializedName("MINI_PROGRAM") 647 MINI_PROGRAM, 648 @SerializedName("APP") 649 APP, 650 @SerializedName("PAYMENT_CODE") 651 PAYMENT_CODE 652 } 653 654 public static class CouponAvailableStoreInfo { 655 @SerializedName("description") 656 public String description; 657 658 @SerializedName("mini_program_appid") 659 public String miniProgramAppid; 660 661 @SerializedName("mini_program_path") 662 public String miniProgramPath; 663 } 664 665 public enum AppJumpType { 666 @SerializedName("H5") 667 H5, 668 @SerializedName("PASSCODE_LINK") 669 PASSCODE_LINK, 670 @SerializedName("USAGE_GUIDE") 671 USAGE_GUIDE 672 } 673 674 public enum CouponCodeDisplayMode { 675 @SerializedName("INVISIBLE") 676 INVISIBLE, 677 @SerializedName("BARCODE") 678 BARCODE, 679 @SerializedName("QRCODE") 680 QRCODE 681 } 682 683 public static class EntranceMiniProgram { 684 @SerializedName("appid") 685 public String appid; 686 687 @SerializedName("path") 688 public String path; 689 690 @SerializedName("entrance_wording") 691 public String entranceWording; 692 693 @SerializedName("guidance_wording") 694 public String guidanceWording; 695 } 696 697 public static class EntranceOfficialAccount { 698 @SerializedName("appid") 699 public String appid; 700 } 701 702 public static class ComboPackageChoice { 703 @SerializedName("name") 704 public String name; 705 706 @SerializedName("price") 707 public Long price; 708 709 @SerializedName("count") 710 public Long count; 711 712 @SerializedName("image_url") 713 public String imageUrl; 714 715 @SerializedName("mini_program_appid") 716 public String miniProgramAppid; 717 718 @SerializedName("mini_program_path") 719 public String miniProgramPath; 720 } 721 722 public static class FixedWeekPeriod { 723 @SerializedName("day_list") 724 public List<WeekEnum> dayList = new ArrayList<WeekEnum>(); 725 726 @SerializedName("day_period_list") 727 public List<PeriodOfTheDay> dayPeriodList; 728 } 729 730 public static class TimePeriod { 731 @SerializedName("begin_time") 732 public String beginTime; 733 734 @SerializedName("end_time") 735 public String endTime; 736 } 737 738 public enum WeekEnum { 739 @SerializedName("MONDAY") 740 MONDAY, 741 @SerializedName("TUESDAY") 742 TUESDAY, 743 @SerializedName("WEDNESDAY") 744 WEDNESDAY, 745 @SerializedName("THURSDAY") 746 THURSDAY, 747 @SerializedName("FRIDAY") 748 FRIDAY, 749 @SerializedName("SATURDAY") 750 SATURDAY, 751 @SerializedName("SUNDAY") 752 SUNDAY 753 } 754 755 public static class PeriodOfTheDay { 756 @SerializedName("begin_time") 757 public Long beginTime; 758 759 @SerializedName("end_time") 760 public Long endTime; 761 } 762 763} 764
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_brand_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/brand/4015826866 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 10 "strings" 11 "time" 12) 13 14func main() { 15 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 16 config, err := wxpay_brand_utility.CreateBrandConfig( 17 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 18 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 19 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 20 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 21 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 22 ) 23 if err != nil { 24 fmt.Println(err) 25 return 26 } 27 28 request := &SendUserProductCouponRequest{ 29 ProductCouponId: wxpay_brand_utility.String("1000000013"), 30 StockId: wxpay_brand_utility.String("1000000013001"), 31 CouponCode: wxpay_brand_utility.String("Code_123456"), 32 Appid: wxpay_brand_utility.String("wx233544546545989"), 33 Openid: wxpay_brand_utility.String("oh-394z-6CGkNoJrsDLTTUKiAnp4"), 34 SendRequestNo: wxpay_brand_utility.String("MCHSEND202003101234"), 35 Attach: wxpay_brand_utility.String("any attach content"), 36 CouponTagInfo: &CouponTagInfo{ 37 CouponTagList: []UserProductCouponTag{ 38 USERPRODUCTCOUPONTAG_MEMBER, 39 }, 40 MemberTagInfo: &MemberTagInfo{ 41 MemberCardId: wxpay_brand_utility.String("MemberCardId_1234567890"), 42 }, 43 }, 44 } 45 46 response, err := SendUserProductCoupon(config, request) 47 if err != nil { 48 fmt.Printf("请求失败: %+v\n", err) 49 // TODO: 请求失败,根据状态码执行不同的处理 50 return 51 } 52 53 // TODO: 请求成功,继续业务逻辑 54 fmt.Printf("请求成功: %+v\n", response) 55} 56 57func SendUserProductCoupon(config *wxpay_brand_utility.BrandConfig, request *SendUserProductCouponRequest) (response *UserProductCouponEntity, err error) { 58 const ( 59 host = "https://api.mch.weixin.qq.com" 60 method = "POST" 61 path = "/brand/marketing/product-coupon/users/{openid}/coupons" 62 ) 63 64 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 65 if err != nil { 66 return nil, err 67 } 68 reqUrl.Path = strings.Replace(reqUrl.Path, "{openid}", url.PathEscape(*request.Openid), -1) 69 reqBody, err := json.Marshal(request) 70 if err != nil { 71 return nil, err 72 } 73 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 74 if err != nil { 75 return nil, err 76 } 77 httpRequest.Header.Set("Accept", "application/json") 78 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 79 httpRequest.Header.Set("Content-Type", "application/json") 80 authorization, err := wxpay_brand_utility.BuildAuthorization(config.BrandId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 81 if err != nil { 82 return nil, err 83 } 84 httpRequest.Header.Set("Authorization", authorization) 85 86 client := &http.Client{} 87 httpResponse, err := client.Do(httpRequest) 88 if err != nil { 89 return nil, err 90 } 91 respBody, err := wxpay_brand_utility.ExtractResponseBody(httpResponse) 92 if err != nil { 93 return nil, err 94 } 95 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 96 // 2XX 成功,验证应答签名 97 err = wxpay_brand_utility.ValidateResponse( 98 config.WechatPayPublicKeyId(), 99 config.WechatPayPublicKey(), 100 &httpResponse.Header, 101 respBody, 102 ) 103 if err != nil { 104 return nil, err 105 } 106 response := &UserProductCouponEntity{} 107 if err := json.Unmarshal(respBody, response); err != nil { 108 return nil, err 109 } 110 111 return response, nil 112 } else { 113 return nil, wxpay_brand_utility.NewApiException( 114 httpResponse.StatusCode, 115 httpResponse.Header, 116 respBody, 117 ) 118 } 119} 120 121type SendUserProductCouponRequest struct { 122 ProductCouponId *string `json:"product_coupon_id,omitempty"` 123 StockId *string `json:"stock_id,omitempty"` 124 CouponCode *string `json:"coupon_code,omitempty"` 125 Appid *string `json:"appid,omitempty"` 126 Openid *string `json:"openid,omitempty"` 127 SendRequestNo *string `json:"send_request_no,omitempty"` 128 Attach *string `json:"attach,omitempty"` 129 CouponTagInfo *CouponTagInfo `json:"coupon_tag_info,omitempty"` 130} 131 132func (o *SendUserProductCouponRequest) MarshalJSON() ([]byte, error) { 133 type Alias SendUserProductCouponRequest 134 a := &struct { 135 Openid *string `json:"openid,omitempty"` 136 *Alias 137 }{ 138 // 序列化时移除非 Body 字段 139 Openid: nil, 140 Alias: (*Alias)(o), 141 } 142 return json.Marshal(a) 143} 144 145type UserProductCouponEntity struct { 146 CouponCode *string `json:"coupon_code,omitempty"` 147 CouponState *UserProductCouponState `json:"coupon_state,omitempty"` 148 ValidBeginTime *time.Time `json:"valid_begin_time,omitempty"` 149 ValidEndTime *time.Time `json:"valid_end_time,omitempty"` 150 ReceiveTime *string `json:"receive_time,omitempty"` 151 SendRequestNo *string `json:"send_request_no,omitempty"` 152 SendChannel *UserProductCouponSendChannel `json:"send_channel,omitempty"` 153 ConfirmRequestNo *string `json:"confirm_request_no,omitempty"` 154 ConfirmTime *time.Time `json:"confirm_time,omitempty"` 155 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 156 DeactivateTime *string `json:"deactivate_time,omitempty"` 157 DeactivateReason *string `json:"deactivate_reason,omitempty"` 158 SingleUsageDetail *CouponUsageDetail `json:"single_usage_detail,omitempty"` 159 ProductCoupon *ProductCouponEntity `json:"product_coupon,omitempty"` 160 Stock *StockEntity `json:"stock,omitempty"` 161 Attach *string `json:"attach,omitempty"` 162 ChannelCustomInfo *string `json:"channel_custom_info,omitempty"` 163 CouponTagInfo *CouponTagInfo `json:"coupon_tag_info,omitempty"` 164} 165 166type CouponTagInfo struct { 167 CouponTagList []UserProductCouponTag `json:"coupon_tag_list,omitempty"` 168 MemberTagInfo *MemberTagInfo `json:"member_tag_info,omitempty"` 169} 170 171type UserProductCouponState string 172 173func (e UserProductCouponState) Ptr() *UserProductCouponState { 174 return &e 175} 176 177const ( 178 USERPRODUCTCOUPONSTATE_CONFIRMING UserProductCouponState = "CONFIRMING" 179 USERPRODUCTCOUPONSTATE_PENDING UserProductCouponState = "PENDING" 180 USERPRODUCTCOUPONSTATE_EFFECTIVE UserProductCouponState = "EFFECTIVE" 181 USERPRODUCTCOUPONSTATE_USED UserProductCouponState = "USED" 182 USERPRODUCTCOUPONSTATE_EXPIRED UserProductCouponState = "EXPIRED" 183 USERPRODUCTCOUPONSTATE_DELETED UserProductCouponState = "DELETED" 184 USERPRODUCTCOUPONSTATE_DEACTIVATED UserProductCouponState = "DEACTIVATED" 185) 186 187type UserProductCouponSendChannel string 188 189func (e UserProductCouponSendChannel) Ptr() *UserProductCouponSendChannel { 190 return &e 191} 192 193const ( 194 USERPRODUCTCOUPONSENDCHANNEL_BRAND_MANAGE UserProductCouponSendChannel = "BRAND_MANAGE" 195 USERPRODUCTCOUPONSENDCHANNEL_API UserProductCouponSendChannel = "API" 196 USERPRODUCTCOUPONSENDCHANNEL_RECEIVE_COMPONENT UserProductCouponSendChannel = "RECEIVE_COMPONENT" 197 USERPRODUCTCOUPONSENDCHANNEL_MEMBER UserProductCouponSendChannel = "MEMBER" 198 USERPRODUCTCOUPONSENDCHANNEL_STICKER_GIFT UserProductCouponSendChannel = "STICKER_GIFT" 199) 200 201type CouponUsageDetail struct { 202 UseRequestNo *string `json:"use_request_no,omitempty"` 203 UseTime *time.Time `json:"use_time,omitempty"` 204 ReturnRequestNo *string `json:"return_request_no,omitempty"` 205 ReturnTime *time.Time `json:"return_time,omitempty"` 206 AssociatedOrderInfo *UserProductCouponAssociatedOrderInfo `json:"associated_order_info,omitempty"` 207 AssociatedPayScoreOrderInfo *UserProductCouponAssociatedPayScoreOrderInfo `json:"associated_pay_score_order_info,omitempty"` 208 SavedAmount *int64 `json:"saved_amount,omitempty"` 209 UseProductNoList []string `json:"use_product_no_list,omitempty"` 210} 211 212type ProductCouponEntity struct { 213 ProductCouponId *string `json:"product_coupon_id,omitempty"` 214 Scope *ProductCouponScope `json:"scope,omitempty"` 215 Type *ProductCouponType `json:"type,omitempty"` 216 UsageMode *UsageMode `json:"usage_mode,omitempty"` 217 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"` 218 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 219 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 220 OutProductNo *string `json:"out_product_no,omitempty"` 221 State *ProductCouponState `json:"state,omitempty"` 222 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 223 DeactivateTime *string `json:"deactivate_time,omitempty"` 224 DeactivateReason *string `json:"deactivate_reason,omitempty"` 225 AvailableProductNoList []string `json:"available_product_no_list,omitempty"` 226 BusinessMode *ProductCouponBusinessMode `json:"business_mode,omitempty"` 227} 228 229type StockEntity struct { 230 ProductCouponId *string `json:"product_coupon_id,omitempty"` 231 StockId *string `json:"stock_id,omitempty"` 232 Remark *string `json:"remark,omitempty"` 233 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 234 CouponCodeCountInfo *CouponCodeCountInfo `json:"coupon_code_count_info,omitempty"` 235 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"` 236 SingleUsageRule *SingleUsageRule `json:"single_usage_rule,omitempty"` 237 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 238 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 239 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 240 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 241 SentCountInfo *StockSentCountInfo `json:"sent_count_info,omitempty"` 242 State *StockState `json:"state,omitempty"` 243 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 244 DeactivateTime *time.Time `json:"deactivate_time,omitempty"` 245 DeactivateReason *string `json:"deactivate_reason,omitempty"` 246} 247 248type UserProductCouponTag string 249 250func (e UserProductCouponTag) Ptr() *UserProductCouponTag { 251 return &e 252} 253 254const ( 255 USERPRODUCTCOUPONTAG_MEMBER UserProductCouponTag = "MEMBER" 256 USERPRODUCTCOUPONTAG_MEMBER_ACTIVITY UserProductCouponTag = "MEMBER_ACTIVITY" 257) 258 259type MemberTagInfo struct { 260 MemberCardId *string `json:"member_card_id,omitempty"` 261} 262 263type UserProductCouponAssociatedOrderInfo struct { 264 TransactionId *string `json:"transaction_id,omitempty"` 265 OutTradeNo *string `json:"out_trade_no,omitempty"` 266 Mchid *string `json:"mchid,omitempty"` 267 SubMchid *string `json:"sub_mchid,omitempty"` 268} 269 270type UserProductCouponAssociatedPayScoreOrderInfo struct { 271 OrderId *string `json:"order_id,omitempty"` 272 OutOrderNo *string `json:"out_order_no,omitempty"` 273 Mchid *string `json:"mchid,omitempty"` 274 SubMchid *string `json:"sub_mchid,omitempty"` 275} 276 277type ProductCouponScope string 278 279func (e ProductCouponScope) Ptr() *ProductCouponScope { 280 return &e 281} 282 283const ( 284 PRODUCTCOUPONSCOPE_ALL ProductCouponScope = "ALL" 285 PRODUCTCOUPONSCOPE_SINGLE ProductCouponScope = "SINGLE" 286 PRODUCTCOUPONSCOPE_CATEGORY ProductCouponScope = "CATEGORY" 287) 288 289type ProductCouponType string 290 291func (e ProductCouponType) Ptr() *ProductCouponType { 292 return &e 293} 294 295const ( 296 PRODUCTCOUPONTYPE_NORMAL ProductCouponType = "NORMAL" 297 PRODUCTCOUPONTYPE_DISCOUNT ProductCouponType = "DISCOUNT" 298 PRODUCTCOUPONTYPE_EXCHANGE ProductCouponType = "EXCHANGE" 299) 300 301type UsageMode string 302 303func (e UsageMode) Ptr() *UsageMode { 304 return &e 305} 306 307const ( 308 USAGEMODE_SINGLE UsageMode = "SINGLE" 309 USAGEMODE_PROGRESSIVE_BUNDLE UsageMode = "PROGRESSIVE_BUNDLE" 310) 311 312type SingleUsageInfo struct { 313 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 314 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 315} 316 317type ProgressiveBundleUsageInfo struct { 318 Count *int64 `json:"count,omitempty"` 319 IntervalDays *int64 `json:"interval_days,omitempty"` 320} 321 322type ProductCouponDisplayInfo struct { 323 Name *string `json:"name,omitempty"` 324 ImageUrl *string `json:"image_url,omitempty"` 325 BackgroundUrl *string `json:"background_url,omitempty"` 326 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"` 327 OriginalPrice *int64 `json:"original_price,omitempty"` 328 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"` 329} 330 331type ProductCouponState string 332 333func (e ProductCouponState) Ptr() *ProductCouponState { 334 return &e 335} 336 337const ( 338 PRODUCTCOUPONSTATE_AUDITING ProductCouponState = "AUDITING" 339 PRODUCTCOUPONSTATE_EFFECTIVE ProductCouponState = "EFFECTIVE" 340 PRODUCTCOUPONSTATE_DEACTIVATED ProductCouponState = "DEACTIVATED" 341) 342 343type ProductCouponBusinessMode string 344 345func (e ProductCouponBusinessMode) Ptr() *ProductCouponBusinessMode { 346 return &e 347} 348 349const ( 350 PRODUCTCOUPONBUSINESSMODE_FREE ProductCouponBusinessMode = "FREE" 351) 352 353type CouponCodeMode string 354 355func (e CouponCodeMode) Ptr() *CouponCodeMode { 356 return &e 357} 358 359const ( 360 COUPONCODEMODE_WECHATPAY CouponCodeMode = "WECHATPAY" 361 COUPONCODEMODE_UPLOAD CouponCodeMode = "UPLOAD" 362 COUPONCODEMODE_API_ASSIGN CouponCodeMode = "API_ASSIGN" 363) 364 365type CouponCodeCountInfo struct { 366 TotalCount *int64 `json:"total_count,omitempty"` 367 AvailableCount *int64 `json:"available_count,omitempty"` 368} 369 370type StockSendRule struct { 371 MaxCount *int64 `json:"max_count,omitempty"` 372 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"` 373 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"` 374} 375 376type SingleUsageRule struct { 377 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 378 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 379 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 380 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"` 381} 382 383type UsageRuleDisplayInfo struct { 384 CouponUsageMethodList []CouponUsageMethod `json:"coupon_usage_method_list,omitempty"` 385 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 386 MiniProgramPath *string `json:"mini_program_path,omitempty"` 387 AppPath *string `json:"app_path,omitempty"` 388 UsageDescription *string `json:"usage_description,omitempty"` 389 CouponAvailableStoreInfo *CouponAvailableStoreInfo `json:"coupon_available_store_info,omitempty"` 390 AppJumpType *AppJumpType `json:"app_jump_type,omitempty"` 391 PasscodeLink *string `json:"passcode_link,omitempty"` 392} 393 394type CouponDisplayInfo struct { 395 CodeDisplayMode *CouponCodeDisplayMode `json:"code_display_mode,omitempty"` 396 BackgroundColor *string `json:"background_color,omitempty"` 397 EntranceMiniProgram *EntranceMiniProgram `json:"entrance_mini_program,omitempty"` 398 EntranceOfficialAccount *EntranceOfficialAccount `json:"entrance_official_account,omitempty"` 399} 400 401type NotifyConfig struct { 402 NotifyAppid *string `json:"notify_appid,omitempty"` 403} 404 405type StockStoreScope string 406 407func (e StockStoreScope) Ptr() *StockStoreScope { 408 return &e 409} 410 411const ( 412 STOCKSTORESCOPE_NONE StockStoreScope = "NONE" 413 STOCKSTORESCOPE_ALL StockStoreScope = "ALL" 414 STOCKSTORESCOPE_SPECIFIC StockStoreScope = "SPECIFIC" 415) 416 417type StockSentCountInfo struct { 418 TotalCount *int64 `json:"total_count,omitempty"` 419 TodayCount *int64 `json:"today_count,omitempty"` 420} 421 422type StockState string 423 424func (e StockState) Ptr() *StockState { 425 return &e 426} 427 428const ( 429 STOCKSTATE_AUDITING StockState = "AUDITING" 430 STOCKSTATE_SENDING StockState = "SENDING" 431 STOCKSTATE_PAUSED StockState = "PAUSED" 432 STOCKSTATE_STOPPED StockState = "STOPPED" 433 STOCKSTATE_DEACTIVATED StockState = "DEACTIVATED" 434) 435 436type NormalCouponUsageRule struct { 437 Threshold *int64 `json:"threshold,omitempty"` 438 DiscountAmount *int64 `json:"discount_amount,omitempty"` 439} 440 441type DiscountCouponUsageRule struct { 442 Threshold *int64 `json:"threshold,omitempty"` 443 PercentOff *int64 `json:"percent_off,omitempty"` 444} 445 446type ComboPackage struct { 447 Name *string `json:"name,omitempty"` 448 PickCount *int64 `json:"pick_count,omitempty"` 449 ChoiceList []ComboPackageChoice `json:"choice_list,omitempty"` 450} 451 452type CouponAvailablePeriod struct { 453 AvailableBeginTime *string `json:"available_begin_time,omitempty"` 454 AvailableEndTime *string `json:"available_end_time,omitempty"` 455 AvailableDays *int64 `json:"available_days,omitempty"` 456 WaitDaysAfterReceive *int64 `json:"wait_days_after_receive,omitempty"` 457 WeeklyAvailablePeriod *FixedWeekPeriod `json:"weekly_available_period,omitempty"` 458 IrregularAvailablePeriodList []TimePeriod `json:"irregular_available_period_list,omitempty"` 459 AvailableSeconds *int64 `json:"available_seconds,omitempty"` 460} 461 462type ExchangeCouponUsageRule struct { 463 Threshold *int64 `json:"threshold,omitempty"` 464 ExchangePrice *int64 `json:"exchange_price,omitempty"` 465} 466 467type CouponUsageMethod string 468 469func (e CouponUsageMethod) Ptr() *CouponUsageMethod { 470 return &e 471} 472 473const ( 474 COUPONUSAGEMETHOD_OFFLINE CouponUsageMethod = "OFFLINE" 475 COUPONUSAGEMETHOD_MINI_PROGRAM CouponUsageMethod = "MINI_PROGRAM" 476 COUPONUSAGEMETHOD_APP CouponUsageMethod = "APP" 477 COUPONUSAGEMETHOD_PAYMENT_CODE CouponUsageMethod = "PAYMENT_CODE" 478) 479 480type CouponAvailableStoreInfo struct { 481 Description *string `json:"description,omitempty"` 482 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 483 MiniProgramPath *string `json:"mini_program_path,omitempty"` 484} 485 486type AppJumpType string 487 488func (e AppJumpType) Ptr() *AppJumpType { 489 return &e 490} 491 492const ( 493 APPJUMPTYPE_H5 AppJumpType = "H5" 494 APPJUMPTYPE_PASSCODE_LINK AppJumpType = "PASSCODE_LINK" 495 APPJUMPTYPE_USAGE_GUIDE AppJumpType = "USAGE_GUIDE" 496) 497 498type CouponCodeDisplayMode string 499 500func (e CouponCodeDisplayMode) Ptr() *CouponCodeDisplayMode { 501 return &e 502} 503 504const ( 505 COUPONCODEDISPLAYMODE_INVISIBLE CouponCodeDisplayMode = "INVISIBLE" 506 COUPONCODEDISPLAYMODE_BARCODE CouponCodeDisplayMode = "BARCODE" 507 COUPONCODEDISPLAYMODE_QRCODE CouponCodeDisplayMode = "QRCODE" 508) 509 510type EntranceMiniProgram struct { 511 Appid *string `json:"appid,omitempty"` 512 Path *string `json:"path,omitempty"` 513 EntranceWording *string `json:"entrance_wording,omitempty"` 514 GuidanceWording *string `json:"guidance_wording,omitempty"` 515} 516 517type EntranceOfficialAccount struct { 518 Appid *string `json:"appid,omitempty"` 519} 520 521type ComboPackageChoice struct { 522 Name *string `json:"name,omitempty"` 523 Price *int64 `json:"price,omitempty"` 524 Count *int64 `json:"count,omitempty"` 525 ImageUrl *string `json:"image_url,omitempty"` 526 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 527 MiniProgramPath *string `json:"mini_program_path,omitempty"` 528} 529 530type FixedWeekPeriod struct { 531 DayList []WeekEnum `json:"day_list,omitempty"` 532 DayPeriodList []PeriodOfTheDay `json:"day_period_list,omitempty"` 533} 534 535type TimePeriod struct { 536 BeginTime *string `json:"begin_time,omitempty"` 537 EndTime *string `json:"end_time,omitempty"` 538} 539 540type WeekEnum string 541 542func (e WeekEnum) Ptr() *WeekEnum { 543 return &e 544} 545 546const ( 547 WEEKENUM_MONDAY WeekEnum = "MONDAY" 548 WEEKENUM_TUESDAY WeekEnum = "TUESDAY" 549 WEEKENUM_WEDNESDAY WeekEnum = "WEDNESDAY" 550 WEEKENUM_THURSDAY WeekEnum = "THURSDAY" 551 WEEKENUM_FRIDAY WeekEnum = "FRIDAY" 552 WEEKENUM_SATURDAY WeekEnum = "SATURDAY" 553 WEEKENUM_SUNDAY WeekEnum = "SUNDAY" 554) 555 556type PeriodOfTheDay struct { 557 BeginTime *int64 `json:"begin_time,omitempty"` 558 EndTime *int64 `json:"end_time,omitempty"` 559} 560
应答参数
折叠全部参数
200 OK
coupon_code 必填 string(40)
【用户商品券Code】 用户商品券的唯一标识
coupon_state 必填 string
【用户商品券状态】
可选取值
CONFIRMING: 待确认,用户商品券发放需要品牌方调用【确认发放用户商品券API(单券)】或【确认发放用户商品券API(多次优惠)】后才能生效PENDING: 已发放待生效,用户商品券已发放成功但尚未到达可用开始时间EFFECTIVE: 已生效,用户商品券已成功发放且到达可用开始时间USED: 已核销,用户商品券已核销EXPIRED: 已过期,用户商品券已超过有效期,不再可用DELETED: 已删除,用户主动删除该券DEACTIVATED: 已失效,品牌方主动调用【失效用户商品券API】或【失效用户商品券组API】使用户商品券失效
valid_begin_time 必填 string
【有效期开始时间】 用户商品券可用开始时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
valid_end_time 必填 string
【有效期结束时间】 用户商品券可用结束时间。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
receive_time 必填 string
【领券时间】 用户领券时间。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
send_request_no 必填 string(128)
【发券请求单号】 发券时传入的请求流水号
send_channel 必填 string
【发券渠道】 描述用户商品券是经由什么渠道发送的
可选取值
BRAND_MANAGE: 摇一摇有优惠,通过摇一摇有优惠渠道发放API: 品牌方自主发券,品牌方通过发券接口自主发券到商家名片RECEIVE_COMPONENT: 小程序领券组件,品牌方通过小程序领券组件发券MEMBER: 会员,品牌方通过会员相关活动或渠道进行发券STICKER_GIFT: 贴图有礼,用户参与品牌贴图有礼活动后发放
confirm_request_no 选填 string
【确认请求单号】 品牌方确认发券请求时传入的的请求流水号。当且仅当 品牌方调用【确认发放用户商品券API】后提供。
confirm_time 选填 string
【确认发放时间】 品牌方确认发券时间,当且仅当 品牌方调用【确认发放用户商品券API】后提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
deactivate_request_no 选填 string(128)
【失效请求单号】 品牌方失效券请求时传入的的请求流水号。当且仅当 coupon_state 为 DEACTIVATED 时提供,返回品牌方调用【失效用户商品券API】或【失效用户商品券组API】时传入的请求流水号
deactivate_time 选填 string
【失效时间】 失效时间,当且仅当 coupon_state 为 DEACTIVATED 时提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
deactivate_reason 选填 string(150)
【失效原因】 失效券的原因,当且仅当 coupon_state 为 DEACTIVATED 时提供,返回品牌方调用【失效用户商品券API】或【失效用户商品券组API】时传入的失效原因
single_usage_detail 选填 object
【单券使用详情】 当且仅当 usage_mode 为 SINGLE 时提供
use_request_no 选填 string
【券核销请求单号】 券核销的请求流水号,当且仅当用户商品券状态 coupon_state 为 USED 时提供
use_time 选填 string
【券核销时间】 券被核销的时间,当且仅当用户商品券状态 coupon_state 为 USED 时提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
return_request_no 选填 string
【退券请求单号】 品牌退券时传入的请求流水号,当且仅当券发生了退回后提供此字段
return_time 选填 string
【退券时间】 券被退回的时间,当且仅当券发生了退回后提供此字段。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
associated_order_info 选填 object
【券核销的微信支付订单信息】 券核销对应的微信支付订单信息,当且仅当用户商品券状态 coupon_state 为 USED 时提供,
注:
1、associated_order_info与 associated_pay_score_order_info 会根据核销请求时的传入参数决定返回对应字段
2、订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
transaction_id 选填 string
【微信支付单号】 由微信支付生成的支付单唯一标识,可以唯一定位到一笔微信支付单。
注:订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
out_trade_no 选填 string
【商户订单号】 在微信支付支付时传入的商户订单号,在商户侧具有唯一性,因此提供此字段时应同时提供下单商户号:
如果此单为服务商模式下单,则需提供 父商户号
mchid以及 子商户号sub_mchid如果此单为直连商户模式下单,则需提供 直连商户号
mchid
注:订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
mchid 选填 string
【商户号】 当提供 out_trade_no 时此字段必传,否则可以省略。参考如下规则传入:
若为服务商模式,则此字段为服务商商户号
若为直连商户模式,则此字段为商户号
sub_mchid 选填 string
【子商户号】 当提供 out_trade_no 时,参考如下规则传入:
若为服务商模式,则此字段必填,为子商户号
若为直连商户模式,则此字段为空
不提供 out_trade_no 时可忽略此字段
associated_pay_score_order_info 选填 object
【券核销的关联微信支付分订单信息】 券核销的关联微信支付分订单信息,当且仅当用户商品券状态 coupon_state 为 USED 时提供,
注:
1、associated_order_info与 associated_pay_score_order_info 会根据核销请求时的传入参数决定返回对应字段
2、订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
order_id 选填 string
【微信支付服务订单号】 支付分订单在微信侧的唯一标识。
注:订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
out_order_no 选填 string
【商户服务订单号】 商户系统内部服务订单号,要求32个字符内,只能是数字、大小写字母_-| 且在同一个商户号下唯一。:
如果此单为服务商模式下单,则需提供 父商户号
mchid以及 子商户号sub_mchid如果此单为直连商户模式下单,则需提供 直连商户号
mchid
注:订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付服务单。
mchid 选填 string
【商户号】 当提供 out_order_no 时此字段必传,否则可以省略。参考如下规则传入:
若为服务商模式,则此字段为服务商商户号
若为直连商户模式,则此字段为商户号
sub_mchid 选填 string
【子商户号】 当提供 out_order_no 时,参考如下规则传入:
若为服务商模式,则此字段必填,为子商户号
若为直连商户模式,则此字段为空
不提供 out_order_no 时可忽略此字段
saved_amount 选填 integer
【优惠金额】 使用本券的实际优惠金额,单位为分
注:
当本券为全场/品类折扣券(scope=
ALL或CATEGORY)时,提供的是商户传入的值
use_product_no_list 选填 array[string]
【核销商品编码列表】 核销商品编码列表
注:
当该券优惠范围为单品或品类且商户核销时传入的商品编码列表正确时提供
product_coupon 必填 object
【商品券信息】 该用户商品券对应的商品券详情
product_coupon_id 必填 string(40)
【商品券ID】 商品券的唯一标识,由微信支付生成
scope 必填 string
【优惠范围】 商品券优惠范围
可选取值
ALL: 全场商品可用券,此时券类型type仅可配置为NORMAL或DISCOUNTSINGLE: 部分商品可用券,此时券类型type配置不受限制,即可配置为NORMAL、DISCOUNT或EXCHANGECATEGORY: 品类券。适用于商户对某一品类商品提供优惠的场景;系统侧不维护商品/品类清单,具体可用商品范围由商户在display_info描述、图片等字段中向用户告知,并在核销时由商户自行判定。此时券类型type仅可配置为NORMAL或DISCOUNT
type 必填 string
【商品券类型】 商品券的优惠类型
可选取值
NORMAL: 满减券DISCOUNT: 折扣券EXCHANGE: 兑换券,仅在scope为SINGLE时可配置
usage_mode 必填 string
【使用模式】 商品券使用模式
可选取值
SINGLE: 单券,即用户只能使用一次,使用后券失效PROGRESSIVE_BUNDLE: 多次优惠,由一组批次组成,每阶梯次序对应一个批次。用户按顺序使用,每次核销后发放下一张券,直到用完为止
single_usage_info 选填 object
【单券模式信息】 单券模式配置信息,仅当 usage_mode 为 SINGLE 时提供,其他场景不提供。
normal_coupon 选填 object
【满减券使用规则】 本商品券内所有批次均以此规则提供满减优惠,当且仅当 type 为 NORMAL 且 scope 为 ALL 或 CATEGORY 时必填,其他类型不应填写。
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受满减优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
discount_amount 必填 integer
【固定减免金额】 固定减免金额,单位为分,必须大于0。
discount_coupon 选填 object
【折扣券使用规则】 本商品券内所有批次均以此规则提供折扣优惠,当且仅当 type 为 DISCOUNT 且 scope 为 ALL 或 CATEGORY 时必填,其他类型不应填写。
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受折扣优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
percent_off 必填 integer
【固定减免百分比】 表示减免金额为总金额的百分比,必须大于0。例如:填入 30 表示减免 30%,即打 7 折
progressive_bundle_usage_info 选填 object
【多次优惠模式信息】 多次优惠模式配置信息,当且仅当 usage_mode 为 PROGRESSIVE_BUNDLE 时提供,其他模式不提供。
count 必填 integer
【可使用次数】 多次优惠领取后用户可使用次数,最少3次,最多15次
interval_days 选填 integer
【多次优惠使用间隔天数】 多次优惠多次使用之间需要间隔的天数,最高7天。例如:
间隔
0天表示不限制,使用后当天仍然可以继续使用下一次优惠间隔
1天表示使用后当天不再可用,下一次优惠需要等到次日 00:00:00 才能使用间隔
2天表示使用后当天和次日不再可用,下一次优惠需要等到第三天 00:00:00 才能使用依此类推……
默认情况下为 0 天,即不限制,使用后当天仍然可以继续使用下一次优惠
display_info 必填 object
【展示信息】 商品券展示信息
name 必填 string(25)
【商品券名称】 商品券名称,长度为3-25个UTF-8字符
image_url 必填 string
【商品券图片】 商品图片的链接地址,仅支持通过【图片上传API】获取的图片URL地址。
请参考商品券图片设计规范进行设计
要求图片宽高比1:1,建议尺寸1080*1080
大小不超过2M
建议图片格式:透明PNG格式
需要注意保留透明边距(上下左右各120px)
background_url 必填 string
【商品券背景图】 商品背景图片的URL地址,仅支持通过【图片上传API】获取的图片URL地址。
要求图片宽高比65:77,建议尺寸1170*1326
大小不超过2M
建议图片格式:JPG/PNG格式
需要注意保留「商品名称」与「商品图」的安全区域
detail_image_url_list 选填 array[string]
【商品券详情图列表】 商品详情图URL地址列表,用于最多可上传8张图片,仅支持通过【图片上传API】获取的图片URL地址。
要求图片宽高比65:77,建议尺寸1170*1326
大小不超过2M
建议图片格式:JPG/PNG格式
original_price 选填 integer
【商品原价】 单位为分,用于对外展示,默认为 0,最大为 10000000。不填写时默认为 0
combo_package_list 选填 array[object]
【适用商品组合】 当 scope 为 SINGLE 必填,用于对外展示,其他优惠范围选填。最多配置 50 个组合
name 必填 string(25)
【适用商品名】 长度不超过25个UTF-8字符
pick_count 必填 integer
【可选单品数量】 用户可以从 choice_list 中选择的选项数量,例如 10 选 3,则这里填 3
choice_list 必填 array[object]
【单品列表】 套餐内包含的选项列表,记录每个单品的信息,最多99个单品,且不能少于设置的pick_count数量
name 必填 string(25)
【单品名称】 长度不超过25个UTF-8字符
price 必填 integer
【单品价格】 单位为分,必须大于0。
count 必填 integer
【单品数量】 最多99个
image_url 选填 string
【单品图片】 单品图片URL地址,仅支持通过【图片上传API】获取的图片URL地址,接入领券组件和核销组件的品牌方建议填写。
要求图片宽高比1:1,建议尺寸1080*1080
大小不超过2M
建议图片格式:透明PNG格式
需要注意保留透明边距(上下左右各120px)
mini_program_appid 选填 string
【单品跳转小程序AppID】 品牌方可展示单品的小程序AppID,小程序需与品牌方存在绑定关系,接入领券组件和核销组件的品牌方建议填写。需和 mini_program_path 一同填写。
mini_program_path 选填 string
【单品跳转小程序路径】 单品展示信息在小程序内的跳转路径,接入领券组件和核销组件的品牌方建议填写。需和 mini_program_appid 一同填写。
out_product_no 选填 string
【外部商品ID】 商户创建商品券时主动传入的外部商品ID,原样返回
state 必填 string
【商品券状态】 商品券状态
可选取值
AUDITING: 审批中,审批完成前商品券不可用EFFECTIVE: 生效中,商品券已生效,可以正常使用DEACTIVATED: 已失效,品牌方主动调用失效接口使商品券失效
deactivate_request_no 选填 string(128)
【失效请求单号】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用【失效商品券API】时传入的请求流水号
deactivate_time 选填 string
【失效时间】 当且仅当 state 为 DEACTIVATED 时提供,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
deactivate_reason 选填 string(150)
【失效原因】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用【失效商品券API】时传入的失效原因
available_product_no_list 选填 array[string]
【可用商品编码列表】 商户创建商品券时主动传入的可用商品编码,原样返回
business_mode 必填 string
【业务模式】 商品券的业务模式;本能力上线前创建的存量商品券统一返回 FREE
可选取值
FREE: 普通券,用户可直接领取。
stock 必填 object
【批次信息】 该用户商品券发券时使用的批次详情
product_coupon_id 必填 string(40)
【商品券ID】 商品券的唯一标识,由微信支付生成
stock_id 必填 string(40)
【批次ID】 商品券批次的唯一标识,由微信支付生成
remark 选填 string(20)
【备注】 仅配置品牌可见,用于自定义信息
coupon_code_mode 必填 string
【券Code分配模式】 决定发券时用户商品券Code如何产生
可选取值
WECHATPAY: 微信支付随机生成,发券时由微信支付系统自动随机生成券码,品牌方无需干预,微信支付随机生成的券Code长度限制为40个字符以内UPLOAD: 品牌方预上传Code,品牌方需先使用【预上传券Code API(单券)】或【预上传券Code API(多次优惠)】上传自定义Code,微信支付系统发券时从中随机选取,当预存Code不足时可能影响发券,品牌应及时补充API_ASSIGN: 品牌方自行指定,品牌方通过【向用户发放商品券API】自行发券时指定,微信支付系统不再进行自动分配。特别注意:这种模式的商品批次只可由品牌方自行发券,无法在摇一摇有优惠等微信支付渠道投放;商品券的usage_mode为PROGRESSIVE_BUNDLE时不可使用本模式
coupon_code_count_info 选填 object
【品牌方预上传的券Code数量信息】 当且仅当 coupon_code_mode 为 UPLOAD 时存在此字段
total_count 必填 integer
【已上传的Code总数】 品牌方为此批次已经上传过的券Code总数量
available_count 必填 integer
【当前可用的Code数】 品牌方为此批次已经上传过的券Code中,当前剩余可用的券Code数量
stock_send_rule 必填 object
【发放规则】 发放规则
max_count 必填 integer
【发放次数总上限】 批次在生命周期内总发放次数,最多 100,000,000 次
max_count_per_day 选填 integer
【每日发放次数上限】 批次在每天内发放次数上限,每日刷新,最多 100,000,000 次。默认不限制每日发放上限
max_count_per_user 必填 integer
【每个用户领取次数上限】 每个用户最多可领取本批次的次数,最多 100 次。
single_usage_rule 选填 object
【单券使用规则】 当且仅当 usage_mode 为 SINGLE 时提供,其他场景不提供
coupon_available_period 必填 object
【券可核销时间】 确定用户领券后在什么时间段内可以核销
available_begin_time 必填 string
【批次开始时间】 遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
距离当前创建批次的时间不能超过90天,批次有效期最长不超过366天,摇优惠场景建议设置批次时间大于等于5天
available_end_time 必填 string
【批次结束时间】 遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
批次有效期最长不超过366天
available_days 选填 integer
【券生效后N天内可用】 日期区间内,券生效后 N 天内有效,最多365天。例如:
生效当天内有效填 1
生效后2天内有效填 2
依此类推……
用户在有效期开始前领取商品券,则从有效期第1天开始计算天数,用户在有效期内领取商品券,则从领取当天开始计算天数,无论用户何时领取商品券,商品券在活动有效期结束后均不可用。
可配合 wait_days_after_receive 一同填写,也可单独填写。
注:不可与 irregular_available_period_list 同时配置
wait_days_after_receive 选填 integer
【领券后需等待N天才生效】 日期区间内,用户领券后需等待 N 天才开始生效,最多30天。例如:
领券后当天开始生效则无需填写
领券后第二天开始生效则填写 1
用户在有效期开始前领取商品券,则从有效期第1天开始计算天数,用户在有效期内领取商品券,则从领取当天开始计算天数。无论用户何时领取商品券,商品券在活动有效期结束后均不可用。
需配合 available_days 一同填写,不可单独填写。
注:不可与 irregular_available_period_list 同时配置
weekly_available_period 选填 object
【每周固定可用时间】 日期区间内,每周固定时间可以使用。可与 available_days 和 wait_days_after_receive 一同配置,一同配置时条件需同时满足券才可用(时间范围取交集)。
注:不可与 irregular_available_period_list 同时配置
day_list 必填 array[string]
【每周可用星期数】 每周特定星期X可用,在日期区间内每周循环有效。例如 配置 ["MONDAY", "FRIDAY"] 表示每周一和周五可用。
可选取值
MONDAY: 周一可用TUESDAY: 周二可用WEDNESDAY: 周三可用THURSDAY: 周四可用FRIDAY: 周五可用SATURDAY: 周六可用SUNDAY: 周日可用
day_period_list 选填 array[object]
【当天可用时间段】 生效当天特定时间段内有效,可以配置多个时间段。最多可以配置 3 个时间段。不配置则全天可用。
begin_time 必填 integer
【当天可用开始时间】 当天可用时间距离当天 00:00:00 的秒数,如 60 表示当天 00:01:00 开始可用。取值范围 [0,86399] 且必须小于 end_time
end_time 必填 integer
【当天可用结束时间】 当天结束可用时间距离当天 00:00:00 的秒数,如 86399 表示当天 23:59:59 结束可用。取值范围 [0,86399] 且必须大于 begin_time
irregular_available_period_list 选填 array[object]
【指定可用时间段】 可以配置多个无规律时间段,不同区间内请勿重叠,最多可配置2个区间。
注:不可与 available_days、wait_days_after_receive、weekly_available_period 同时配置
begin_time 必填 string
【开始时间】 区间开始时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
end_time 必填 string
【结束时间】 区间结束时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
available_seconds 选填 integer
【领取后N秒内有效】 日期区间内,用户领券后立即生效,自领取时刻起 N 秒内可用,不与自然日对齐。取值范围为 3600~86400,且仅支持 3600 的整数倍。
注:不可与 available_days、wait_days_after_receive、weekly_available_period、irregular_available_period_list 同时配置
normal_coupon 选填 object
【满减券使用规则】 当且仅当 type 为 NORMAL 且 scope 为 SINGLE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受满减优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
discount_amount 必填 integer
【固定减免金额】 固定减免金额,单位为分,必须大于0。
discount_coupon 选填 object
【折扣券使用规则】 当且仅当 type 为 DISCOUNT 且 scope 为 SINGLE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受折扣优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
percent_off 必填 integer
【固定减免百分比】 表示减免金额为总金额的百分比,必须大于0。例如:填入 30 表示减免 30%,即打 7 折
exchange_coupon 选填 object
【兑换券使用规则】 当且仅当 type 为 EXCHANGE 且 scope 为 SINGLE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可进行兑换。门槛可以为0,0元和0.01元都为无门槛兑换。例如:
满 100 元可用填
10000满 0.01 元可用填
1
exchange_price 必填 integer
【固定兑换价格】 单位为分,必须大于或等于0。
usage_rule_display_info 必填 object
【券使用规则展示信息】 券使用规则展示信息
coupon_usage_method_list 必填 array[string]
【券使用方式列表】 可以配置多种使用方式
可选取值
OFFLINE: 线下滴码核销,点击券“立即使用”跳转展示券二维码详情(投放计划暂不支持此核销方式)MINI_PROGRAM: 线上小程序核销,点击券“立即使用”跳转至配置的商家小程序(需要添加小程序AppID和Path)APP: APP核销,在商家APP内核销PAYMENT_CODE: 微信支付付款码核销,用户点击券“立即使用”将跳转至微信支付钱包付款码,品牌方扫描付款码后可通过付款码获取到用户openid,通过openid查询并核销用户券,核销后再发起下单,适合线下支付场景
mini_program_appid 选填 string
【小程序AppID】 品牌方小程序AppID,可在微信公众平台查看,该小程序与品牌存在绑定关系。
在 coupon_usage_method_list 中包含 MINI_PROGRAM 时必填,需和 mini_program_path 一同填写。
mini_program_path 选填 string
【小程序跳转路径】 品牌方小程序内部跳转路径。
在 coupon_usage_method_list 中包含 MINI_PROGRAM 时必填,需和 mini_program_appid 一同填写。
app_path 选填 string
【APP的H5跳转路径】 品牌方APP的H5跳转路径。在 app_jump_type 为 H5 时必填。
usage_description 必填 string(1000)
【券使用说明】 用于说明详细的券规则,长度不超过1000个UTF-8字符
coupon_available_store_info 选填 object
【券可用门店信息】 用于描述全部可用门店信息,可配置小程序跳转地址进行展示
description 必填 string(1000)
【券可用门店描述】 告知用户本券可在哪些门店使用,长度不超过1000个UTF-8字符
mini_program_appid 选填 string
【小程序AppID】 品牌方小程序AppID,用于展示可用门店列表的详细信息,可在微信公众平台查看,该小程序与品牌存在绑定关系。需和 mini_program_path 一同填写。
mini_program_path 选填 string
【小程序跳转路径】 品牌方小程序内部展示可用门店列表的详细信息的页面跳转路径,需和 mini_program_appid 一同填写。
app_jump_type 选填 string
【APP跳转类型】 APP跳转类型,在 coupon_usage_method_list 中包含 APP 时必填。
可选取值
H5: 跳转H5,点击券立即使用跳转至配置的H5页面PASSCODE_LINK: 口令链接,点击券立即使用展示口令链接供用户复制使用USAGE_GUIDE: 展示使用指引,引导前往APP核销
passcode_link 选填 string
【口令链接】 口令链接。在 app_jump_type 为 PASSCODE_LINK 时必填。
coupon_display_info 必填 object
【用户商品券展示信息】 用户商品券在卡包中的展示详情,包括引导用户的自定义入口
code_display_mode 必填 string
【用户商品券Code展示模式】 决定用户商品券Code在卡包中的展示形态
可选取值
INVISIBLE: 不展示CodeBARCODE: 条形码QRCODE: 二维码
background_color 选填 string
【背景颜色】 券的背景颜色,可设置10种颜色,色值请参考下方说明。颜色取值为颜色图中的颜色名称,不填默认为 Color020 。

entrance_mini_program 选填 object
【小程序入口】 展示跳转小程序的入口
appid 必填 string
【小程序AppID】 品牌方小程序的AppID,可在微信公众平台查看,该小程序与品牌存在绑定关系
path 必填 string
【小程序跳转路径】 品牌方小程序内部跳转路径
entrance_wording 必填 string(5)
【入口文案】 小程序入口文案,长度不超过5个UTF-8字符
guidance_wording 必填 string(6)
【引导文案】 小程序入口引导文案,长度不超过6个UTF-8字符
entrance_official_account 选填 object
【公众号入口】 展示跳转公众号的入口
appid 必填 string
【公众号AppID】 微信公众号唯一标识,可在微信公众平台查看,该公众号应与品牌方存在绑定关系
notify_config 必填 object
【事件通知配置】 发生券相关事件时,微信支付会向品牌方发送通知,需要提供通知相关配置
notify_appid 必填 string
【事件通知AppID】 品牌的AppID,支持小程序、服务号、公众号、APP类型的AppID,可在微信公众平台查看,用于券事件通知时计算用户的OpenID,需要与品牌存在绑定关系
store_scope 必填 string
【可用门店范围】 控制该批次可以在品牌下哪些门店使用
可选取值
NONE: 无关联门店,该批次对外不展示可用门店信息ALL: 所有门店可用,该批次在品牌下的所有门店可用,品牌无需为该批次关联门店列表SPECIFIC: 特定门店可用,品牌需调用关联门店接口关联门店,关联后该批次在关联的门店可用
sent_count_info 必填 object
【已发放次数】 本批次已发放次数
total_count 必填 integer
【已发放总次数】 批次在生命周期内已发放次数
today_count 必填 integer
【当天已发放次数】 批次在当天已发放次数
state 必填 string
【批次状态】 商品券批次状态
可选取值
AUDITING: 审批中SENDING: 发放中PAUSED: 已暂停STOPPED: 已停止,当前已到达结束时间DEACTIVATED: 已失效,品牌方主动调用失效接口使批次失效
deactivate_request_no 选填 string(128)
【失效请求单号】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用失效接口时传入的请求流水号
deactivate_time 选填 string
【失效时间】 当且仅当 state 为 DEACTIVATED 时提供,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
deactivate_reason 选填 string(150)
【失效原因】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用【失效商品券批次API】时传入的失效原因
attach 选填 string
【自定义附加信息】 调用发券接口时品牌方使用 attach 字段主动设置的附加信息。微信支付不会解析该信息,仅在查询用户商品券和回调中原样返回。
注: 发券渠道多样,只有品牌方通过发券接口发放的券才会在查询和回调中携带此字段,其他渠道发放的券 attach 为空。
channel_custom_info 选填 string(1000)
【渠道自定义信息】 使用微信支付提供的其他渠道(比如「摇一摇有优惠」)发放商品券时,渠道可能会设置该渠道特定的自定义信息,请根据 send_channel 字段判断如何解析本字段。不同渠道的自定义信息格式不同,请根据对应渠道的文档解析。
coupon_tag_info 选填 object
【用户商品券标签信息】 用户商品券标签信息
coupon_tag_list 选填 array[string]
【用户商品券标签列表】 用户商品券标签列表
可选取值
MEMBER: 会员标签,标识该用户商品券为会员券MEMBER_ACTIVITY: 会员活动标签,标识该用户券为会员活动券
member_tag_info 选填 object
【会员标签信息】 当用户商品券标签列表中有MEMBER时,该字段必填
member_card_id 选填 string
【会员卡模板ID】 通过商家名片会员API创建会员卡模板成功后,获得的会员卡模板ID
应答示例
200 OK
发送会员券
1{ 2 "coupon_code" : "Code_123456", 3 "coupon_state" : "CONFIRMING", 4 "valid_begin_time" : "2025-08-02T00:00:00+08:00", 5 "valid_end_time" : "2025-08-31T23:59:59+08:00", 6 "receive_time" : "2025-08-02T00:00:00+08:00", 7 "send_request_no" : "MCHSEND202003101234", 8 "send_channel" : "API", 9 "single_usage_detail" : { }, 10 "product_coupon" : { 11 "product_coupon_id" : "1000000013", 12 "scope" : "ALL", 13 "type" : "DISCOUNT", 14 "usage_mode" : "SINGLE", 15 "business_mode" : "FREE", 16 "single_usage_info" : { 17 "discount_coupon" : { 18 "threshold" : 10000, 19 "percent_off" : 20 20 } 21 }, 22 "display_info" : { 23 "name" : "全场满100立打8折-新名字", 24 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 25 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 26 "detail_image_url_list" : [ 27 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 28 ] 29 }, 30 "state" : "EFFECTIVE", 31 "out_product_no" : "Product_1234567890" 32 }, 33 "stock" : { 34 "product_coupon_id" : "1000000013", 35 "stock_id" : "1000000013001", 36 "remark" : "8月工作日有效批次", 37 "coupon_code_mode" : "UPLOAD", 38 "coupon_code_count_info" : { 39 "total_count" : 0, 40 "available_count" : 0 41 }, 42 "stock_send_rule" : { 43 "max_count" : 10000000, 44 "max_count_per_user" : 1 45 }, 46 "single_usage_rule" : { 47 "coupon_available_period" : { 48 "available_begin_time" : "2025-08-01T00:00:00+08:00", 49 "available_end_time" : "2025-08-31T23:59:59+08:00", 50 "available_days" : 30, 51 "weekly_available_period" : { 52 "day_list" : [ 53 "MONDAY", 54 "TUESDAY", 55 "WEDNESDAY", 56 "THURSDAY", 57 "FRIDAY" 58 ] 59 } 60 } 61 }, 62 "usage_rule_display_info" : { 63 "coupon_usage_method_list" : [ 64 "OFFLINE", 65 "MINI_PROGRAM", 66 "PAYMENT_CODE" 67 ], 68 "mini_program_appid" : "wx1234567890", 69 "mini_program_path" : "/pages/index/product", 70 "usage_description" : "工作日可用", 71 "coupon_available_store_info" : { 72 "description" : "所有门店可用,可使用小程序查看门店列表", 73 "mini_program_appid" : "wx1234567890", 74 "mini_program_path" : "/pages/index/store-list" 75 } 76 }, 77 "coupon_display_info" : { 78 "code_display_mode" : "QRCODE", 79 "background_color" : "Color010", 80 "entrance_mini_program" : { 81 "appid" : "wx1234567890", 82 "path" : "/pages/index/product", 83 "entrance_wording" : "欢迎选购", 84 "guidance_wording" : "获取更多优惠" 85 }, 86 "entrance_official_account" : { 87 "appid" : "wx1234567890" 88 } 89 }, 90 "notify_config" : { 91 "notify_appid" : "wx4fd12345678" 92 }, 93 "store_scope" : "NONE", 94 "sent_count_info" : { 95 "total_count" : 0, 96 "today_count" : 0 97 }, 98 "state" : "SENDING" 99 }, 100 "attach" : "any attach content", 101 "coupon_tag_info" : { 102 "coupon_tag_list" : [ 103 "MEMBER" 104 ], 105 "member_tag_info" : { 106 "member_card_id" : "MemberCardId_1234567890" 107 } 108 } 109} 110
发放普通券
1{ 2 "coupon_code" : "Code_123456", 3 "coupon_state" : "CONFIRMING", 4 "valid_begin_time" : "2025-08-02T00:00:00+08:00", 5 "valid_end_time" : "2025-08-31T23:59:59+08:00", 6 "receive_time" : "2025-08-02T00:00:00+08:00", 7 "send_request_no" : "MCHSEND202003101234", 8 "send_channel" : "API", 9 "single_usage_detail" : { }, 10 "product_coupon" : { 11 "product_coupon_id" : "1000000013", 12 "scope" : "ALL", 13 "type" : "DISCOUNT", 14 "usage_mode" : "SINGLE", 15 "business_mode" : "FREE", 16 "single_usage_info" : { 17 "discount_coupon" : { 18 "threshold" : 10000, 19 "percent_off" : 20 20 } 21 }, 22 "display_info" : { 23 "name" : "全场满100立打8折-新名字", 24 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 25 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 26 "detail_image_url_list" : [ 27 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 28 ] 29 }, 30 "state" : "EFFECTIVE", 31 "out_product_no" : "Product_1234567890" 32 }, 33 "stock" : { 34 "product_coupon_id" : "1000000013", 35 "stock_id" : "1000000013001", 36 "remark" : "8月工作日有效批次", 37 "coupon_code_mode" : "UPLOAD", 38 "coupon_code_count_info" : { 39 "total_count" : 0, 40 "available_count" : 0 41 }, 42 "stock_send_rule" : { 43 "max_count" : 10000000, 44 "max_count_per_user" : 1 45 }, 46 "single_usage_rule" : { 47 "coupon_available_period" : { 48 "available_begin_time" : "2025-08-01T00:00:00+08:00", 49 "available_end_time" : "2025-08-31T23:59:59+08:00", 50 "available_days" : 30, 51 "weekly_available_period" : { 52 "day_list" : [ 53 "MONDAY", 54 "TUESDAY", 55 "WEDNESDAY", 56 "THURSDAY", 57 "FRIDAY" 58 ] 59 } 60 } 61 }, 62 "usage_rule_display_info" : { 63 "coupon_usage_method_list" : [ 64 "OFFLINE", 65 "MINI_PROGRAM", 66 "PAYMENT_CODE" 67 ], 68 "mini_program_appid" : "wx1234567890", 69 "mini_program_path" : "/pages/index/product", 70 "usage_description" : "工作日可用", 71 "coupon_available_store_info" : { 72 "description" : "所有门店可用,可使用小程序查看门店列表", 73 "mini_program_appid" : "wx1234567890", 74 "mini_program_path" : "/pages/index/store-list" 75 } 76 }, 77 "coupon_display_info" : { 78 "code_display_mode" : "QRCODE", 79 "background_color" : "Color010", 80 "entrance_mini_program" : { 81 "appid" : "wx1234567890", 82 "path" : "/pages/index/product", 83 "entrance_wording" : "欢迎选购", 84 "guidance_wording" : "获取更多优惠" 85 }, 86 "entrance_official_account" : { 87 "appid" : "wx1234567890" 88 } 89 }, 90 "notify_config" : { 91 "notify_appid" : "wx4fd12345678" 92 }, 93 "store_scope" : "NONE", 94 "sent_count_info" : { 95 "total_count" : 0, 96 "today_count" : 0 97 }, 98 "state" : "SENDING" 99 }, 100 "attach" : "any attach content" 101} 102
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
400 | INVALID_REQUEST | 当前发放模式不允许传入券码 | 当且仅当该批次的 coupon_code_mode 为 API_ASSIGN 时必传,其他模式下用户商品券Code由微信支付分配,请勿传入券码。 |
400 | PARAM_ERROR | 指定 MEMBER 标签时必须提供 member_card_id | 请在 member_tag_info 中填写 member_card_id |
403 | USER_ERROR | 用户不是该品牌的会员 | 用户不是该品牌的会员,无法发放会员券 |
400 | INVALID_REQUEST | 单券使用模式的商品券批次,应该在「单券使用规则」中包含对应类型的优惠规则。对于文档中标记不应填写的优惠规则应删除。 | 请在「单券使用规则」中包含对应类型的优惠规则,并删除文档中标记不应填写的优惠规则。 |
400 | INVALID_REQUEST | 多次优惠使用模式的商品券批次,应该在「多次优惠使用规则」中包含对应类型的优惠规则,且数量与多次优惠的优惠次数相等 | 在「多次优惠使用规则」中包含对应类型的优惠规则,且数量与多次优惠的优惠次数相等 |
400 | INVALID_REQUEST | 单品满减券或单品折扣券不应在商品券中设置「满减券使用规则」或「折扣券使用规则」,而是应该在商品券批次中设置 | 请删除商品券中的「满减券使用规则」或「折扣券使用规则」,并在商品券批次中设置对应的优惠规则 |
403 | NO_AUTH | 品牌没有此接口权限 | 品牌没有此接口权限 |
400 | PARAM_ERROR | page_token 不合法,请确认 page_token 来自于上一个列表查询请求的 next_page_token | 请确认 page_token 来自于上一个列表查询请求的 next_page_token,如果是初次查询则不要填写 page_token 参数 |
400 | INVALID_REQUEST | 发放单号已使用 | 更换发券单号 |
400 | INVALID_REQUEST | 商品券支持APP核销时,必须提供「APP跳转路径」 | 请提供「APP跳转路径」参数 |
400 | PARAM_ERROR | 分页大小超出限制,请根据接口文档调整到允许的范围 | 请调整分页大小到规定范围 |
404 | NOT_FOUND | 当前访问对象不存在,请确认ID是否合法且属于当前品牌 | 请确认ID是否合法且属于当前品牌 |
400 | INVALID_REQUEST | 商品券支持小程序核销时,必须提供「小程序AppID」 | 请提供「小程序AppID」 |
400 | PARAM_ERROR | 商品券批次ID不能为空 | 补充商品券批次ID |
400 | INVALID_REQUEST | 单品券必须提供商品原价,请补充 | 请补充商品原价 |
400 | INVALID_REQUEST | 商品券支持小程序核销时,必须提供「小程序跳转路径」 | 请提供提供「小程序跳转路径」 |
400 | PARAM_ERROR | 时间字符串格式错误,请使用 RFC3339 标准格式 | 请使用 RFC3339 标准格式 |
400 | INVALID_REQUEST | 单券模式下,全场满减券应在商品券中提供满减券使用规则信息 | 请在商品券中提供「满减券使用规则信息」 |
400 | INVALID_REQUEST | 每周固定可用时间(weekly_available_period)中提供当天可用时间段时(day_period_list),每周可用星期数(day_list)必填 | 请补充 每周可用星期数(day_list) |
400 | INVALID_REQUEST | 单券模式下,全场券需要提供「单券模式信息(single_usage_info)」 | 请提供单券模式信息(single_usage_info) |
400 | INVALID_REQUEST | 多次优惠模式下必须提供「多次优惠模式信息(sequential_usage_info)」 | 请填写 多次优惠模式信息(sequential_usage_info) |
400 | INVALID_REQUEST | 传入的OpenID不合法 | 请使用参数 AppID 对应的的OpenID |
400 | PARAM_ERROR | 用户商品券Code不能为空 | 补充商品券Code参数 |
400 | INVALID_REQUEST | 命中商品券批次日限额 | 增加商品券批次日限额或更换批次后发放 |
400 | ALREADY_EXISTS | out_request_no 重复,请更换请求单号再试 | out_request_no 重复,请更换请求单号再试 |
400 | INVALID_REQUEST | 商品券批次状态不是发放中 | 等待商品券批次生效后再发放 |
400 | INVALID_REQUEST | 商品券状态不是生效中 | 等待商品券批次生效后再发放 |
403 | USER_ERROR | 发券达到用户总限额 | 更换发放批次 |
400 | PARAM_ERROR | Http header中缺少必填参数Wechatpay-Serial | 缺少必要商品券图片,请补充上传后重试 |
400 | PARAM_ERROR | 参数过短 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
400 | PARAM_ERROR | 参数过长 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
400 | PARAM_ERROR | 参数错误 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
400 | PARAM_ERROR | 参数超出取值范围 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
400 | INVALID_REQUEST | Http头Content-Type值必须为application/json | 需将Http头中的Content-Type值设置为application/json |
400 | PARAM_ERROR | 传入了不支持的Accept-Language | 传入了不支持的Accept-Language,支持的Accept-Language值请参考应答的语种 |
401 | SIGN_ERROR | Authorization不合法 | Http头未传递Authorization值或Authorization值格式错误,请参考《APIv3如何签名和验签》,检查传递的Authorization值是否符合规则 |
400 | INVALID_REQUEST | Http头缺少Accept或User-Agent | Http头缺少Accept或User-Agent,请根据API文档在请求头中补充该参数 |
400 | PARAM_ERROR | 请求中含有未在API文档中定义的参数 | 请求中含有未在API文档中定义的参数,请检查传递的参数列表是否有编写错误的字段名 |
401 | SIGN_ERROR | Http头Authorization认证类型不正确 | Http头Authorization认证类型不正确,请将认证类型修改为WECHATPAY-BRAND-SHA256-RSA2048 |
400 | INVALID_REQUEST | 批次状态非运营中(新创建的批次请等3秒后使用) | 等待 3 秒后再发放 |
403 | USER_ERROR | 用户领取券张数已达上限 | 增加用户限额或更换发放批次 |
400 | PARAM_ERROR | 券Code已被其他发券占用 | 更换券Code |
