Skip to main content
Find the anon key with npx @insforge/cli secrets get ANON_KEY, or in the dashboard: click Install and open API Keys.

Overview

The TypeScript SDK exposes Razorpay runtime helpers for generated app frontends:
  • insforge.payments.razorpay.createOrder(...)
  • insforge.payments.razorpay.verifyOrder(...)
  • insforge.payments.razorpay.createSubscription(...)
  • insforge.payments.razorpay.verifySubscription(...)
  • insforge.payments.razorpay.cancelSubscription(...)
  • insforge.payments.razorpay.pauseSubscription(...)
  • insforge.payments.razorpay.resumeSubscription(...)
Razorpay does not return a hosted Checkout URL. The backend creates a Razorpay Order or Subscription and returns checkoutOptions. The browser loads Razorpay Checkout and opens it with those options.
See Razorpay Payments for provider setup, manual webhooks, database tables, and fulfillment patterns.

SDK setup

The SDK calls Razorpay runtime routes with the current InsForge user token. Do not call these routes with provider secret keys.

Load Razorpay Checkout

One-time order

Create an app-owned pending order first. Then create the Razorpay Order through InsForge: Razorpay Orders can be amount-only, but creating Razorpay Items for one-time sellable products is a good practice because synced Items make the catalog visible in InsForge and Razorpay. Treat Orders as payment attempts.
If your webhook trigger reads notes.order_id, pass notes: { order_id: ... } when creating the Order. Open Razorpay Checkout and verify the returned signature:
Signature verification protects the immediate browser callback. Durable fulfillment should still come from verified Razorpay webhook events.

Subscription

Create or sync a Razorpay Plan first. Then create the subscription through InsForge:
Pass Razorpay subscription notes when webhook triggers need app identifiers later. Open Razorpay Checkout with the returned subscription ID:

Manage subscriptions

Razorpay does not provide a Stripe Billing Portal equivalent. Use backend routes for subscription management:
Subscription creation checks INSERT policies on payments.razorpay_subscriptions. Cancel, pause, and resume check UPDATE policies on the same table. PostgreSQL also applies SELECT policies to rows returned by INSERT/UPDATE ... RETURNING, so add matching SELECT visibility for the same billing subject when a policy probe needs to return the row. Add app-specific RLS or server-side membership checks before exposing these controls for shared subjects.

Fulfillment

Do not mark orders paid, grant credits, or activate subscriptions from the Checkout handler alone. Use verified Razorpay webhook events in payments.webhook_events. Do not attach fulfillment triggers to provider mirror tables such as payments.razorpay_subscriptions. Create app-owned fulfillment tables with RLS, then update them from webhook triggers. See Razorpay Payments for a trigger example.

Live/test environment

Pass 'test' as the first SDK argument while developing. Only switch to 'live' after the developer explicitly approves production Razorpay changes and live Items, Plans, and webhooks are configured.
Never put Razorpay Key Secret or webhook secret in frontend code. The frontend only receives the public Razorpay Key ID as checkoutOptions.key.