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

# 发起代扣

> 发起一笔账户间代扣。`X-GatePay-On-Behalf-Of` 指定本次交易的发起方账户 ID，`accountId` 指定付款方账户 ID（被扣款账户）。当前版本为同步接口，提交后直接返回最终执行结果。

## 概述

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

## 说明

* 认证方式使用 GatePay 标准签名请求头。
* 这个机构专属接口需要携带 `X-GatePay-On-Behalf-Of`，表示本次代扣的发起方账户 ID，可填写机构账户 ID 或子账户 ID。
* 请求体中的 `accountId` 表示付款方账户 ID（被扣款账户）。
* 当前版本中，该接口会同步返回最终执行结果，不需要再依赖详情接口轮询处理中状态。
* 通用签名规则请参见 [/api-reference/version/100/cn/common/securityAndSignature](/api-reference/version/100/cn/common/securityAndSignature)。


## OpenAPI

````yaml api-reference/version/100/cn/openapi/institutional-openapi.json POST /transfer/open/institution/v1/pay/charge
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:
  /transfer/open/institution/v1/pay/charge:
    post:
      summary: 发起代扣
      description: >-
        发起一笔账户间代扣。`X-GatePay-On-Behalf-Of` 指定本次交易的发起方账户 ID，`accountId` 指定付款方账户
        ID（被扣款账户）。当前版本为同步接口，提交后直接返回最终执行结果。
      parameters:
        - $ref: '#/components/parameters/X-GatePay-Certificate-ClientId'
        - $ref: '#/components/parameters/X-GatePay-Timestamp'
        - $ref: '#/components/parameters/X-GatePay-Nonce'
        - $ref: '#/components/parameters/X-GatePay-Signature'
        - $ref: '#/components/parameters/X-GatePay-On-Behalf-Of'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChargeRequest'
            examples:
              default:
                summary: 代扣示例
                value:
                  merchantBatchNo: '1234565454511231'
                  accountId: '1979044675'
                  currency: USDT
                  amount: '1'
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransferResponseWrapper'
              examples:
                success:
                  summary: 成功响应
                  value:
                    status: SUCCESS
                    code: '000000'
                    errorMessage: ''
                    data:
                      merchantBatchNo: '1234565454511231'
                      status: PAID
                      fromAccountId: '2124267192'
                      toAccountId: '1979044675'
                      currency: USDT
                      amount: '1'
                      createTime: 1763455435851
components:
  parameters:
    X-GatePay-Certificate-ClientId:
      name: X-GatePay-Certificate-ClientId
      in: header
      required: true
      description: 商户在Gate商户后台注册应用时分配的clientId
      schema:
        type: string
        example: 4186d0c6-6a35-55a9-8dc6-5312769dbff8
    X-GatePay-Timestamp:
      name: X-GatePay-Timestamp
      in: header
      required: true
      description: 请求生成时的UTC时间戳，milliseconds。请注意，GatePay不处理收到请求时间与这个时间戳差距大于10秒钟的请求
      schema:
        type: string
        example: '1672905655498'
    X-GatePay-Nonce:
      name: X-GatePay-Nonce
      in: header
      required: true
      description: 随机字符串，字符符合HTTP Header头部的规范，建议长度在32个字符以内，字符串组成为数字和字母
      schema:
        type: string
        example: '9578'
    X-GatePay-Signature:
      name: X-GatePay-Signature
      in: header
      required: true
      description: 请求签名。GatePay通过此签名来确定此请求是否合法
      schema:
        type: string
    X-GatePay-On-Behalf-Of:
      name: X-GatePay-On-Behalf-Of
      in: header
      required: true
      schema:
        type: string
      description: 必填代理归属请求头。请填写本次交易的发起方账户 ID，可填写机构账户 ID 或子账户 ID。
  schemas:
    ChargeRequest:
      type: object
      required:
        - merchantBatchNo
        - accountId
        - currency
        - amount
      properties:
        merchantBatchNo:
          type: string
          description: 由商户侧生成的唯一批次 ID
        accountId:
          type: string
          description: 付款方账户 ID（被扣款账户）。
        currency:
          type: string
          description: 转账币种
        amount:
          type: string
          description: 转账金额
    TransferResponseWrapper:
      type: object
      properties:
        status:
          type: string
          example: SUCCESS
        code:
          type: string
          example: '000000'
        errorMessage:
          type: string
        data:
          $ref: '#/components/schemas/TransferResponse'
    TransferResponse:
      type: object
      description: 同步执行结果。提交成功后直接返回最终状态与核心结果字段。
      properties:
        merchantBatchNo:
          type: string
          description: 批次 ID，与入参 merchantBatchNo 一致
        status:
          type: string
          description: 状态：ERROR 失败；EXPIRED 过期；PAID 成功；CANCELLED 关单
        toAccountId:
          type: string
          description: 收款账户 ID
        fromAccountId:
          type: string
          description: 出款账户 ID
        createTime:
          type: integer
          format: int64
          description: 订单创建时间，毫秒
        currency:
          type: string
          description: 币种
        amount:
          type: string
          description: 划转金额

````