Create a plan
Callauth.api.createPlan from the server to create a new Razorpay plan. This is typically an admin-only operation. Validate the caller’s role before invoking the endpoint.
app/api/admin/plans/route.ts
Interval count. For example,
1 with "monthly" means every month; 3 means every 3 months.List plans
Fetch all plans from your Razorpay account.Fetch a single plan
Retrieve a specific plan by its Razorpay ID.Use a created plan in plugin config
After creating a plan in Razorpay, copy itsid into the plugin’s subscription.plans array so users can subscribe to it.
auth.ts
The
name field is matched case-insensitively when users call authClient.subscription.upgrade({ plan: "pro" }). The plugin stores the plan name lowercased in the database.Dynamic plans
If your application supports plan creation from an admin dashboard, you can fetch the latest plans from Razorpay at runtime and use them to populate your pricing page or plugin configuration.app/admin/plans/page.tsx
React hook: useRazorpayPlans
useRazorpayPlans fetches the full list of Razorpay plans and caches it with TanStack Query. You can pass queryOptions to customize caching behavior.