
Wechatpay Product Coupon
Create WeChat Pay brand product coupons (e.g.全场折扣券) from official Go sample parameters without rewriting paths, signatures, or request shapes.
Overview
WeChat Pay Product Coupon is an agent skill for the Build phase that parameterizes official WeChat Pay Go samples to create brand product coupons.
Install
npx skills add https://github.com/wechatpay-apiv3/wechatpay-skills --skill wechatpay-product-couponWhat is this skill?
- Official 创建商品券 sample: SINGLE usage, ALL scope, DISCOUNT type
- BrandConfig from cert serial, apiclient_key.pem, and wxp_pub.pem paths
- Explicit field rules: OutRequestNo 6–40 chars, usage_mode=SINGLE with scope=ALL
- DiscountCoupon vs NormalCoupon branching by coupon type
- Hard rule: only replace parameters and comments—do not rewrite API paths or signing
- OutRequestNo length 6–40 characters per sample comments
- Example usage_mode=SINGLE with scope=ALL for store-wide discount coupon
Adoption & trust: 799 installs on skills.sh; 263 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need WeChat 商品券 live in your backend but cannot safely let an agent freestyle payment API paths, signatures, or request JSON.
Who is it for?
Go backends integrating WeChat Pay brand product coupons with certs already issued in the brand console.
Skip if: Non-WeChat payment stacks, teams without brand IDs and API certs, or agents asked to invent new endpoints outside the official sample.
When should I use this skill?
When implementing WeChat Pay brand product coupon creation from official v3 samples (parameter fill only).
What do I get? / Deliverables
You get a review-ready CreateProductCoupon request wired through official BrandConfig and typed models, ready to test in brand sandbox before launch.
- Parameterized CreateProductCouponRequest for chosen scope/type
- BrandConfig initialization snippet ready for sandbox or staging calls
- Annotated field map for conditional DiscountCoupon vs NormalCoupon blocks
Recommended Skills
Journey fit
Coupon creation is an API integration task during product build, not launch SEO or post-ship monitoring. Integrations subphase matches third-party payment SDK wiring, certs, and request models for WeChat Pay v3 brand APIs.
How it compares
Official-parameter skill template—not a generic coupon generator or MCP; pair with your own secrets management outside the repo.
Common Questions / FAQ
Who is wechatpay-product-coupon for?
Indie and solo developers building WeChat Pay–connected products who want agents to fill official coupon-creation samples instead of writing payment glue from memory.
When should I use wechatpay-product-coupon?
During Build → integrations when defining SINGLE全场折扣券 (or related scope/type variants) before Ship security review and Launch distribution in WeChat channels.
Is wechatpay-product-coupon safe to install?
Samples reference real cert paths and keys you must supply locally; review the Security Audits panel on this Prism page and never commit private keys or live merchant IDs into chat logs.
SKILL.md
READMESKILL.md - Wechatpay Product Coupon
package main // SDK工具类(HTTP客户端 + 数据模型)见: ../9-SDK工具类/brand_models_and_client.go // ❗重要:本文件为官方示例代码,只允许替换参数和添加注释,禁止从零编写或拼接修改API路径、签名逻辑、请求结构 import ( "demo/wxpay_brand_utility" // 引用微信支付工具库 "encoding/json" "fmt" ) // 创建商品券 - 单券-全场-折扣券 func main() { // TODO: 请准备商户开发必要参数 config, err := wxpay_brand_utility.CreateBrandConfig( "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考品牌经营平台【安全中心】 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考品牌经营平台【安全中心】 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 ) if err != nil { fmt.Println(err) return } request := &CreateProductCouponRequest{ OutRequestNo: wxpay_brand_utility.String("12345_20250101_A3489"), // 必填,创建请求单号,6-40个字符,品牌侧需保持唯一性 Scope: PRODUCTCOUPONSCOPE_ALL.Ptr(), // 必填,优惠范围:ALL-全场券,SINGLE-单品券 Type: PRODUCTCOUPONTYPE_DISCOUNT.Ptr(), // 必填,商品券类型:NORMAL-满减券,DISCOUNT-折扣券,EXCHANGE-兑换券 UsageMode: USAGEMODE_SINGLE.Ptr(), // 必填,使用模式:SINGLE-单券,SEQUENTIAL-多次优惠 // 【条件必填】单券模式信息 // 填写条件:当 usage_mode=SINGLE 且 scope=ALL 时必填,用于设置全场券的优惠规则 // 说明:本示例为全场折扣券,因此需要填写 DiscountCoupon;如果是全场满减券则填写 NormalCoupon SingleUsageInfo: &SingleUsageInfo{ // 【条件必填】折扣券使用规则 // 填写条件:当 type=DISCOUNT 且 scope=ALL 时必填 // 说明:如果 type=NORMAL 则需填写 NormalCoupon 而非 DiscountCoupon DiscountCoupon: &DiscountCouponUsageRule{ Threshold: wxpay_brand_utility.Int64(10000), // 必填,门槛金额(单位:分),满100元可用;无门槛填0 PercentOff: wxpay_brand_utility.Int64(20), // 必填,折扣百分比,20表示减免20%即打8折;30表示减免30%即打7折 }, }, // 必填,商品券展示信息 DisplayInfo: &ProductCouponDisplayInfo{ Name: wxpay_brand_utility.String("全场满100立打8折"), // 必填,商品券名称,3-15个字符 ImageUrl: wxpay_brand_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), // 必填,商品券图片URL,需通过图片上传接口获取,建议1080*1080,1:1 BackgroundUrl: wxpay_brand_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), // 选填,背景图URL,建议1170*1326,65:77 DetailImageUrlList: []string{ // 选填,详情图URL列表,最多6张 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", }, // 【条件必填】以下两个字段仅当 scope=SINGLE(单品券) 时必填,全场券无需填写 // OriginalPrice: wxpay_brand_utility.Int64(10000), // 商品原价(单位:分) // ComboPackageList: []ComboPackage{...}, // 套餐组合列表 }, OutProductNo: wxpay_brand_utility.String("Product_1234567890"), // 选填,商户侧商品券唯一标识 // 【条件必填】批次信息 // 填写条件:当 usage_mode=SINGLE 时必填 // 说明:单券模式必须配置批次信息,包含发放规则、使用规则、展示信息等 Stock: &StockForCreate{ Remark: wxpay_brand_utility.String("8月工作日有效批次"), // 选填,批次备注,最多60个字符 CouponCodeMode: COUPONCODEMODE_UPLOAD.Ptr(), // 必填,券码模式:WECHATPAY-微信支付随机生成/UPLOAD-品牌方预上传/API_ASSIGN-品牌方自行指定 // 必填,批次发放规则 StockSendRule: &StockSendRule{ MaxCount: wxpay_brand_utility.Int64(10000000), // 必填,批次最大发放数量 MaxCountPerDay: wxpay_brand_utility.Int64(100000), // 选填,单日最大发放数量 MaxCountPerUser: wxpay_brand_utility.Int64(1), // 必填,单用户最大领取数量 }, // 【条件必填】单券使用规则 // 填写条件:当 usage_mode=SINGLE 时必填 // 说明:定义券的可用时间范围、周期等规则 SingleUsageRule: &SingleUsageRule{ // 必填,券可核销时间 CouponAvailablePeriod: &SingleCouponAvailablePeriod{ AvailableBeginTime: wxpay_brand_utility.String("2025-08-01T00:00:00+08:00"), // 必填,可用开始时间(RFC3339格式) AvailableEndTime: wxpay_brand_utility.String("2025-08-31T23:59:59+08:00"), // 必填,可用结束时间(RFC3339格式) AvailableDays: wxpay_brand_utility.Int64(30), // 选填,领取后有效天数,1-365天 WaitDaysAfterReceive: wxpay_brand_utility.Int64(0), // 选填,领取后等待天数,0表示领取后立即可用 // 选填,每周固定可用时间(如仅工作日可用) WeeklyAvailablePeriod: &FixedWeekPeriod{ // 【条件必填】每周可用星期数 // 填写条件:当设置了 WeeklyAvailablePeriod 时必填 DayList: []WeekEnum{ WEEKENUM_MONDAY, WEEKENUM_TUESDAY, WEEKENUM_WEDNESDAY, WEEKENUM_THURSDAY,