itecdn 5.x / 用户 API
创建微信充值预支付订单
POST
/v1/wxpay/preorder为当前登录用户创建余额充值订单,并按后台配置调用原生微信支付、CodePay 或 Cccyun 微信支付渠道。系统会根据充值限制要求个人实名认证、二次实名认证或企业认证;成功后订单状态为未付款,支付回调到账后才会增加余额。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
未定义路径、查询或请求头参数。
请求体 · 必填
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
amount | string | 必填 | 必填。充值金额,必须是非负数字字符串;可带小数点,且最多两位小数。 约束 / 默认值 / 示例 |
完整 Schema
{
"type": "object",
"additionalProperties": false,
"required": [
"amount"
],
"properties": {
"amount": {
"type": "string",
"pattern": "^\\d+(\\.\\d{1,2})?$",
"description": "必填。充值金额,必须是非负数字字符串;可带小数点,且最多两位小数。",
"example": "10.00"
}
},
"example": {
"amount": "10.00"
}
}请求体示例
{
"amount": "10.00"
}响应
HTTP 200
请求已被处理。成功时返回支付二维码、支付网关表单参数或订单 ID;金额格式无效、未开通微信支付、未满足认证限制或第三方下单失败时仍返回 HTTP 200。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
msg | string | 必填 | 处理结果说明。 约束 / 默认值 / 示例 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | object | 必填 | 支付渠道返回的预支付数据。原生微信和 CodePay 返回 code_url、order_id、money;Cccyun 返回提交支付网关所需参数。 展开字段结构支付渠道返回的预支付数据。原生微信和 CodePay 返回 code_url、order_id、money;Cccyun 返回提交支付网关所需参数。
|
完整 Schema
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"msg": {
"type": "string",
"description": "处理结果说明。",
"example": "订单创建成功"
},
"data": {
"type": "object",
"description": "支付渠道返回的预支付数据。原生微信和 CodePay 返回 code_url、order_id、money;Cccyun 返回提交支付网关所需参数。",
"properties": {
"code_url": {
"type": "string",
"description": "原生微信或 CodePay 的付款二维码链接。",
"example": "weixin://wxpay/bizpayurl?pr=demo"
},
"order_id": {
"type": "integer",
"description": "本系统创建的充值订单 ID;Cccyun 渠道不返回该字段。",
"example": 101
},
"money": {
"type": "string",
"nullable": true,
"description": "CodePay 或 Cccyun 返回的支付金额;原生微信支付通常为 null。",
"example": "10.00"
},
"url": {
"type": "string",
"description": "Cccyun 支付网关提交地址。",
"example": "https://pay.example.invalid/submit.php"
},
"pid": {
"type": "string",
"description": "Cccyun 商户标识。",
"example": "demo-merchant"
},
"type": {
"type": "string",
"description": "Cccyun 支付方式,固定为 wxpay。",
"example": "wxpay"
},
"out_trade_no": {
"type": "string",
"description": "商户订单号。",
"example": "cy202601010001"
},
"notify_url": {
"type": "string",
"description": "支付回调地址。",
"example": "https://master.example.invalid/v1/wxpay/notify"
},
"return_url": {
"type": "string",
"description": "付款完成后的返回地址。",
"example": "https://master.example.invalid/pay-result"
},
"name": {
"type": "string",
"description": "订单商品名称。",
"example": "itecdn余额充值"
},
"sitename": {
"type": "string",
"description": "站点名称。",
"example": "itecdn"
},
"sign": {
"type": "string",
"description": "Cccyun 请求签名。",
"example": "sanitized-signature"
},
"sign_type": {
"type": "string",
"description": "签名算法,固定为 MD5。",
"example": "MD5"
}
}
}
}
}示例
{
"code": 0,
"msg": "订单创建成功",
"data": {
"code_url": "weixin://wxpay/bizpayurl?pr=demo",
"order_id": 101,
"money": null
}
}二维码支付订单
{
"code": 0,
"msg": "订单创建成功",
"data": {
"code_url": "weixin://wxpay/bizpayurl?pr=demo",
"order_id": 101,
"money": null
}
}Cccyun 网关订单
{
"code": 0,
"msg": "订单创建成功",
"data": {
"url": "https://pay.example.invalid/submit.php",
"pid": "demo-merchant",
"type": "wxpay",
"out_trade_no": "cy202601010001",
"notify_url": "https://master.example.invalid/v1/wxpay/notify",
"return_url": "https://master.example.invalid/pay-result",
"name": "itecdn余额充值",
"money": "10.00",
"sitename": "itecdn",
"sign": "sanitized-signature",
"sign_type": "MD5"
}
}需要实名认证
{
"code": "wxpay_pre_order-11",
"msg": "请先完成实名认证再充值",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request POST \
"https://master.example.invalid/v1/wxpay/preorder" \
--header "access-token: YOUR_ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"amount": "10.00"}'