Configure billing gateways, customer portals, webhook endpoints, and checkout verification.
Billing Gateway Architecture
Operator features a dual-gateway provider architecture implemented in src/server/services/billing/providers/:
- Stripe: Recommended for North America, Europe, and international credit/debit card processing.
- Razorpay: Recommended for India and Southeast Asia (supports UPI QR, NetBanking, and RuPay).
Both providers implement the PaymentProvider interface and process webhooks through the central webhookProcessor.
Stripe Setup & Customer Portal
Configuration
1. In your `.env`, configure:
- `STRIPE_SECRET_KEY`
- `STRIPE_WEBHOOK_SECRET`
- `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`
2. In the Stripe Dashboard, configure your Webhook Endpoint:
- URL: `https://YOUR_DOMAIN/api/webhooks/billing/stripe`
- Events: `checkout.session.completed`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.payment_succeeded`, `invoice.payment_failed`.
Self-Service Customer Portal
Customers can manage payment methods, upgrade tiers, download invoices, or cancel subscriptions through Stripe's hosted Customer Portal linked directly from **Billing** (`/billing`).
Razorpay Setup & Webhooks
Configuration
1. In your `.env`, configure:
- `RAZORPAY_KEY_ID`
- `RAZORPAY_KEY_SECRET`
- `RAZORPAY_WEBHOOK_SECRET`
2. In Razorpay Dashboard under **Settings > Webhooks**:
- URL: `https://YOUR_DOMAIN/api/webhooks/billing/razorpay`
- Secret: Matches `RAZORPAY_WEBHOOK_SECRET`
- Events: `payment.captured`, `payment_link.paid`, `subscription.charged`.