Skip to main content
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.
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.
  • 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>:

Pagination

List endpoints support a common pagination shape:
integer
Unix timestamp. Return items created after this time.
integer
Unix timestamp. Return items created before this time.
integer
Maximum number of items to return. Maximum value is 100.
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.
Status codes map to Better Auth conventions: BAD_REQUEST, NOT_FOUND, INTERNAL_SERVER_ERROR, FORBIDDEN, UNAUTHORIZED. See Error codes for the full list.

Endpoint groups

Orders

Create, retrieve, edit, and list Razorpay orders. Verify payments against an order.

Payments

Retrieve, list, edit, and capture Razorpay payments.

Refunds

Refund payments and manage refund records.

Transfers

Create and manage Razorpay Route transfers between linked accounts.

Subscriptions

Upgrade, cancel, pause, resume, and restore plugin-managed subscriptions.

Razorpay subscriptions

Direct Razorpay subscription APIs: links, add-ons, offers, invoices, and pending updates.

Plans

Create and retrieve Razorpay billing plans.

Invoices

Create, issue, edit, cancel, notify, and list Razorpay invoices.

Customers

Create, edit, and list Razorpay customers. Manage bank accounts and tokens.

Items

Create, edit, delete, and list Razorpay catalog items.

Add-ons

Retrieve, list, and delete Razorpay subscription add-ons.

Webhook

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.