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

# 试算商户手续费

> 本接口用于根据商户信息、订单金额等参数，试算该笔交易的手续费金额。仅限Gate Pay商户调用。

## 概述

本页说明 `POST /payment/open/institution/payClearing/clearing/previewMerchantFee` 接口。完整的请求参数、响应结构与示例由上方关联的 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/preview-merchant-fee-openapi.json POST /payment/open/institution/payClearing/clearing/previewMerchantFee
openapi: 3.1.0
info:
  title: GatePay 机构商户手续费 API
  description: GatePay 支付平台 API 接口文档 - 试算商户手续费
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://openplatform.gateapi.io
security: []
paths:
  /payment/open/institution/payClearing/clearing/previewMerchantFee:
    post:
      summary: 试算商户手续费
      description: 本接口用于根据商户信息、订单金额等参数，试算该笔交易的手续费金额。仅限Gate Pay商户调用。
      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: 试算商户手续费请求参数
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewMerchantFeeRequest'
            examples:
              basicExample:
                summary: 基础示例
                value:
                  orderCurrency: USDT
                  accessMode: 0
                  scenario: 0
                  orderAmount: '100.00'
        required: true
      responses:
        '200':
          description: 试算成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreviewMerchantFeeResponse'
              examples:
                successResponse:
                  summary: 成功响应
                  value:
                    status: success
                    code: '000000'
                    errorMessage: ''
                    data:
                      merchantId: '123456789'
                      merchantType: 1
                      accessMode: 0
                      orderCurrency: USDT
                      orderAmount: 100
                      orderFee: 2.5
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidParams:
                  summary: 无效请求参数
                  value:
                    status: error
                    code: '400001'
                    errorMessage: 无效请求参数
                    data: null
                invalidSignature:
                  summary: 无效签名
                  value:
                    status: error
                    code: '400002'
                    errorMessage: 无效签名
                    data: null
                invalidApiKey:
                  summary: API身份秘钥不存在或无效
                  value:
                    status: error
                    code: '400004'
                    errorMessage: API身份秘钥不存在或无效
                    data: null
                invalidClientId:
                  summary: 客户端 ID 无效
                  value:
                    status: error
                    code: '400005'
                    errorMessage: INVALID_CLIENT_ID/clientid错误
                    data: null
                unsupportedMediaType:
                  summary: 不支持的media type
                  value:
                    status: error
                    code: '400007'
                    errorMessage: 不支持的media type
                    data: null
        '500':
          description: 服务端错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                feeServiceError:
                  summary: 调用费率服务试算接口失败
                  value:
                    status: error
                    code: '503011007'
                    errorMessage: 调用费率服务试算接口失败
                    data: null
                feeConfigEmpty:
                  summary: 商户费率配置为空
                  value:
                    status: error
                    code: '503011008'
                    errorMessage: 商户费率配置为空
                    data: null
                unknownError:
                  summary: 未知错误
                  value:
                    status: error
                    code: '503010999'
                    errorMessage: 未知错误
                    data: null
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: >-
          601d560c54d53412aca5901256f101e7078b5779f61f30bedfe9a5f0b92f049589952a151ea477371e4a99ac0e1c3cc8dec62654b3c6a1794ef981efe19232bc
    X-GatePay-Timestamp:
      name: X-GatePay-Timestamp
      in: header
      required: true
      description: 时间戳（毫秒）
      schema:
        type: string
        example: '1726027137585'
    X-GatePay-Nonce:
      name: X-GatePay-Nonce
      in: header
      required: true
      description: 随机数
      schema:
        type: string
        example: '2290830087'
    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:
    PreviewMerchantFeeRequest:
      type: object
      required:
        - orderCurrency
        - accessMode
        - scenario
        - orderAmount
      properties:
        orderCurrency:
          type: string
          description: 订单币种，如：USDT、USDC等
          example: USDT
        accessMode:
          type: integer
          description: 接入模式：0=中心化支付，1=Web3支付
          enum:
            - 0
            - 1
          example: 0
        scenario:
          type: integer
          description: 交易类型（场景）：0=收款
          enum:
            - 0
          example: 0
        orderAmount:
          type: string
          format: decimal
          description: 订单金额，必须大于等于0
          example: '100.00'
    PreviewMerchantFeeResponse:
      type: object
      properties:
        status:
          type: string
          description: 响应状态：success/error
          enum:
            - success
            - error
          example: success
        code:
          type: string
          description: 响应码，000000表示成功
          example: '000000'
        errorMessage:
          type: string
          description: 错误信息，成功时为空
          example: ''
        data:
          $ref: '#/components/schemas/PreviewMerchantFeeData'
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          description: 响应状态
          enum:
            - error
          example: error
        code:
          type: string
          description: 错误码
          example: '400001'
        errorMessage:
          type: string
          description: 错误信息
          example: 无效请求参数
        data:
          type: 'null'
          description: 错误时为空
    PreviewMerchantFeeData:
      type: object
      properties:
        merchantId:
          type: string
          description: 商户ID
          example: '123456789'
        merchantType:
          type: integer
          description: 商户类型：0=普通商户，1=代理商
          enum:
            - 0
            - 1
          example: 1
        accessMode:
          type: integer
          description: 接入模式：0=中心化支付，1=Web3支付
          enum:
            - 0
            - 1
          example: 0
        orderCurrency:
          type: string
          description: 订单币种
          example: USDT
        orderAmount:
          type: number
          format: decimal
          description: 订单金额
          example: 100
        orderFee:
          type: number
          format: decimal
          description: 计算出的手续费
          example: 2.5

````