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

# Introduction

> Better Auth Razorpay is a plugin that adds Razorpay payments, subscriptions, and billing to your Better Auth application.

Better Auth Razorpay is a Better Auth plugin that integrates Razorpay into your application. It gives you one-time payments, refunds, Route transfers, subscriptions with trials and seat-based billing, invoices, customers, plans, items, add-ons, webhooks, and optional TanStack Query React hooks. All of this is managed through your existing Better Auth setup so you do not need a separate payments backend.

## What you get

The plugin is split into three parts: a server plugin, a client plugin, and an optional React hooks package. The server plugin registers endpoints under your Better Auth handler. The client plugin exposes typed methods on your auth client. The React hooks wrap those methods with TanStack Query for caching and loading states.

> [card] [One-time payments](https://better-auth-razorpay.amankushwaha.dev/guides/one-time-payments.md)
>
> Create orders, capture payments, and verify signatures.

> [card] [Subscriptions](https://better-auth-razorpay.amankushwaha.dev/guides/subscriptions.md)
>
> Manage recurring billing, upgrades, pauses, and cancellations.

> [card] [Organizations](https://better-auth-razorpay.amankushwaha.dev/configuration/organizations.md)
>
> Bill teams and sync seat counts with member changes.

> [card] [Webhooks](https://better-auth-razorpay.amankushwaha.dev/guides/webhooks.md)
>
> Handle Razorpay events with built-in signature verification.

> [card] [React hooks](https://better-auth-razorpay.amankushwaha.dev/react/overview.md)
>
> Query and mutate payments and subscriptions from React.

> [card] [API reference](https://better-auth-razorpay.amankushwaha.dev/api-reference/overview.md)
>
> Browse every endpoint and parameter.

## Requirements

* Better Auth `^1.7.0`
* TypeScript `^5.6.3`
* A Razorpay account with API keys
* Optional: `@tanstack/react-query ^5.104.3` and `react ^19.3.0` if you use the React hooks

## Quick teaser

Add the server plugin to your auth config:

```ts auth.ts theme={null}
import { betterAuth } from "better-auth";
import { razorpay } from "@amank-root/better-auth-razorpay";

export const auth = betterAuth({
  plugins: [
    razorpay({
      keyId: process.env.RAZORPAY_KEY_ID!,
      keySecret: process.env.RAZORPAY_KEY_SECRET!,
      subscription: {
        enabled: true,
        plans: [{ planId: "plan_XXXX", name: "pro" }],
      },
    }),
  ],
});
```

Add the client plugin:

```ts client.ts theme={null}
import { createAuthClient } from "better-auth/react";
import { razorpayClient } from "@amank-root/better-auth-razorpay/client";

export const authClient = createAuthClient({
  plugins: [razorpayClient({ subscription: true })],
});
```

Then create an order and open Razorpay Checkout:

```tsx theme={null}
const { data: order } = await authClient.razorpay.createOrder({
  amount: 50000, // INR 500 in paise
  currency: "INR",
});

const rzp = new window.Razorpay({
  key: process.env.NEXT_PUBLIC_RAZORPAY_KEY_ID!,
  order_id: order.id,
  amount: order.amount,
  currency: order.currency,
  name: "My Store",
  handler: (response) => {
    // verify payment on the server
  },
});
rzp.open();
```

See the [Quickstart](https://better-auth-razorpay.amankushwaha.dev/quickstart.md) for a complete end-to-end example, or jump to [Installation](https://better-auth-razorpay.amankushwaha.dev/installation.md) to set up your project.


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