> ## Documentation Index
> Fetch the complete documentation index at: https://opendocs.xft.xin/llms.txt
> Use this file to discover all available pages before exploring further.

# 退款接口

## 功能说明

支持对已支付的订单发起退款。商户退款单号必须唯一，退款结果以同步响应和退款查询接口为准。退款支持单笔交易分多次退款，多次退款需要提交原支付订单的商户订单号和不同的商户退款请求号，总退款金额不能超过用户实际支付金额。 一笔退款失败后重新提交，请不要更换商户退款单号，请使用相同的商户退款单号请求退款。由于渠道对于退款有效期的限制，建议支付完成1年内操作退款。

## 请求地址

`POST /v1/aggregate/payment/charge/refund`

## 请求参数

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `out_trade_no` | string | 是 | 商户流水号（原支付订单的商户流水号） |
| `refund_trade_no` | string | 是 | 商户退款单号，必须唯一 |
| `merchant_code` | string | 是 | 商户编码 |
| `refund_amount` | object | 是 | 退款金额，单位：分，详见下方 Amount 说明 |
| `refund_reason` | string | 否 | 退款原因 |
| `staff_code` | string | 否 | 收银员工号 |

**Amount 对象（refund\_amount）**

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `total` | int | 是 | 订单总金额，单位：分 |
| `payer_total` | int | 否 | 用户支付金额，单位：分（使用优惠券的情况下，等于总金额减优惠券金额） |
| `currency` | string | 否 | 订单金额货币类型；`CNY`：人民币，境内商户号仅支持人民币 |
| `payer_currency` | string | 否 | 用户支付货币类型 |

## 请求示例

```json theme={"system"}
{
  "out_trade_no": "ea51203e1a0146d7954b39ac88aecaf7",
  "refund_trade_no": "R20231025152300001",
  "merchant_code": "226801000000865319122",
  "refund_amount": {
    "total": 100,
    "currency": "CNY"
  },
  "refund_reason": "用户申请退款",
  "staff_code": "S001"
}
```

## 响应参数

| 字段 | 类型 | 说明 |
| - | - | - |
| `trade_state` | string | 退款状态，详见 [TradeState 枚举](https://opendocs.xft.xin/open/payment/aggregate-payment-v1/get-charge.md#tradestate) |
| `trade_state_desc` | string | 退款状态描述 |
| `failure_code` | string | 失败码 |
| `failure_msg` | string | 失败信息 |
| `trade_no` | string | 渠道退款流水号 |
| `platform_trade_no` | string | 平台退款流水号 |
| `amount` | object | 退款金额，结构同请求参数 Amount |
| `succeeded_at` | string | 退款成功时间，格式：`yyyyMMddHHmmss`；示例值：`20220912111230` |

## 响应示例

```json theme={"system"}
{
  "trade_state": "00",
  "trade_state_desc": "成功",
  "failure_code": "",
  "failure_msg": "",
  "trade_no": "50300807092023102512345678901",
  "platform_trade_no": "20231025152300000002",
  "amount": {
    "total": 100,
    "payer_total": 100,
    "currency": "CNY",
    "payer_currency": "CNY"
  },
  "succeeded_at": "20231025152300"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.