> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建订单

> 在 GatePay 支付平台创建一个新的支付订单。成功创建后，系统会返回支付相关信息，可用于跳转到支付页面或生成支付二维码。

## 概述

本页说明 `/v1/pay/order` 接口。完整的请求参数、响应结构与示例由上方关联的 OpenAPI 定义渲染。

## 说明

* 认证方式使用 GatePay 标准签名请求头。
* 本页展示普通商户接口。
* 通用签名规则请参见 [/api-reference/version/100/cn/common/securityAndSignature](/api-reference/version/100/cn/common/securityAndSignature)。


## OpenAPI

````yaml api-reference/version/100/cn/openapi/payment-order-openapi.json POST /v1/pay/order
openapi: 3.1.0
info:
  title: GatePay 支付订单 API
  description: GatePay 支付平台 API 接口文档
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://openplatform.gateapi.io
security: []
paths:
  /v1/pay/order:
    post:
      summary: 创建订单
      description: 在 GatePay 支付平台创建一个新的支付订单。成功创建后，系统会返回支付相关信息，可用于跳转到支付页面或生成支付二维码。
      parameters:
        - $ref: '#/components/parameters/X-GatePay-Certificate-ClientId'
        - $ref: '#/components/parameters/X-GatePay-Signature'
        - $ref: '#/components/parameters/X-GatePay-Timestamp'
        - $ref: '#/components/parameters/X-GatePay-Nonce'
      requestBody:
        description: 支付订单创建参数
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PayOrderRequest'
            examples:
              basicExample:
                summary: 基础示例
                value:
                  merchantTradeNo: '22212345678555'
                  env:
                    terminalType: APP
                  currency: GT
                  orderAmount: '1.21'
                  goods:
                    goodsName: NF2T
                    goodsDetail: '123444'
                  returnUrl: http://47.99.158.63:8205/payment/redirect
                  channelId: '123456'
        required: true
      responses:
        '200':
          description: 支付订单创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PayOrderResponse'
              examples:
                successResponse:
                  summary: 成功响应
                  value:
                    code: SUCCESS
                    message: 订单创建成功
                    data:
                      prepayId: GATE202400001
                      terminalType: APP
                      expireTime: 1672909255498
components:
  parameters:
    X-GatePay-Certificate-ClientId:
      name: X-GatePay-Certificate-ClientId
      in: header
      required: true
      description: 商户客户端ID，在 GatePay 平台申请获得
      schema:
        type: string
        example: 4186d0c6-6a35-55a9-8dc6-5312769dbff8
    X-GatePay-Signature:
      name: X-GatePay-Signature
      in: header
      required: true
      description: HMAC-SHA256签名，用于验证请求合法性
      schema:
        type: string
        example: >-
          672d5650dcc9bb22ebf25fa16c28d03c0e159d742a9176d4340a5da326d75dc8a2ec24c97fa6fc5d1533dd6e968863747e1d86a45e562cbe899f9ed7e9ca7f77
    X-GatePay-Timestamp:
      name: X-GatePay-Timestamp
      in: header
      required: true
      description: 时间戳（毫秒），与服务器时间差不能超过5分钟
      schema:
        type: string
        example: '1672905655498'
    X-GatePay-Nonce:
      name: X-GatePay-Nonce
      in: header
      required: true
      description: 随机数，用于防止重放攻击
      schema:
        type: string
        example: '9578'
  schemas:
    PayOrderRequest:
      type: object
      required:
        - merchantTradeNo
        - currency
        - orderAmount
        - env
        - goods
      properties:
        merchantTradeNo:
          type: string
          description: 商户订单号，必须唯一
          minLength: 5
          maxLength: 32
          example: '22212345678555'
        env:
          $ref: '#/components/schemas/Env'
        currency:
          type: string
          description: 订单币种。请参考上方“支持的网络币种”确认当前可用范围。
          example: GT
        orderAmount:
          type: string
          description: 订单金额，必须为正数，支持小数
          pattern: ^\d+(\.\d{1,2})?$
          example: '1.21'
        goods:
          $ref: '#/components/schemas/Goods'
        orderExpireTime:
          type: integer
          description: 订单过期时间，UTC时间戳，millisecond。不设置时默认为1小时，最大过期时间为1小时
          format: int64
          example: 1770789143000
        returnUrl:
          type: string
          description: 订单支付成功后返回跳转地址，最长256字符。仅在独立页面支付完成后会跳转到该Url
          format: uri
          maxLength: 512
          example: http://47.99.158.63:8205/payment/redirect
        cancelUrl:
          type: string
          description: 订单支付取消后返回跳转地址
          format: uri
          maxLength: 512
          example: http://47.99.158.63:8205/payment/redirect
        channelId:
          type: string
          description: 客户渠道名称
          maxLength: 32
          example: '123456'
        fiatCurrency:
          type: string
          description: 法币币种
        fiatAmount:
          type: string
          description: 法币金额
        surchargeAmount:
          type: string
          description: 用户承担的手续费金额
        payCurrency:
          type: string
          description: 支付币种
        payAmount:
          type: string
          description: 支付金额
        chain:
          type: string
          description: 链网络
        address:
          type: string
          description: 链地址
        sourceType:
          type: string
          description: 订单来源类型
        payTypes:
          type: array
          description: 支持的支付方式列表
          items:
            type: string
    PayOrderResponse:
      type: object
      properties:
        code:
          type: string
          description: 响应码
          enum:
            - SUCCESS
            - ERROR
          example: SUCCESS
        message:
          type: string
          description: 响应消息
          example: 订单创建成功
        data:
          $ref: '#/components/schemas/PayOrderData'
    Env:
      type: object
      required:
        - terminalType
      properties:
        terminalType:
          type: string
          description: 终端类型
          enum:
            - WEB
            - APP
            - MINIAPP
            - WAP
            - OTHERS
          example: APP
        scene:
          type: string
          description: 支付场景
          example: CHECKOUT
    Goods:
      type: object
      required:
        - goodsName
      properties:
        goodsName:
          type: string
          description: 商品名称
          maxLength: 100
          example: NF2T
        goodsDetail:
          type: string
          description: 商品详情描述
          maxLength: 500
          example: '123444'
    PayOrderData:
      type: object
      properties:
        prepayId:
          type: string
          description: 预支付订单ID
          example: GATE202400001
        terminalType:
          type: string
          description: 终端类型
          example: APP
        expireTime:
          type: integer
          format: int64
          description: 订单过期时间戳（毫秒）
          example: 1672909255498

````