- Home
- Skills
- APIs & Backend
- Razorpay Stripe Billing
Razorpay Stripe Billing
Implement production-grade dual-gateway billing with Razorpay, Stripe, and GST-compliant invoicing for Next.js.
$14.99
Razorpay Stripe Billing
Example session with this skill installed
Set up a dual-gateway billing system with Razorpay and Stripe for my Next.js app. I need webhook verification and GST invoice support.
- Read your context and instructions
- Compiled the razorpay stripe billing
I have implemented the dual-gateway billing system. This includes the Prisma schema for orders and invoices, the checkout routing logic, and secure webhook handlers for both Razorpay and Stripe.
Billing System Implementation
1. Database Schema (Prisma)
model PaymentOrder {
id String @id @default(cuid())
userId String
amount Int // In smallest unit (paise/cents)
currency String
status String // PENDING, COMPLETED, FAILED
provider String // RAZORPAY | STRIPE
providerOrderId String @unique
createdAt DateTime @default(now())
Invoice Invoice?
}
model WebhookEvent {
id String @id @default(cuid())
provider String
providerEventId String @unique // Prevents double-processing
processedAt DateTime @default(now())
}
model Invoice {
id String @id @default(cuid())
orderId String @unique
order PaymentOrder @relation(fields: [orderId], references: [id])
invoiceNumber String @unique // INV-2024-XXXX
taxBreakdown Json // { cgst, sgst, igst, vat }
totalAmount Int
}
2. Webhook Verification (Node.js)
import crypto from "crypto";
// Razorpay HMAC Verification Example
const expectedSignature = req.headers["x-razorpay-signature"];
const body = await req.text();
const generatedSignature = crypto
.createHmac("sha256", process.env.RAZORPAY_WEBHOOK_SECRET!)
.update(body)
.digest("hex");
if (!crypto.timingSafeEqual(Buffer.from(generatedSignature), Buffer.from(expectedSignature))) {
return new Response("Invalid signature", { status: 400 });
}
Next steps
- Add the provider secrets to your
.envfile. - Run
npx prisma db pushto sync the new payment and invoice models. - Configure your Razorpay and Stripe dashboards to point to the new
/api/billing/webhooksendpoints.
Connects securely to your tools. The creator never sees your data.
About this skill
Integrating global payments usually involves high risk and repetitive boilerplate. This skill implements a production-ready billing layer that handles both Razorpay for Indian markets and Stripe for global customers. It prevents double-charging and ensures tax compliance without manual logic.
What it does
- Dual-gateway routing automatically directs users to Razorpay for INR/UPI or Stripe for USD/EUR based on currency.
- Cryptographic verification secures webhooks using HMAC and native SDK methods to prevent tampered payment signals.
- Idempotent processing uses database constraints to safely handle webhook retries without double-crediting accounts.
- Tax-compliant invoicing calculates CGST, SGST, IGST for Indian transactions and zero-rated VAT for international exports.
- Server-side price enforcement ignores client-side amount inputs, fetching plan costs strictly from your database or config.
How it works
- Initialize environment by installing SDKs and generating a secure
.env.exampletemplate for both providers. - Sync database models using the provided Prisma schema for orders, webhook event tracking, and invoices.
- Configure checkout API to authenticate sessions and route orders to the correct gateway based on the user's currency.
- Implement webhook listeners that verify signatures and execute database transactions for payment fulfillment.
- Generate invoices with sequential numbering and specific tax breakdowns for India and international regions.
Frameworks & tools
Built for Next.js App Router and Node.js. Uses Prisma for database operations, Zod for schema validation, and official stripe and razorpay SDKs.
Why this beats prompting it yourself
Writing billing logic from scratch often leads to security holes like price manipulation or race conditions during webhook processing. This skill provides a tested architecture for idempotency and specific Indian GST logic that generic prompts usually miss.
Use cases
- Launching a SaaS that needs UPI/Netbanking in India and cards globally.
- Adding automated GST-compliant PDF invoicing to an existing agency platform.
- Migrating from a single-gateway setup to a multi-currency billing system.
- Hardening existing payment endpoints against webhook spoofing and double-processing.
Known limitations
Requires a database with unique constraint support for idempotency. Does not include frontend UI components for the checkout buttons.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 9 days ago
- Software
- tsc
Node.jstypescriptprisma
Permissions
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.