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

# 订单状态查询

> 查询预付单或商户订单的支付状态。

## 概述

本页说明 `POST /payment/open/institution/v1/pay/order/query` 接口。完整的请求参数、响应结构与示例由上方关联的 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/call-payment-openapi.json POST /payment/open/institution/v1/pay/order/query
openapi: 3.1.0
info:
  title: GatePay 机构调起支付 API
  description: >-
    适用于商户在移动端APP中集成Gate Pay支付功能


    商户APP调用Gate Pay提供的SDK调用Gate Pay支付模块，商户APP会跳转到 Gate
    APP中完成支付，支付完后跳回到商户APP内，最后展示支付结果。


    目前支持手机系统有：IOS（苹果）、Android（安卓）。


    交互细节如下：


    步骤1：用户进入商户APP，选择商品下单、确认购买，进入支付环节。商户服务后台生成支付订单，签名后将数据传输到APP端。


    步骤2：用户点击后发起支付操作，进入到Gate 界面，调起Gate Pay支付，出现确认支付界面。


    步骤3：用户确认收款方和金额，点击立即支付后出现输入密码界面。


    步骤4：输入正确密码后，支付完成，现支付结果页面。


    步骤5：回跳到商户APP中，商户APP根据支付结果个性化展示订单处理结果
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://openplatform.gateapi.io
security: []
paths:
  /payment/open/institution/v1/pay/order/query:
    post:
      summary: 订单状态查询
      description: 查询预付单或商户订单的支付状态。
      operationId: queryOrder
      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/OrderQueryRequest'
            example:
              prepayId: '56416503889661952'
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/QueryOrderReturnType'
              example:
                status: SUCCESS
                code: '000000'
                errorMessage: ''
                data:
                  prepayId: '56335302571069440'
                  merchantId: 10002
                  merchantTradeNo: '118223456798'
                  transactionId: ''
                  goodsName: NF2T
                  currency: USDT
                  orderAmount: '1.9'
                  surchargeAmount: '0'
                  fiatCurrency: ''
                  fiatAmount: ''
                  fiatRate: ''
                  status: EXPIRED
                  createTime: 1675392982792
                  expireTime: 1675396480000
                  transactTime: 0
                  order_name: MiniApp-Payment#118223456798
                  pay_currency: ''
                  pay_amount: '0'
                  expectCurrency: BTC
                  channelId: ''
                  rate: '0'
                  totalFeeAmount: '0'
                  totalSettleAmount: ''
                  payDetails: []
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: 随机 nonce，用于防止重放攻击
      schema:
        type: string
        example: '9578'
    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:
    OrderQueryRequest:
      type: object
      properties:
        prepayId:
          type: string
          description: 预付单ID
        merchantTradeNo:
          type: string
          description: 商户订单id。预付单id与此id提供一个即可
    ApiResponse:
      type: object
      properties:
        status:
          type: string
          description: 请求状态
        code:
          type: string
          description: 响应码
        errorMessage:
          type: string
          description: 错误信息
    QueryOrderReturnType:
      type: object
      required:
        - prepayId
        - merchantId
        - merchantTradeNo
        - transactionId
        - goodsName
        - currency
        - orderAmount
        - status
        - createTime
        - expireTime
        - transactTime
        - order_name
        - pay_currency
        - pay_amount
        - rate
      properties:
        prepayId:
          type: string
          description: 预付单ID
        merchantId:
          type: integer
          format: int64
          description: 用于申请商户账号的Gate UID
        merchantTradeNo:
          type: string
          description: 商户订单号
        transactionId:
          type: string
          description: 交易ID
        goodsName:
          type: string
          description: 商品名称
        currency:
          type: string
          description: 订单币种
        orderAmount:
          type: string
          description: 订单金额
        surchargeAmount:
          type: string
          description: 附加费
        fiatCurrency:
          type: string
          description: 法币订单币种
        fiatAmount:
          type: string
          description: 法币订单金额
        fiatRate:
          type: string
          description: 法币-加密货币汇率
        status:
          type: string
          description: 订单状态
          enum:
            - PENDING
            - PROCESS
            - PAID
            - EXPIRED
            - CANCELLED
            - ERROR
        createTime:
          type: integer
          format: int64
          description: 预付单创建时间（毫秒）
        expireTime:
          type: integer
          format: int64
          description: 预付单过期时间（毫秒）
        transactTime:
          type: integer
          format: int64
          description: 支付完成时间（毫秒）
        order_name:
          type: string
          description: 订单名称
        pay_currency:
          type: string
          description: 用户实际支付币种
        pay_amount:
          type: string
          description: 用户实际支付金额
        expectCurrency:
          type: string
          description: 商户指定营收币种
        actualCurrency:
          type: string
          description: 实际结算币种
        actualAmount:
          type: string
          description: 实际结算金额
        rate:
          type: string
          description: 闪兑支付汇率
        channelId:
          type: string
          description: 客户名称
        totalFeeAmount:
          type: string
          description: 累计已收取的手续费。若支付流水未结算、未支付或仅为中心化支付等场景，可能为空或为 0
        institutionFeeAmount:
          type: string
          description: 累计已收取的收益分成。若支付流水未结算、未支付或仅为中心化支付等场景，可能为空或为 0。
        totalSettleAmount:
          type: string
          description: 累计已结算金额。若支付流水未结算等场景，可能为空
        payDetails:
          type: array
          description: 支付信息
          items:
            $ref: '#/components/schemas/OrderQueryPayDetail'
    OrderQueryPayDetail:
      type: object
      description: 支付流水中单笔支付的手续费与结算信息（payDetail）。
      properties:
        transactionId:
          type: string
          description: 支付流水号
        payType:
          type: string
          description: 支付类型：`GatePay` Gate 支付，`Web3Pay` Web3 支付
        payTime:
          type: string
          description: 支付时间
        payAmount:
          type: string
          description: 支付金额
        payCurrency:
          type: string
          description: 支付币种
        feeAmount:
          type: string
          description: 手续费
        institutionFeeAmount:
          type: string
          description: 收益分成。
        settleAmount:
          type: string
          description: 结算金额
        settlementStatus:
          type: string
          description: 结算状态：`pending` 未结算，`done` 已结算

````