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

# 主动发起扣款

> 商户主动对订阅单发起扣款；`subscriptionOrderNo` 与 `merchantSubscriptionOrderNo` 须二选一传入。`merchantDeductNo` 在商户侧全局唯一，用于幂等。

## 概述

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

## 说明

* 鉴权使用 GatePay 标准签名请求头。
* 本页为商户开放平台路径说明。
* 签名与验签规则见 [/api-reference/version/100/cn/common/securityAndSignature](/api-reference/version/100/cn/common/securityAndSignature)。


## OpenAPI

````yaml api-reference/version/100/cn/openapi/subscription/orderDeduct-openapi.json POST /open/v1/order/deduct
openapi: 3.1.0
info:
  title: GatePay 订阅 API
  description: GatePay 支付平台 API 接口文档
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://openplatform.gateapi.io/pay-subscription
security: []
paths:
  /open/v1/order/deduct:
    post:
      summary: 主动发起扣款
      description: >-
        商户主动对订阅单发起扣款；`subscriptionOrderNo` 与 `merchantSubscriptionOrderNo`
        须二选一传入。`merchantDeductNo` 在商户侧全局唯一，用于幂等。
      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/MerchantDeductRequest'
            examples:
              basicExample:
                summary: 基础示例
                value:
                  subscriptionOrderNo: '70778338049917032'
                  merchantDeductNo: DEDUCT_20260420_001
                  amount: 10.5
                  currency: USDT
                  description: 周期扣款
        required: true
      responses:
        '200':
          description: 请求已受理（具体是否扣款成功见 `data.status`）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderDeductApiResponse'
              examples:
                successResponse:
                  summary: 成功响应
                  value:
                    code: '0'
                    message: ''
                    data:
                      deductOrderNo: '70778338049917033'
                      merchantDeductNo: DEDUCT_20260420_001
                      status: SUCCESS
                      amount: '10.50000000'
                      currency: USDT
                      totalDeducted: '10.50000000'
                      remainingAmount: '89.50000000'
                      deductTime: 1773989575000
                    success: true
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:
    MerchantDeductRequest:
      type: object
      required:
        - merchantDeductNo
        - amount
        - currency
      properties:
        subscriptionOrderNo:
          type: string
          description: 平台订阅订单编号（与 `merchantSubscriptionOrderNo` 二选一必填）
        merchantSubscriptionOrderNo:
          type: string
          description: 商户订阅订单编号（与 `subscriptionOrderNo` 二选一必填）
        merchantDeductNo:
          type: string
          description: 商户扣款编号，全局唯一，用于幂等控制
        amount:
          type: number
          description: 扣款金额，须大于 0，且须与订阅单约定一致
        currency:
          type: string
          description: 扣款币种，须与订阅单一致
        description:
          type: string
          maxLength: 100
          description: 扣款说明，展示给用户，最多 100 字符
    OrderDeductApiResponse:
      type: object
      properties:
        code:
          type: string
          description: 响应码，0 表示成功
          example: '0'
        message:
          type: string
          description: 响应描述，成功时为空
          example: ''
        success:
          type: boolean
          description: 请求是否成功
          example: true
        data:
          $ref: '#/components/schemas/MerchantDeductResult'
    MerchantDeductResult:
      type: object
      description: 扣款结果数据
      properties:
        deductOrderNo:
          type: string
          description: 平台扣款单号
        merchantDeductNo:
          type: string
          description: 商户扣款编号
        status:
          type: string
          description: 扣款状态：`SUCCESS` 成功，`PROCESSING` 处理中，`FAILED` 失败
        amount:
          type: string
          description: 本次扣款金额
        currency:
          type: string
          description: 币种
        totalDeducted:
          type: string
          description: 累计已扣款总金额（含本次）
        remainingAmount:
          type: string
          description: 剩余可扣额度；无额度限制时可能不返回
        deductTime:
          type: integer
          format: int64
          description: 扣款时间（毫秒时间戳）

````