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

# 设置退款账户

> 将已验证的收款人指定为商户的退款账户。当订单被撤销时，VelaFi 会自动将资金发送到此账户。

当法币兑加密货币订单或全球支付订单被撤销或退款时，VelaFi 需要知道将资金发送到哪里。使用此端点可将任何先前已验证的收款人指定为某个商户的退款账户。每个商户同一时间只能有一个有效的退款账户——使用不同的 `userPaymentId` 再次调用此端点将替换之前的指定。

## 端点

```
POST https://api.velafi.com/v2/payments/refund_account
```

> [!NOTE]
>
> 沙盒环境测试请使用 `https://api-test.velafi.com/v2/payments/refund_account`。

## 请求头

| 请求头 | 值 |
| - | - |
| `X-BH-TOKEN` | 通过 `GET /v2/token/generate` 获取的令牌 |
| `Content-Type` | `application/json` |

## 请求体参数

**userPaymentId** `integer` *required*

要指定为退款账户的收款人的唯一数字 ID。该收款人必须为 `status: 1`（有效）。

**merchantId** `integer` *required*

要为其设置退款账户的商户的数字 ID。

## 响应字段

**code** `integer`

响应状态码。`200` 表示成功。

**msg** `string`

人类可读的响应消息。

**data** `boolean`

如果成功指定退款账户，则为 `true`。

## 示例

```bash theme={null}
curl -X POST "https://api.velafi.com/v2/payments/refund_account" \
  -H "X-BH-TOKEN: YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "merchantId": 456,
    "userPaymentId": 123
  }'
```

```json theme={null}
{
  "code": 200,
  "msg": "SUCCESS",
  "data": true
}
```

> [!TIP]
>
> 设置退款账户后，对应收款人的 `hasRefundAccount` 字段在 `GET /v2/payments` 响应中将返回 `1`。


## Related topics

- [管理收款人](https://docs.velafi.com/cn/docs/guides/managing-beneficiaries.md)
- [Webhook 设置](https://docs.velafi.com/cn/api-reference/webhooks/webhook-setup.md)
- [入金（法币兑加密货币）](https://docs.velafi.com/cn/docs/guides/on-ramp.md)
- [获取资金记录](https://docs.velafi.com/cn/api-reference/merchant/retrieve-funding-records.md)
- [添加收款人](https://docs.velafi.com/cn/api-reference/beneficiary/add-beneficiary.md)


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