修改商品券
更新时间:2025.11.07服务商可以通过该接口修改商品券信息。
注意: 修改只会对新发的券生效,历史已经发放给用户的券不会改变。
前置条件:商品券处于 EFFECTIVE 状态
接口说明
支持商户:【普通服务商】
请求方式:【PATCH】/v3/marketing/partner/product-coupon/product-coupons/{product_coupon_id}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
接口限频:20/秒(商户号维度)
请求参数
折叠全部参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Content-Type 必填 string
请设置为application/json
path 路径参数
product_coupon_id 必填 string
【商品券ID】 商品券的唯一标识,创建商品券时由微信支付生成
body 包体参数
out_request_no 必填 string(40)
【修改请求单号】 品牌修改商品券的请求流水号,品牌侧需保持唯一性,可使用 数字、大小写字母、下划线_、短横线- 组成,长度在6-40个字符之间
display_info 选填 object
【展示信息】 商品券展示信息;与 available_product_no_list 至少传其一
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
【商品原价】 单位为分,用于对外展示,最大为 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 一同填写。
brand_id 必填 string
【品牌ID】 微信支付为品牌方分配的唯一标识,该品牌应与服务商存在授权关系
available_product_no_list 选填 array[string(20)]
【可用商品编码列表】 可用商品编码列表;与 display_info 至少传其一;不传或空列表表示不修改本字段;仅单品或品类可填。单个编码可使用数字、大小写字母组成,长度不超过20个字符
请求示例
PATCH
调整商品券标题
1curl -X PATCH \ 2 https://api.mch.weixin.qq.com/v3/marketing/partner/product-coupon/product-coupons/1000000013 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "display_info" : { 8 "name" : "全场满100立打8折-新名字", 9 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 10 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 11 "detail_image_url_list" : [ 12 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 13 ] 14 }, 15 "out_request_no" : "12345_20250101_A3489", 16 "brand_id" : "120344" 17 }' 18
需配合微信支付工具库 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 UpdateProductCoupon { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "PATCH"; 28 private static String PATH = "/v3/marketing/partner/product-coupon/product-coupons/{product_coupon_id}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 UpdateProductCoupon client = new UpdateProductCoupon( 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 UpdateProductCouponRequest request = new UpdateProductCouponRequest(); 41 request.outRequestNo = "12345_20250101_A3489"; 42 request.productCouponId = "1000000013"; 43 request.displayInfo = new ProductCouponDisplayInfo(); 44 request.displayInfo.name = "全场满100立打8折-新名字"; 45 request.displayInfo.imageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 46 request.displayInfo.backgroundUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 47 request.displayInfo.detailImageUrlList = new ArrayList<>(); 48 { 49 request.displayInfo.detailImageUrlList.add("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"); 50 }; 51 request.brandId = "120344"; 52 try { 53 ProductCouponEntity response = client.run(request); 54 // TODO: 请求成功,继续业务逻辑 55 System.out.println(response); 56 } catch (WXPayUtility.ApiException e) { 57 // TODO: 请求失败,根据状态码执行不同的逻辑 58 e.printStackTrace(); 59 } 60 } 61 62 public ProductCouponEntity run(UpdateProductCouponRequest request) { 63 String uri = PATH; 64 uri = uri.replace("{product_coupon_id}", WXPayUtility.urlEncode(request.productCouponId)); 65 String reqBody = WXPayUtility.toJson(request); 66 67 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 68 reqBuilder.addHeader("Accept", "application/json"); 69 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 70 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 71 reqBuilder.addHeader("Content-Type", "application/json"); 72 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 73 reqBuilder.method(METHOD, requestBody); 74 Request httpRequest = reqBuilder.build(); 75 76 // 发送HTTP请求 77 OkHttpClient client = new OkHttpClient.Builder().build(); 78 try (Response httpResponse = client.newCall(httpRequest).execute()) { 79 String respBody = WXPayUtility.extractBody(httpResponse); 80 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 81 // 2XX 成功,验证应答签名 82 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 83 httpResponse.headers(), respBody); 84 85 // 从HTTP应答报文构建返回数据 86 return WXPayUtility.fromJson(respBody, ProductCouponEntity.class); 87 } else { 88 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 89 } 90 } catch (IOException e) { 91 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 92 } 93 } 94 95 private final String mchid; 96 private final String certificateSerialNo; 97 private final PrivateKey privateKey; 98 private final String wechatPayPublicKeyId; 99 private final PublicKey wechatPayPublicKey; 100 101 public UpdateProductCoupon(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 102 this.mchid = mchid; 103 this.certificateSerialNo = certificateSerialNo; 104 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 105 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 106 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 107 } 108 109 public static class UpdateProductCouponRequest { 110 @SerializedName("out_request_no") 111 public String outRequestNo; 112 113 @SerializedName("product_coupon_id") 114 @Expose(serialize = false) 115 public String productCouponId; 116 117 @SerializedName("display_info") 118 public ProductCouponDisplayInfo displayInfo; 119 120 @SerializedName("brand_id") 121 public String brandId; 122 123 @SerializedName("available_product_no_list") 124 public List<String> availableProductNoList; 125 } 126 127 public static class ProductCouponEntity { 128 @SerializedName("product_coupon_id") 129 public String productCouponId; 130 131 @SerializedName("scope") 132 public ProductCouponScope scope; 133 134 @SerializedName("type") 135 public ProductCouponType type; 136 137 @SerializedName("usage_mode") 138 public UsageMode usageMode; 139 140 @SerializedName("single_usage_info") 141 public SingleUsageInfo singleUsageInfo; 142 143 @SerializedName("progressive_bundle_usage_info") 144 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 145 146 @SerializedName("display_info") 147 public ProductCouponDisplayInfo displayInfo; 148 149 @SerializedName("out_product_no") 150 public String outProductNo; 151 152 @SerializedName("state") 153 public ProductCouponState state; 154 155 @SerializedName("deactivate_request_no") 156 public String deactivateRequestNo; 157 158 @SerializedName("deactivate_time") 159 public String deactivateTime; 160 161 @SerializedName("deactivate_reason") 162 public String deactivateReason; 163 164 @SerializedName("brand_id") 165 public String brandId; 166 167 @SerializedName("available_product_no_list") 168 public List<String> availableProductNoList; 169 170 @SerializedName("business_mode") 171 public ProductCouponBusinessMode businessMode; 172 } 173 174 public static class ProductCouponDisplayInfo { 175 @SerializedName("name") 176 public String name; 177 178 @SerializedName("image_url") 179 public String imageUrl; 180 181 @SerializedName("background_url") 182 public String backgroundUrl; 183 184 @SerializedName("detail_image_url_list") 185 public List<String> detailImageUrlList; 186 187 @SerializedName("original_price") 188 public Long originalPrice; 189 190 @SerializedName("combo_package_list") 191 public List<ComboPackage> comboPackageList; 192 } 193 194 public enum ProductCouponScope { 195 @SerializedName("ALL") 196 ALL, 197 @SerializedName("SINGLE") 198 SINGLE, 199 @SerializedName("CATEGORY") 200 CATEGORY 201 } 202 203 public enum ProductCouponType { 204 @SerializedName("NORMAL") 205 NORMAL, 206 @SerializedName("DISCOUNT") 207 DISCOUNT, 208 @SerializedName("EXCHANGE") 209 EXCHANGE 210 } 211 212 public enum UsageMode { 213 @SerializedName("SINGLE") 214 SINGLE, 215 @SerializedName("PROGRESSIVE_BUNDLE") 216 PROGRESSIVE_BUNDLE 217 } 218 219 public static class SingleUsageInfo { 220 @SerializedName("normal_coupon") 221 public NormalCouponUsageRule normalCoupon; 222 223 @SerializedName("discount_coupon") 224 public DiscountCouponUsageRule discountCoupon; 225 } 226 227 public static class ProgressiveBundleUsageInfo { 228 @SerializedName("count") 229 public Long count; 230 231 @SerializedName("interval_days") 232 public Long intervalDays; 233 } 234 235 public enum ProductCouponState { 236 @SerializedName("AUDITING") 237 AUDITING, 238 @SerializedName("EFFECTIVE") 239 EFFECTIVE, 240 @SerializedName("DEACTIVATED") 241 DEACTIVATED 242 } 243 244 public enum ProductCouponBusinessMode { 245 @SerializedName("FREE") 246 FREE 247 } 248 249 public static class ComboPackage { 250 @SerializedName("name") 251 public String name; 252 253 @SerializedName("pick_count") 254 public Long pickCount; 255 256 @SerializedName("choice_list") 257 public List<ComboPackageChoice> choiceList = new ArrayList<ComboPackageChoice>(); 258 } 259 260 public static class NormalCouponUsageRule { 261 @SerializedName("threshold") 262 public Long threshold; 263 264 @SerializedName("discount_amount") 265 public Long discountAmount; 266 } 267 268 public static class DiscountCouponUsageRule { 269 @SerializedName("threshold") 270 public Long threshold; 271 272 @SerializedName("percent_off") 273 public Long percentOff; 274 } 275 276 public static class ComboPackageChoice { 277 @SerializedName("name") 278 public String name; 279 280 @SerializedName("price") 281 public Long price; 282 283 @SerializedName("count") 284 public Long count; 285 286 @SerializedName("image_url") 287 public String imageUrl; 288 289 @SerializedName("mini_program_appid") 290 public String miniProgramAppid; 291 292 @SerializedName("mini_program_path") 293 public String miniProgramPath; 294 } 295 296} 297
需配合微信支付工具库 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 "strings" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &UpdateProductCouponRequest{ 28 OutRequestNo: wxpay_utility.String("12345_20250101_A3489"), 29 ProductCouponId: wxpay_utility.String("1000000013"), 30 DisplayInfo: &ProductCouponDisplayInfo{ 31 Name: wxpay_utility.String("全场满100立打8折-新名字"), 32 ImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), 33 BackgroundUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), 34 DetailImageUrlList: []string{ 35 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 36 }, 37 }, 38 BrandId: wxpay_utility.String("120344"), 39 } 40 41 response, err := UpdateProductCoupon(config, request) 42 if err != nil { 43 fmt.Printf("请求失败: %+v\n", err) 44 // TODO: 请求失败,根据状态码执行不同的处理 45 return 46 } 47 48 // TODO: 请求成功,继续业务逻辑 49 fmt.Printf("请求成功: %+v\n", response) 50} 51 52func UpdateProductCoupon(config *wxpay_utility.MchConfig, request *UpdateProductCouponRequest) (response *ProductCouponEntity, err error) { 53 const ( 54 host = "https://api.mch.weixin.qq.com" 55 method = "PATCH" 56 path = "/v3/marketing/partner/product-coupon/product-coupons/{product_coupon_id}" 57 ) 58 59 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 60 if err != nil { 61 return nil, err 62 } 63 reqUrl.Path = strings.Replace(reqUrl.Path, "{product_coupon_id}", url.PathEscape(*request.ProductCouponId), -1) 64 reqBody, err := json.Marshal(request) 65 if err != nil { 66 return nil, err 67 } 68 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 69 if err != nil { 70 return nil, err 71 } 72 httpRequest.Header.Set("Accept", "application/json") 73 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 74 httpRequest.Header.Set("Content-Type", "application/json") 75 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 76 if err != nil { 77 return nil, err 78 } 79 httpRequest.Header.Set("Authorization", authorization) 80 81 client := &http.Client{} 82 httpResponse, err := client.Do(httpRequest) 83 if err != nil { 84 return nil, err 85 } 86 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 87 if err != nil { 88 return nil, err 89 } 90 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 91 // 2XX 成功,验证应答签名 92 err = wxpay_utility.ValidateResponse( 93 config.WechatPayPublicKeyId(), 94 config.WechatPayPublicKey(), 95 &httpResponse.Header, 96 respBody, 97 ) 98 if err != nil { 99 return nil, err 100 } 101 response := &ProductCouponEntity{} 102 if err := json.Unmarshal(respBody, response); err != nil { 103 return nil, err 104 } 105 106 return response, nil 107 } else { 108 return nil, wxpay_utility.NewApiException( 109 httpResponse.StatusCode, 110 httpResponse.Header, 111 respBody, 112 ) 113 } 114} 115 116type UpdateProductCouponRequest struct { 117 OutRequestNo *string `json:"out_request_no,omitempty"` 118 ProductCouponId *string `json:"product_coupon_id,omitempty"` 119 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 120 BrandId *string `json:"brand_id,omitempty"` 121 AvailableProductNoList []string `json:"available_product_no_list,omitempty"` 122} 123 124func (o *UpdateProductCouponRequest) MarshalJSON() ([]byte, error) { 125 type Alias UpdateProductCouponRequest 126 a := &struct { 127 ProductCouponId *string `json:"product_coupon_id,omitempty"` 128 *Alias 129 }{ 130 // 序列化时移除非 Body 字段 131 ProductCouponId: nil, 132 Alias: (*Alias)(o), 133 } 134 return json.Marshal(a) 135} 136 137type ProductCouponEntity struct { 138 ProductCouponId *string `json:"product_coupon_id,omitempty"` 139 Scope *ProductCouponScope `json:"scope,omitempty"` 140 Type *ProductCouponType `json:"type,omitempty"` 141 UsageMode *UsageMode `json:"usage_mode,omitempty"` 142 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"` 143 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 144 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 145 OutProductNo *string `json:"out_product_no,omitempty"` 146 State *ProductCouponState `json:"state,omitempty"` 147 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 148 DeactivateTime *string `json:"deactivate_time,omitempty"` 149 DeactivateReason *string `json:"deactivate_reason,omitempty"` 150 BrandId *string `json:"brand_id,omitempty"` 151 AvailableProductNoList []string `json:"available_product_no_list,omitempty"` 152 BusinessMode *ProductCouponBusinessMode `json:"business_mode,omitempty"` 153} 154 155type ProductCouponDisplayInfo struct { 156 Name *string `json:"name,omitempty"` 157 ImageUrl *string `json:"image_url,omitempty"` 158 BackgroundUrl *string `json:"background_url,omitempty"` 159 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"` 160 OriginalPrice *int64 `json:"original_price,omitempty"` 161 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"` 162} 163 164type ProductCouponScope string 165 166func (e ProductCouponScope) Ptr() *ProductCouponScope { 167 return &e 168} 169 170const ( 171 PRODUCTCOUPONSCOPE_ALL ProductCouponScope = "ALL" 172 PRODUCTCOUPONSCOPE_SINGLE ProductCouponScope = "SINGLE" 173 PRODUCTCOUPONSCOPE_CATEGORY ProductCouponScope = "CATEGORY" 174) 175 176type ProductCouponType string 177 178func (e ProductCouponType) Ptr() *ProductCouponType { 179 return &e 180} 181 182const ( 183 PRODUCTCOUPONTYPE_NORMAL ProductCouponType = "NORMAL" 184 PRODUCTCOUPONTYPE_DISCOUNT ProductCouponType = "DISCOUNT" 185 PRODUCTCOUPONTYPE_EXCHANGE ProductCouponType = "EXCHANGE" 186) 187 188type UsageMode string 189 190func (e UsageMode) Ptr() *UsageMode { 191 return &e 192} 193 194const ( 195 USAGEMODE_SINGLE UsageMode = "SINGLE" 196 USAGEMODE_PROGRESSIVE_BUNDLE UsageMode = "PROGRESSIVE_BUNDLE" 197) 198 199type SingleUsageInfo struct { 200 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 201 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 202} 203 204type ProgressiveBundleUsageInfo struct { 205 Count *int64 `json:"count,omitempty"` 206 IntervalDays *int64 `json:"interval_days,omitempty"` 207} 208 209type ProductCouponState string 210 211func (e ProductCouponState) Ptr() *ProductCouponState { 212 return &e 213} 214 215const ( 216 PRODUCTCOUPONSTATE_AUDITING ProductCouponState = "AUDITING" 217 PRODUCTCOUPONSTATE_EFFECTIVE ProductCouponState = "EFFECTIVE" 218 PRODUCTCOUPONSTATE_DEACTIVATED ProductCouponState = "DEACTIVATED" 219) 220 221type ProductCouponBusinessMode string 222 223func (e ProductCouponBusinessMode) Ptr() *ProductCouponBusinessMode { 224 return &e 225} 226 227const ( 228 PRODUCTCOUPONBUSINESSMODE_FREE ProductCouponBusinessMode = "FREE" 229) 230 231type ComboPackage struct { 232 Name *string `json:"name,omitempty"` 233 PickCount *int64 `json:"pick_count,omitempty"` 234 ChoiceList []ComboPackageChoice `json:"choice_list,omitempty"` 235} 236 237type NormalCouponUsageRule struct { 238 Threshold *int64 `json:"threshold,omitempty"` 239 DiscountAmount *int64 `json:"discount_amount,omitempty"` 240} 241 242type DiscountCouponUsageRule struct { 243 Threshold *int64 `json:"threshold,omitempty"` 244 PercentOff *int64 `json:"percent_off,omitempty"` 245} 246 247type ComboPackageChoice struct { 248 Name *string `json:"name,omitempty"` 249 Price *int64 `json:"price,omitempty"` 250 Count *int64 `json:"count,omitempty"` 251 ImageUrl *string `json:"image_url,omitempty"` 252 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 253 MiniProgramPath *string `json:"mini_program_path,omitempty"` 254} 255
应答参数
折叠全部参数
200 OK
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
【商品原价】 单位为分,用于对外展示,最大为 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】时传入的失效原因
brand_id 必填 string
【品牌ID】 微信支付为品牌方分配的唯一标识,该品牌应与服务商存在授权关系
available_product_no_list 选填 array[string]
【可用商品编码列表】 商户创建商品券时主动传入的可用商品编码,原样返回
business_mode 必填 string
【业务模式】 商品券的业务模式;本能力上线前创建的存量商品券统一返回 FREE
可选取值
FREE: 普通券,用户可直接领取。
应答示例
200 OK
调整商品券标题
1{ 2 "product_coupon_id" : "1000000013", 3 "scope" : "ALL", 4 "type" : "DISCOUNT", 5 "usage_mode" : "SINGLE", 6 "business_mode" : "FREE", 7 "single_usage_info" : { 8 "discount_coupon" : { 9 "threshold" : 10000, 10 "percent_off" : 20 11 } 12 }, 13 "display_info" : { 14 "name" : "全场满100立打8折-新名字", 15 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 16 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 17 "detail_image_url_list" : [ 18 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 19 ] 20 }, 21 "state" : "EFFECTIVE", 22 "out_product_no" : "Product_1234567890", 23 "brand_id" : "120344" 24} 25
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
400 | INVALID_REQUEST | 传入参数不符合业务规则 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
404 | NOT_FOUND | 未找到 product_coupon_id 对应的商品券 | 请确认 product_coupon_id 存在且属于当前品牌 |
429 | RATELIMIT_EXCEEDED | 请求超过接口频率限制 | 请稍后使用原参数重试 |
