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