> ## 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.

# 创建预付单

> 创建 Web 支付预付单，返回预付单 ID 以及 Web 支付组件跳转地址等信息。

## 概述

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

## 说明

* 认证方式使用 GatePay 标准签名请求头。
* 本页展示同一接口的机构路径版本。
* 除创建子账户、查询子账户详情、分页查询子账户外，机构侧请求需携带 `X-GatePay-On-Behalf-Of`。
* 通用签名规则请参见 [/api-reference/version/100/cn/common/securityAndSignature](/api-reference/version/100/cn/common/securityAndSignature)。


## OpenAPI

````yaml api-reference/version/100/cn/openapi/institution/web-payment-openapi.json POST /payment/open/institution/v1/pay/transactions/native
openapi: 3.1.0
info:
  title: GatePay Web 支付 API
  version: 1.0.0
  description: 基于原 Web Payment 文档整理的 OpenAPI 3.1 规范。涵盖 Web 预付单创建、关闭、查询以及退款相关接口。
servers:
  - url: https://openplatform.gateapi.io
    description: 生产环境
security: []
tags:
  - name: web-payment
    description: Web 支付相关接口，包括预付单创建、关闭、查询以及退款等。
paths:
  /payment/open/institution/v1/pay/transactions/native:
    post:
      tags:
        - web-payment
      summary: 创建预付单
      description: 创建 Web 支付预付单，返回预付单 ID 以及 Web 支付组件跳转地址等信息。
      operationId: createPrepayOrder
      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'
        - $ref: '#/components/parameters/X-GatePay-On-Behalf-Of'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePrepayRequest'
            examples:
              default:
                summary: 商户实际收入币种与订单币种一致
                value:
                  merchantTradeNo: '118223456797'
                  currency: USDT
                  orderAmount: '1.9'
                  env:
                    terminalType: APP
                  goods:
                    goodsName: NF2T
                    goodsDetail: nef-book
                  orderExpireTime: 1660204248000
                  returnUrl: http://example.com/payment/callback
                  channelId: '123456'
      responses:
        '200':
          description: 创建预付单成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePrepayResponse'
              examples:
                success:
                  summary: 成功响应示例
                  value:
                    status: SUCCESS
                    code: '0'
                    errorMessage: ''
                    data:
                      prepayId: '50913213697495040'
                      terminalType: APP
                      expireTime: 1674100394000
                      qrContent: >-
                        http://openplatform.gate.io/qr/AjQHJ56mDQ26dtx5ftspl9usV9tlIA8iom35toXhX7Y=
                      location: >-
                        https://114.55.238.130:13555/webpay?prepayid=50913213697495040
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: '3525756760'
    X-GatePay-On-Behalf-Of:
      name: X-GatePay-On-Behalf-Of
      in: header
      required: true
      schema:
        type: string
      description: >-
        必填代理归属请求头。请填写本次请求的发起方账户 ID；在机构代理商户 API 中通常填写目标子账户 ID，在机构代扣与划转接口中可填写机构账户
        ID 或子账户 ID。
  schemas:
    CreatePrepayRequest:
      type: object
      description: 创建预付单请求参数。
      properties:
        merchantTradeNo:
          type: string
          description: 商户订单号，不大于32字节。
        currency:
          type: string
          description: 加密货币币种，大写形式，如 USDT、BTC。
        orderAmount:
          type: string
          description: 加密货币订单金额，范围 [0.0001, 500000]。
        fiatCurrency:
          type: string
          description: 法币币种，大写形式，如 EUR、GBP、USD、CNY、JPY、AUD、CAD、CHF 等。
        fiatAmount:
          type: string
          description: 法币订单金额，最小值 0.01，最高精度 2 位小数。
        actualCurrency:
          type: string
          description: 商户实际要求入账的币种，如果商户要求入账币种与订单币种不一致，可使用此字段指定实际收入币种。
        env:
          $ref: '#/components/schemas/Env'
        goods:
          $ref: '#/components/schemas/Goods'
        orderExpireTime:
          type: integer
          format: int64
          description: 订单过期时间，UTC 毫秒时间戳。不设置时默认 1 小时，最大为 1 小时。
        returnUrl:
          type: string
          description: 订单支付成功后返回跳转地址，最长 256 字符。
        cancelUrl:
          type: string
          description: 订单支付失败后返回跳转地址，最长 256 字符。
        channelId:
          type: string
          description: 客户名称。
      required:
        - merchantTradeNo
        - env
        - goods
    CreatePrepayResponse:
      type: object
      description: 创建预付单响应。
      properties:
        status:
          type: string
          description: SUCCESS 或 FAIL。
        code:
          type: string
          description: 错误码。
        errorMessage:
          type: string
          description: 错误信息。
        data:
          type: object
          description: 预付单数据。
          properties:
            prepayId:
              type: string
              description: 预付单 ID。
            terminalType:
              type: string
              description: 交易来源，可选值：APP、WEB、WAP、MINIAPP、OTHERS。
            expireTime:
              type: integer
              format: int64
              description: 订单过期时间，毫秒时间戳。不设置时默认为1小时，最大过期时间为1小时
            qrContent:
              type: string
              description: 订单二维码以链接的格式返回，开发者需要自己使用工具根据内容生成二维码图片。
            location:
              type: string
              description: 创建订单后，Web 支付组件跳转地址。
          required:
            - prepayId
            - terminalType
            - expireTime
            - qrContent
            - location
      required:
        - status
        - code
    Env:
      type: object
      description: 交易来源信息。
      properties:
        terminalType:
          type: string
          description: 交易来源，可选值：APP、WEB、WAP、MINIAPP、OTHERS。
      required:
        - terminalType
    Goods:
      type: object
      description: 商品信息。
      properties:
        goodsName:
          type: string
          description: 商品名称，最长 160 字符。
        goodsDetail:
          type: string
          description: 商品描述，最长 256 字符。
      required:
        - goodsName

````