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

# API overview

> Base path, authentication, pagination, error format, and endpoint groups for the better-auth-razorpay plugin.

All plugin endpoints live under the Better Auth base path, for example `/api/auth/*`. The exact prefix depends on how you mount the Better Auth handler in your application. If you mount at `/api/auth`, a Razorpay endpoint such as `POST /razorpay/create-order` is available at `POST /api/auth/razorpay/create-order`.

## Authentication

By default, every endpoint requires a valid Better Auth session cookie. The plugin sets `requireSession: true` unless you override it in the plugin options. When `requireSession` is `false`, the one-time payment and transfer endpoints do not enforce a session.

**cookie** `string`

The standard Better Auth session cookie. Sent automatically by the browser or included as a header in server-to-server calls.

## Calling conventions

### Client

Use the Better Auth client with the Razorpay client plugin. Endpoint paths are converted to camelCase methods on `authClient.razorpay` and `authClient.subscription`.

```ts theme={null}
const { data, error } = await authClient.razorpay.createOrder({
  amount: 50000,
  currency: "INR",
});
```

* `POST` calls pass the body object directly.
* `GET` calls pass `{ query: { ... } }`.
* Responses follow the Better Auth convention: `{ data, error }`.

### Server

Call endpoints directly from server code using `auth.api.<name>`:

```ts theme={null}
// POST endpoint
await auth.api.createRazorpayOrder({
  body: { amount: 50000, currency: "INR" },
  headers: await headers(), // pass request headers for session
});

// GET endpoint
await auth.api.getRazorpayOrder({
  query: { id: "order_XXXX" },
  headers: await headers(),
});
```

## Pagination

List endpoints support a common pagination shape:

**from** `integer`

Unix timestamp. Return items created after this time.

**to** `integer`

Unix timestamp. Return items created before this time.

**count** `integer`

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

**skip** `integer`

Number of items to skip.

## Error format

Errors are returned as Better Auth API errors. The client receives an object with `code` and `message`.

```json theme={null}
{
  "code": "INVALID_ORDER_AMOUNT",
  "message": "Invalid order amount"
}
```

Status codes map to Better Auth conventions: `BAD_REQUEST`, `NOT_FOUND`, `INTERNAL_SERVER_ERROR`, `FORBIDDEN`, `UNAUTHORIZED`. See [Error codes](https://better-auth-razorpay.amankushwaha.dev/reference/error-codes.md) for the full list.

## Endpoint groups

> [card] [Orders](https://better-auth-razorpay.amankushwaha.dev/api-reference/orders.md)
>
> Create, retrieve, edit, and list Razorpay orders. Verify payments against an order.

> [card] [Payments](https://better-auth-razorpay.amankushwaha.dev/api-reference/payments.md)
>
> Retrieve, list, edit, and capture Razorpay payments.

> [card] [Refunds](https://better-auth-razorpay.amankushwaha.dev/api-reference/refunds.md)
>
> Refund payments and manage refund records.

> [card] [Transfers](https://better-auth-razorpay.amankushwaha.dev/api-reference/transfers.md)
>
> Create and manage Razorpay Route transfers between linked accounts.

> [card] [Subscriptions](https://better-auth-razorpay.amankushwaha.dev/api-reference/subscriptions.md)
>
> Upgrade, cancel, pause, resume, and restore plugin-managed subscriptions.

> [card] [Razorpay subscriptions](https://better-auth-razorpay.amankushwaha.dev/api-reference/razorpay-subscriptions.md)
>
> Direct Razorpay subscription APIs: links, add-ons, offers, invoices, and pending updates.

> [card] [Plans](https://better-auth-razorpay.amankushwaha.dev/api-reference/plans.md)
>
> Create and retrieve Razorpay billing plans.

> [card] [Invoices](https://better-auth-razorpay.amankushwaha.dev/api-reference/invoices.md)
>
> Create, issue, edit, cancel, notify, and list Razorpay invoices.

> [card] [Customers](https://better-auth-razorpay.amankushwaha.dev/api-reference/customers.md)
>
> Create, edit, and list Razorpay customers. Manage bank accounts and tokens.

> [card] [Items](https://better-auth-razorpay.amankushwaha.dev/api-reference/items.md)
>
> Create, edit, delete, and list Razorpay catalog items.

> [card] [Add-ons](https://better-auth-razorpay.amankushwaha.dev/api-reference/addons.md)
>
> Retrieve, list, and delete Razorpay subscription add-ons.

> [card] [Webhook](https://better-auth-razorpay.amankushwaha.dev/api-reference/webhook.md)
>
> Receive and verify Razorpay webhook events.

## Subscription-only endpoints

Several endpoints are registered only when `subscription.enabled: true` in the plugin options:

* Subscription lifecycle: `upgrade`, `cancel`, `pause`, `resume`, `update`, `restore`
* Subscription queries: `list`, `get`
* Razorpay subscription list: `fetchAllSubscriptions`

If you call these while subscriptions are disabled, the endpoint does not exist and returns `404`.


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