razorpay(...) inside your betterAuth plugins array. This page lists every option, grouped by purpose, so you can configure credentials, customer behavior, subscriptions, organizations, webhooks, and schema overrides in one place.
Credentials
An existing
Razorpay instance created with new Razorpay({ key_id, key_secret }). Use this when you already manage a Razorpay client elsewhere in your application.Your Razorpay key id, for example
rzp_test_XXXX. Required when razorpayClient is not provided.Your Razorpay key secret. Required when
razorpayClient is not provided, and also required for payment signature verification.Behavior
ISO 4217 currency code used as the default for orders, plans, and invoices when no currency is explicitly supplied.
When
true, the one-time payment and Route transfer endpoints require an active Better Auth session. Set to false to remove session middleware from those endpoints.The secret used to verify Razorpay webhook signatures. If this is missing when a webhook arrives, the plugin raises
WEBHOOK_SECRET_NOT_FOUND. See the webhooks guide for setup instructions.Customers
When
true, a Razorpay customer is created automatically when a user signs up. The customer id is stored on user.razorpayCustomerId, and the onCustomerCreate callback is invoked. This is required for subscription upgrades; without it the plugin raises CUSTOMER_NOT_FOUND.Called after a Razorpay customer is created during sign-up. Use it to sync extra fields into your own database or trigger welcome emails.
Merge additional parameters into the Razorpay customer create call. Return an object with fields such as
contact, gstin, or notes.Subscriptions
Controls whether subscription endpoints and the local
subscription table are registered. Set enabled: true to unlock plan management, upgrades, cancellations, and lifecycle webhooks. See subscription plans for the full SubscriptionOptions reference.subscription.enabled is true, the plugin registers endpoints for upgrading, cancelling, pausing, resuming, updating, restoring, and listing subscriptions. Razorpay subscription APIs such as fetchSubscription, createSubscriptionLink, and fetchPendingUpdate are always registered regardless of this flag.
Organizations
Enables organization-level subscriptions. Requires the Better Auth
organization() plugin. When enabled, each organization can have its own Razorpay customer id, and seat-based plans automatically sync member counts to subscription quantity. See organizations for the full setup.Same shape as the user-level
getCustomerCreateParams, but receives the organization record instead of the user.Called after the Razorpay customer for an organization is created.
Webhook callbacks
Called for every Razorpay webhook event before any specific handler runs. Use it for logging or custom routing.
Fired when an order is fully paid. This is the safest place to fulfill goods or services because the signature and amount have already been verified by Razorpay.
Subscription lifecycle callbacks such as
onSubscriptionActivated and onSubscriptionCharged are defined inside subscription options, not at the top level. See subscription plans for details.Schema
Override or extend the plugin’s database schema. Use this to rename columns, add indexes, or change field types within Better Auth’s schema customization system.
Full example
The following configuration uses most options in a singlebetterAuth setup. Adjust values for your own keys, plans, and business logic.
auth.ts
After changing schema-related options, run
npx @better-auth/cli migrate or generate to apply database migrations.