{
  "tags": [
    "支付"
  ],
  "description": "为当前登录用户创建余额充值订单，并按后台配置调用原生微信支付、CodePay 或 Cccyun 微信支付渠道。系统会根据充值限制要求个人实名认证、二次实名认证或企业认证；成功后订单状态为未付款，支付回调到账后才会增加余额。",
  "operationId": "user_post_v1_wxpay_preorder",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "请求已被处理。成功时返回支付二维码、支付网关表单参数或订单 ID；金额格式无效、未开通微信支付、未满足认证限制或第三方下单失败时仍返回 HTTP 200。",
      "content": {
        "application/json": {
          "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"
                  }
                }
              }
            }
          },
          "examples": {
            "native": {
              "summary": "二维码支付订单",
              "value": {
                "code": 0,
                "msg": "订单创建成功",
                "data": {
                  "code_url": "weixin://wxpay/bizpayurl?pr=demo",
                  "order_id": 101,
                  "money": null
                }
              }
            },
            "cccyun": {
              "summary": "Cccyun 网关订单",
              "value": {
                "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"
                }
              }
            },
            "authRequired": {
              "summary": "需要实名认证",
              "value": {
                "code": "wxpay_pre_order-11",
                "msg": "请先完成实名认证再充值",
                "data": ""
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "订单创建成功",
            "data": {
              "code_url": "weixin://wxpay/bizpayurl?pr=demo",
              "order_id": 101,
              "money": null
            }
          }
        }
      }
    }
  },
  "x-python-handler": "pay.WxpayPreOrder",
  "x-python-route-line": 979,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "amount"
          ],
          "properties": {
            "amount": {
              "type": "string",
              "pattern": "^\\d+(\\.\\d{1,2})?$",
              "description": "必填。充值金额，必须是非负数字字符串；可带小数点，且最多两位小数。",
              "example": "10.00"
            }
          },
          "example": {
            "amount": "10.00"
          }
        }
      }
    }
  },
  "parameters": [],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "pay.WxpayPreOrder"
    },
    {
      "key": "x-python-route-line",
      "value": 979
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "post",
  "path": "/v1/wxpay/preorder",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "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 同时发送。"
    }
  },
  "jsonRequestBodyExample": {
    "amount": "10.00"
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "创建微信充值预支付订单",
    "description": {
      "content": "为当前登录用户创建余额充值订单，并按后台配置调用原生微信支付、CodePay 或 Cccyun 微信支付渠道。系统会根据充值限制要求个人实名认证、二次实名认证或企业认证；成功后订单状态为未付款，支付回调到账后才会增加余额。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "wxpay",
        "preorder"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": []
    },
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "POST",
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}