Skip to main content
The better-auth-razorpay plugin exposes Razorpay subscription link and offer APIs, plus add-on and invoice management. Use these features to generate shareable checkout links, apply promotional offers, attach extra items to subscriptions, and inspect billing history. A subscription link is a hosted checkout page that Razorpay generates for a given plan. You can share the shortUrl directly or embed it in emails and dashboards.
string
required
Razorpay plan ID (for example, plan_XXXX).
number
required
Total billing cycles.
number
default:"1"
Number of subscriptions or seats.
number
Unix timestamp when the link expires.
boolean
default:"true"
Whether Razorpay should notify the customer.
array
Add-ons to include at creation. Each add-on needs an item (either { id: "item_XXX" } or a new item with name, amount, currency, and optional description) and an optional quantity.
object
{ notifyPhone, notifyEmail } to pre-fill contact details.
object
Up to 15 key-value pairs stored on the subscription.
Subscription links are created directly on Razorpay and do not require an existing customer. When the customer completes checkout, Razorpay creates the subscription and sends webhook events.
Apply an existing Razorpay offer to a subscription, or remove it.

Delete an offer

Offers must already exist in your Razorpay dashboard. The plugin does not create offers; it only links and unlinks them from subscriptions.

Pending updates

When you schedule a subscription change for the next cycle, Razorpay creates a pending update. You can fetch or cancel it before it applies.

Fetch pending update

Cancel pending update

Canceling a pending update keeps the subscription on its current plan and quantity. The change scheduled for the next cycle is discarded.

Subscription add-ons

Attach extra chargeable items to an existing subscription. Add-ons appear on future invoices.

Create a subscription add-on

string
required
Razorpay subscription ID (for example, sub_XXXX).
object
required
Either { id: "item_XXX" } or a new item with name, amount, currency, and optional description.
number
default:"1"
How many units of the add-on to bill.

Fetch invoices for a subscription

List all invoices generated for a Razorpay subscription.

Fetch a Razorpay subscription

Retrieve the current state of a subscription directly from Razorpay.

List all Razorpay subscriptions

Query subscriptions across your Razorpay account with filters and pagination.
string
Filter by Razorpay plan ID.
string
Filter by status: created, authenticated, active, pending, halted, paused, cancelled, reverted, expired, or completed.
number
Number of results to return (max 100).
number
Number of results to skip for pagination.

React hooks

Use the TanStack Query hooks for links, offers, pending updates, add-ons, invoices, and subscription lookups.
app/subscription/manage/page.tsx

Common errors