> ## Documentation Index
> Fetch the complete documentation index at: https://better-auth-razorpay.amankushwaha.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Refunds

> Refund payments and manage refund records through the plugin endpoints.

The refunds endpoints let you refund captured payments, retrieve individual refunds, list historical refunds, and update refund notes.

## Refund payment

`POST /api/auth/razorpay/payment/refund`

Refunds a captured Razorpay payment. You can refund the full amount or a partial amount.

**Server API name:** `refundRazorpayPayment`\
**Client method:** `authClient.razorpay.payment.refund(...)`

**paymentId** `string` *required*

Razorpay payment id to refund.

**amount** `integer`

Amount to refund in subunits. Omit to refund the full payment amount.

**speed** `string`

Refund speed. One of `normal` or `optimum`.

**receipt** `string`

Your internal receipt identifier for this refund.

**notes** `object`

Up to 15 key-value pairs. Each value must be 256 characters or fewer.

> [!NOTE]
>
> Errors: `REFUND_NOT_FOUND`, `REFUND_FETCH_FAILED`, `REFUND_EDIT_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.payment.refund({
  paymentId: "pay_XXXX",
  amount: 25000,
  speed: "normal",
  receipt: "refund_001",
  notes: { reason: "Customer request" },
});
```

```ts server.ts theme={null}
const result = await auth.api.refundRazorpayPayment({
  body: {
    paymentId: "pay_XXXX",
    amount: 25000,
    speed: "normal",
    receipt: "refund_001",
    notes: { reason: "Customer request" },
  },
  headers: await headers(),
});
```

## Get refund

`GET /api/auth/razorpay/refund/get`

Retrieves a single refund by id.

**Server API name:** `fetchRefund`\
**Client method:** `authClient.razorpay.refund.get({ query: { refundId, paymentId? } })`

**refundId** `string` *required*

Razorpay refund id, for example `rfnd_XXXX`.

**paymentId** `string`

Optional Razorpay payment id for additional context.

> [!NOTE]
>
> Errors: `REFUND_FETCH_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.refund.get({
  query: { refundId: "rfnd_XXXX" },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchRefund({
  query: { refundId: "rfnd_XXXX" },
  headers: await headers(),
});
```

## List refunds

`GET /api/auth/razorpay/refund/list`

Lists refunds with pagination.

**Server API name:** `fetchAllRefunds`\
**Client method:** `authClient.razorpay.refund.list({ query: { ... } })`

**from** `integer`

Unix timestamp. Return refunds created after this time.

**to** `integer`

Unix timestamp. Return refunds created before this time.

**count** `integer`

Maximum number of refunds to return. Maximum value is `100`.

**skip** `integer`

Number of refunds to skip.

> [!NOTE]
>
> Errors: `REFUND_LIST_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.refund.list({
  query: { count: 10, skip: 0 },
});
```

```ts server.ts theme={null}
const result = await auth.api.fetchAllRefunds({
  query: { count: 10, skip: 0 },
  headers: await headers(),
});
```

## Edit refund

`POST /api/auth/razorpay/refund/edit`

Updates the notes on an existing refund.

**Server API name:** `editRefund`\
**Client method:** `authClient.razorpay.refund.edit(...)`

**refundId** `string` *required*

Razorpay refund id to update.

**notes** `object`

New notes object. Up to 15 key-value pairs, values 256 characters or fewer.

> [!NOTE]
>
> Errors: `REFUND_EDIT_FAILED`.

```ts client.ts theme={null}
const { data, error } = await authClient.razorpay.refund.edit({
  refundId: "rfnd_XXXX",
  notes: { updated: "true" },
});
```

```ts server.ts theme={null}
const result = await auth.api.editRefund({
  body: {
    refundId: "rfnd_XXXX",
    notes: { updated: "true" },
  },
  headers: await headers(),
});
```


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