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

# Contributing

> Local development setup, project structure, tests, build, and publishing workflow for the better-auth-razorpay plugin.

This page covers how to set up the plugin locally, run tests, build the package, and publish a release. The source repository is at [github.com/Amank-root/better-auth-razorpay](https://github.com/Amank-root/better-auth-razorpay) and is released under the MIT license.

## Prerequisites

You need a recent version of Node.js and a package manager. The project uses `bun` for development tasks, but `npm` works for publishing.

## Install dependencies

Clone the repository and install dependencies:

```bash theme={null}
git clone https://github.com/Amank-root/better-auth-razorpay.git
cd better-auth-razorpay
bun install
```

## Project structure

```text theme={null}
better-auth-razorpay/
├── src/
│   ├── index.ts          # Plugin registration and endpoint wiring
│   ├── routes.ts         # Endpoint definitions and handlers
│   ├── client.ts         # Client plugin entry
│   ├── react.ts          # React hooks entry
│   ├── types.ts          # TypeScript type definitions
│   ├── error-codes.ts    # Error code constants
│   ├── razorpay.ts       # Serializers and input mappers
│   ├── hooks.ts          # Webhook event handlers
│   ├── schema.ts         # Database schema definitions
│   ├── signature.ts      # HMAC-SHA256 signature utilities
│   ├── utils.ts          # General utilities
│   ├── version.ts        # Package version
│   ├── metadata.ts       # Metadata helpers
│   ├── notes.ts          # Notes helpers
│   └── middleware.ts     # Middleware definitions
├── test/
│   ├── error-codes.test.ts
│   ├── hooks.test.ts
│   ├── metadata.test.ts
│   ├── notes.test.ts
│   ├── plugin.test.ts        # Subscription-optional construction
│   ├── razorpay.test.ts      # Serializers and mappers
│   ├── schema.test.ts
│   ├── signature.test.ts
│   ├── utils.test.ts
│   └── webhooks-new.test.ts
├── package.json
├── tsconfig.json
└── tsup.config.ts
```

## Development commands

| Command | Purpose |
| - | - |
| `bun install` | Install dependencies |
| `bun run typecheck` | Run TypeScript type checking |
| `bun run test` | Run the test suite with Vitest |
| `npm test` | Alternative way to run tests |
| `bun run build` | Build the package with tsup (ESM + `.d.ts`) |
| `npm publish` | Publish to npm (prepublishOnly runs build automatically) |

### Run type checking

```bash theme={null}
bun run typecheck
```

### Run tests

```bash theme={null}
bun run test
```

The test suite covers error codes, webhook handlers, metadata helpers, plugin construction with and without subscriptions, Razorpay input serializers, schema definitions, signature utilities, general utilities, and the webhook endpoint.

### Build the package

```bash theme={null}
bun run build
```

This uses `tsup` to produce ESM output and TypeScript declaration files in the `dist/` directory.

### Publish a release

```bash theme={null}
npm publish
```

The `prepublishOnly` script in `package.json` automatically runs `bun run build` before publishing, so you do not need to build manually.

## Writing tests

Tests use Vitest. Add a new test file in `test/` following the existing naming convention (`<module>.test.ts`). Import the module under test from `src/` and assert against the exported functions.

```ts test/example.test.ts theme={null}
import { describe, it, expect } from "vitest";
import { someUtility } from "../src/utils";

describe("someUtility", () => {
  it("returns the expected value", () => {
    expect(someUtility("input")).toBe("output");
  });
});
```

## Peer dependencies

The plugin declares these peer dependencies:

* `better-auth` ^1.7.0
* `@better-auth/core` ^1.7.0
* `typescript` ^5.6.3

Optional peer dependencies for React hooks:

* `@tanstack/react-query` ^5.104.3
* `react` ^19.3.0

Bundled dependencies:

* `razorpay` ^2.9.8
* `zod` ^4.6.7
* `defu`

Make sure your local environment satisfies the peer dependencies when testing integration scenarios.

## License

The project is released under the MIT license.


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