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

# 查询礼品卡

> 根据礼品卡卡号或兑换码查询礼品卡详情。当两个参数都传时优先使用 key。

## 概述

本页说明 `POST /payment/open/institution/v1/pay/gift/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/gift-card-openapi.json POST /payment/open/institution/v1/pay/gift/query
openapi: 3.1.0
info:
  title: GatePay 机构礼品卡 API
  description: Gate Pay 礼品卡 API 解决方案，用于礼品卡的即时创建和价值检查。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://openplatform.gateapi.io
security: []
paths:
  /payment/open/institution/v1/pay/gift/query:
    post:
      summary: 查询礼品卡
      description: 根据礼品卡卡号或兑换码查询礼品卡详情。当两个参数都传时优先使用 key。
      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:
        description: 查询礼品卡请求参数（card_number 和 key 二选一）
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GiftCardQueryRequest'
            examples:
              basicExample:
                summary: 按卡号查询
                value:
                  card_number: '5202710871862281'
                  key: ''
        required: true
      responses:
        '200':
          description: 查询成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GiftCardQueryResponse'
              examples:
                successResponse:
                  summary: 成功响应
                  value:
                    status: SUCCESS
                    code: '000000'
                    errorMessage: ''
                    data:
                      card_num: '6712561472330044'
                      key: r81T4rg3FKjt2+BYUgIn0CFqwtxp9CUSHGBFYDDJ608=
                      title: ''
                      creator_name: GateUser-8118f6f8
                      amount: '0.99'
                      status: 2
                      currency: USDT
                      create_time: 1737971259259
                      exchange_uid: 0
                      exchange_time: 1737971259259
components:
  parameters:
    X-GatePay-Certificate-ClientId:
      name: X-GatePay-Certificate-ClientId
      in: header
      required: true
      description: 商户客户端ID
      schema:
        type: string
        example: mZ96D37oKk-HrWJc
    X-GatePay-Signature:
      name: X-GatePay-Signature
      in: header
      required: true
      description: 签名
      schema:
        type: string
        example: >-
          b8c4705ff4c1357f2a27925dd180c1e1f4a244148f312a2dee5afbcc6f4b150e9ffceee455c5a298f895d43a64ee829eebdfd262539d45c41f7aee4336fd8c8c
    X-GatePay-Timestamp:
      name: X-GatePay-Timestamp
      in: header
      required: true
      description: 时间戳（毫秒）
      schema:
        type: string
        example: '1738934053475'
    X-GatePay-Nonce:
      name: X-GatePay-Nonce
      in: header
      required: true
      description: 随机数
      schema:
        type: string
        example: '5417061546'
    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:
    GiftCardQueryRequest:
      type: object
      properties:
        card_number:
          type: string
          description: 礼品卡卡号（与 key 二选一）
          example: '5202710871862281'
        key:
          type: string
          description: 兑换码（与 card_number 二选一，两个都传时优先使用 key）
          example: ''
    GiftCardQueryResponse:
      type: object
      properties:
        status:
          type: string
          description: 响应状态
          example: SUCCESS
        code:
          type: string
          description: 响应码
          example: '000000'
        errorMessage:
          type: string
          description: 错误信息
          example: ''
        data:
          $ref: '#/components/schemas/GiftCardQueryData'
    GiftCardQueryData:
      type: object
      properties:
        card_num:
          type: string
          description: 礼品卡卡号
          example: '6712561472330044'
        key:
          type: string
          description: 兑换码
          example: r81T4rg3FKjt2+BYUgIn0CFqwtxp9CUSHGBFYDDJ608=
        title:
          type: string
          description: 主题
          example: ''
        creator_name:
          type: string
          description: 礼品卡创建人名字
          example: GateUser-8118f6f8
        amount:
          type: string
          description: 礼品卡金额
          example: '0.99'
        status:
          type: integer
          description: 礼品卡状态：0=未知状态，1=待支付，2=未兑换，3=已兑换，4=冻结，5=支付失败，6=人工审核，7=审核驳回，8=审核支付失败
          enum:
            - 0
            - 1
            - 2
            - 3
            - 4
            - 5
            - 6
            - 7
            - 8
          example: 2
        currency:
          type: string
          description: 礼品卡币种
          example: USDT
        card_temp_id:
          type: string
          description: 礼品卡封面ID
          example: '255267012439183360'
        create_time:
          type: integer
          format: int64
          description: 创建时间（毫秒时间戳）
          example: 1737971259259
        exchange_uid:
          type: integer
          description: 兑换人
          example: 0
        exchange_time:
          type: integer
          format: int64
          description: 兑换时间（毫秒时间戳）
          example: 1737971259259

````