
Wechatpay Basic Payment
Prepare WeChat Pay APIv3 merchant credentials, APPID types, and binding steps before implementing checkout in China.
Overview
Wechatpay-basic-payment is an agent skill for the Build phase that explains WeChat Pay APIv3 merchant parameters and APPID binding before payment integration.
Install
npx skills add https://github.com/wechatpay-apiv3/wechatpay-skills --skill wechatpay-basic-paymentWhat is this skill?
- Explains three APPID types (公众号, 小程序, 移动应用) and why they cannot be mixed across payment scenes
- Documents required APIv3 params: mchid, appid, merchant API cert, WeChat Pay public key, APIv3 key
- 3-step APPID binding: merchant platform application, platform confirmation, binding result verification
- Binding limits table including 50 APPIDs per merchant account and no unbind after association
- Query paths for AppID on 公众平台 vs 开放平台 before submitting 关联AppID
- Up to 50 APPIDs may be associated per merchant account
- 3 AppID platform types documented (公众号, 小程序, 移动应用)
- 3-step APPID binding workflow
Adoption & trust: 861 installs on skills.sh; 263 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are ready to code WeChat Pay but orders fail because AppID type, merchant binding, or APIv3 credentials were never configured correctly.
Who is it for?
Indie developers shipping mini programs, native apps, or service-account web pay for China with standard merchant (non-partner) accounts.
Skip if: Stripe-only global checkout, sandbox-free experimentation without a Chinese merchant entity, or partner/sub-merchant platform models not covered here.
When should I use this skill?
Before implementing WeChat Pay APIv3 orders when merchant mode credentials and AppID relationships are not yet verified.
What do I get? / Deliverables
You have the correct AppID class, completed merchant–AppID authorization, and a checklist of certs and keys ready for APIv3 implementation skills.
- Completed AppID-to-merchant binding checklist
- Inventory of APIv3 keys and certificate requirements for implementation
Recommended Skills
Journey fit
Payment rail setup is Build work once you know you are shipping a product that must accept WeChat Pay. Integrations subphase holds third-party API onboarding—mchid, certificates, and APPID authorization—not generic pricing strategy.
How it compares
Onboarding and credential primer for APIv3—not a drop-in payment SDK or webhook verification skill by itself.
Common Questions / FAQ
Who is wechatpay-basic-payment for?
Builders adding WeChat Pay to apps or mini programs who need agent guidance on mchid, AppID types, and binding bureaucracy before writing pay APIs.
When should I use wechatpay-basic-payment?
Use it in Build during payment integrations when setting up merchant keys and AppID authorization, before JSAPI, APP, or mini-program pay implementation.
Is wechatpay-basic-payment safe to install?
It describes handling certificates and API keys—never commit secrets; review the Security Audits panel on this Prism page and store credentials in a secrets manager.
SKILL.md
READMESKILL.md - Wechatpay Basic Payment
# 开发必要参数说明 普通商户模式接入微信支付 APIv3 前,需要准备开发必要参数(mchid、appid、商户API证书、微信支付公钥、APIv3密钥等)。 ## APPID 详解与绑定 ### APPID 类型 APPID 是微信生态中应用的唯一标识,格式都是 `wx` + 一串字符(如 `wxd678efh567hg6787`),根据注册平台不同分为三种类型: | APPID 类型 | 注册平台 | 用途 | |-----------|---------|------| | 公众号 AppID | 公众平台(mp.weixin.qq.com) | 服务号/订阅号,用于公众号内网页场景 | | 小程序 AppID | 公众平台(mp.weixin.qq.com) | 微信小程序场景 | | 移动应用 AppID | 开放平台(open.weixin.qq.com) | 原生 APP(iOS/Android/鸿蒙)场景 | > **三种 APPID 格式相同但不能混用**。拿小程序 AppID 做 JSAPI 支付会报错,拿公众号 AppID 做 APP 支付也不行。 ### 为什么需要绑定 APPID 微信支付的所有支付方式都要求商户号与 APPID 建立绑定关系,未绑定时下单接口会报错。 ### 如何查询 APPID | APPID 类型 | 查询路径 | |-----------|---------| | 服务号/公众号 | 登录公众平台 → 设置与开发 → 开发接口管理 → 基本配置 → 开发者ID(AppID) | | 小程序 | 登录公众平台 → 开发与服务 → 开发管理 → 开发设置 → AppID(小程序ID) | | 移动应用 | 登录开放平台 → 管理中心 → 移动应用 → 查看 → 详情页面 → APPID | ### 如何绑定 **第一步:在商户平台发起绑定申请** 登录商户平台 → 产品中心 → APPID授权管理 → +关联AppID → 新增授权 → 填写 APPID → 提交 - 主体一致:直接填写 APPID 提交 - 主体不一致:还需填写 APPID 认证主体,并勾选《微信支付联合营运承诺函》 **第二步:在对应平台确认授权** | APPID 类型 | 确认路径 | |-----------|---------| | 服务号/公众号 | 登录公众平台 → 微信支付 → 商户号管理 → 待关联商户号 → 确认 | | 小程序 | 登录公众平台 → 微信支付 → 商户号管理 → 待关联商户号 → 确认 | | 移动应用 | 登录开放平台 → 移动应用 → 详情 → 能力专区 → 微信支付 → 查询详情 → 待关联商户号 → 确认 | > 委托第三方创建的小程序,需先设置邮箱密码后登录 PC 端确认。 **第三步:查看绑定结果** 登录商户平台 → 产品中心 → APPID账号管理 → 我关联的APPID账号 ### 绑定限制 | 限制项 | 说明 | |-------|------| | 数量上限 | 一个商户号最多关联 50 个 APPID | | 解绑 | 绑定后不支持解绑,每条关系相互独立 | | 跨主体 | 需补充 APPID 主体信息 | | 特殊费率 | 享有特殊行业费率的商户号,提交后有额外审核(1-3个工作日) | | 费率一致性 | APPID 已绑定其他商户号时,新商户号的费率需与已绑定的一致 | | 风控 | 商户号或 APPID 存在风险时(资料不全、有未处理处罚等),可能增加审核或被驳回 | ### APPID 相关常见报错 | 报错信息 | 原因 | 处理方式 | |---------|------|---------| | `appid and mchid not match` | 下单时传入的 appid 与商户号未建立绑定关系 | 按上述流程绑定 | | `appid is invalid` | appid 格式不对,或使用了错误类型的 appid | 检查是否用了正确类型的 APPID(如 JSAPI 需要公众号 AppID,不能用小程序 AppID) | | JSAPI 支付报权限错误 | 商户号绑定的是小程序 APPID,但用 JSAPI 调起 | JSAPI 需要绑定服务号 APPID | ## 参数与代码示例的对应关系 示例代码中构造函数所需的参数与上述开发必要参数的对应: ``` mchid → 商户号 certificateSerialNo → 商户API证书序列号 privateKeyFilePath → 商户API证书私钥文件路径(apiclient_key.pem) wechatPayPublicKeyId → 微信支付公钥ID wechatPayPublicKeyFilePath → 微信支付公钥文件路径(wxp_pub.pem) ``` package main import ( "bytes" "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/merchant/4015119334 "encoding/json" "fmt" "net/http" "net/url" "time" ) func main() { // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 config, err := wxpay_utility.CreateMchConfig( "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 ) if err != nil { fmt.Println(err) return } request := &DirectApiv3JsapiPrepayRequest{ Appid: wxpay_utility.String("wxd678efh567hg6787"), Mchid: wxpay_utility.String("1230000109"), Description: wxpay_utility.String("Image形象店-深圳腾大-QQ公仔"), OutTradeNo: wxpay_utility.String("1217752501201407033233368018"), TimeExpire: wxpay_utility.Time(time.Now()), Attach: wxpay_utility.String("自定义数据说明"), NotifyUrl: wxpay_utility.String(" https://www.weixin.qq.com/wxpay/pay.php"), GoodsTag: wxpay_utility.String("WXG"), SupportFapiao: wxpay_utility.Bool(false), Amount: &CommonAmountInfo{ Total: wxpay_utility.Int64(100), Currency: wxpay_utility.String("CNY"), }, Payer: &JsapiReqPayerInfo{ Openid: wxpay_utility.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"), }, Detail: &CouponInfo{ CostPrice: wxpay_utility.Int64(608800), InvoiceId: wxpay_utility.String("微信123"), GoodsDetail: []GoodsDetail{GoodsDetail{ MerchantGoodsId: wxpay_utility.String("1246464644"), WechatpayGoodsId: wxpay_utility.String("1001"), GoodsName: