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

# Web 支付退款

> 商户可以针对一个已成功支付的订单发起退款。 退款执行并不需要付款商户和用户确认。退款订单创建后就会开始安排执行。退款成功后，GatePay后台会发送退款结果通知。 请注意：退款不可以取消、撤回、回滚。

## 概述

本页说明 `POST /payment/open/institution/v1/pay/order/refund` 接口。完整的请求参数、响应结构与示例由上方关联的 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/web-payment-openapi.json POST /payment/open/institution/v1/pay/order/refund
openapi: 3.1.0
info:
  title: GatePay Web 支付 API
  version: 1.0.0
  description: 基于原 Web Payment 文档整理的 OpenAPI 3.1 规范。涵盖 Web 预付单创建、关闭、查询以及退款相关接口。
servers:
  - url: https://openplatform.gateapi.io
    description: 生产环境
security: []
tags:
  - name: web-payment
    description: Web 支付相关接口，包括预付单创建、关闭、查询以及退款等。
paths:
  /payment/open/institution/v1/pay/order/refund:
    post:
      tags:
        - web-payment
      summary: 退款接口
      description: >-
        商户可以针对一个已成功支付的订单发起退款。
        退款执行并不需要付款商户和用户确认。退款订单创建后就会开始安排执行。退款成功后，GatePay后台会发送退款结果通知。
        请注意：退款不可以取消、撤回、回滚。
      operationId: createRefund
      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/CreateRefundRequest'
            examples:
              default:
                summary: 默认示例
                value:
                  refundRequestId: '156123911'
                  prepayId: '1647438500687506'
                  refundAmount: '0.8'
      responses:
        '200':
          description: 退款请求结果
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateRefundResponse'
              examples:
                success:
                  summary: 成功响应示例
                  value:
                    status: SUCCESS
                    code: '000000'
                    data:
                      refundRequestId: '156123911'
                      prepayId: '1647438500687506'
                      orderAmount: '1.91'
                      refundAmount: '0.8'
                      channelId: ''
                    errorMessage: ''
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: '3525756760'
    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:
    CreateRefundRequest:
      type: object
      description: 创建退款单请求参数。
      properties:
        refundRequestId:
          type: string
          description: 商户生成的退款单ID。退款单id必须唯一，不大于32字符。
        prepayId:
          type: string
          description: 已完成支付的订单 ID。
        refundAmount:
          type: string
          description: 退款金额，不能超过订单总金额。
        refundReason:
          type: string
          description: 退款原因，最长 256 字符。
      required:
        - refundRequestId
        - prepayId
        - refundAmount
    CreateRefundResponse:
      type: object
      description: 退款接口响应。
      properties:
        status:
          type: string
          description: SUCCESS 或者 FAIL
        code:
          type: string
          description: 出错代码
        data:
          type: object
          description: 退款单信息
          properties:
            refundRequestId:
              type: string
              description: 退款单ID，GatePay生成
            prepayId:
              type: string
              description: 预付单ID
            orderAmount:
              type: string
              description: 订单金额
            refundAmount:
              type: string
              description: 申请退款金额
        errorMessage:
          type: string
          description: 错误信息
      required:
        - status
        - code

````