Demo payments (Razorpay test mode)
Oasis collects weekly premiums through Razorpay Standard Checkout (embedded modal). In test mode, no real INR is charged. Use this page when you need a repeatable demo or local QA.
Prerequisites
Section titled “Prerequisites”- A Razorpay account with Test mode enabled (toggle in the Razorpay Dashboard).
- Test API keys from Dashboard → Account & Settings → API Keys (use the Key ID and Key Secret shown in test mode).
- Oasis environment variables set (see below).
- A rider who has finished onboarding (platform, zone, government ID, face verification) so
/dashboard/policycan show the subscribe flow.
Environment variables
Section titled “Environment variables”Copy from .env.local.example and fill payment fields:
# Client: must start with rzp_test_ (enforced in code for non-production builds)NEXT_PUBLIC_RAZORPAY_KEY_ID=rzp_test_...
# Server-onlyRAZORPAY_KEY_SECRET=...
# Optional: backup path when the Dashboard sends webhooks to your appRAZORPAY_WEBHOOK_SECRET=...The publishable Key ID is safe to expose in the browser; the Key Secret and Webhook Secret must never use a NEXT_PUBLIC_ prefix.
If either key is missing or invalid, POST /api/payments/create-checkout returns 503 and the policy page shows a configuration error.
End-to-end flow in the app
Section titled “End-to-end flow in the app”sequenceDiagram participant R as Rider browser participant A as Next.js API participant Z as Razorpay Checkout R->>A: POST /api/payments/create-checkout A->>A: Insert pending weekly_policy + Razorpay order A-->>R: keyId, orderId, amount, … R->>Z: Open Standard Checkout (modal) Z-->>R: razorpay_order_id, razorpay_payment_id, razorpay_signature R->>A: POST /api/payments/verify A->>A: Verify signature + activate policy R->>R: Redirect /dashboard/policy?success=1
- Sign in as a rider and complete onboarding (
/onboarding). - Open Policy (
/dashboard/policy). - Choose a weekly plan (Basic / Standard / Premium) and start checkout.
- The app calls
POST /api/payments/create-checkoutwithplanId,weekStart, andweekEnd. Oasis creates a pendingweekly_policiesrow and a Razorpay order, then returns options for the Checkout script. - The Razorpay modal opens (
checkout.razorpay.com). Complete payment using a test method (next section). - On success, the client calls
POST /api/payments/verifywith the Razorpay response fields. The server verifies the signature, callsprocess_razorpay_payment_event, and marks the policy paid / active. - You are redirected to
/dashboard/policy?success=1with coverage active.
Test payment methods (no real money)
Section titled “Test payment methods (no real money)”Razorpay maintains the authoritative list of test cards, UPI VPAs, and netbanking flows:
- Test card and payment details (official Razorpay docs)
Common patterns in test mode:
- UPI: use the success VPA documented by Razorpay for test mode (e.g.
success@razorpay— confirm on the page above; Razorpay may update labels). - Cards: use the success card numbers from the same doc for domestic and international test scenarios.
Always keep the Dashboard in Test mode when using these methods.
Optional: Razorpay webhooks (local or deployed)
Section titled “Optional: Razorpay webhooks (local or deployed)”- In Razorpay Dashboard → Webhooks, add your public URL:
https://<your-host>/api/payments/webhook - Subscribe at least to
payment.captured(this is what Oasis handles). - Copy the Webhook secret into
RAZORPAY_WEBHOOK_SECRET.
For local development, expose your machine with a tunnel (ngrok, Cloudflare Tunnel, etc.) and register that URL, or rely on verify-only without webhooks.
The webhook uses the x-razorpay-signature header and the same idempotent process_razorpay_payment_event path as verify.
Troubleshooting
Section titled “Troubleshooting”| Symptom | What to check |
|---|---|
| “Payment not configured” / 503 on subscribe | NEXT_PUBLIC_RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET set; Key ID starts with rzp_test_ in test mode |
| Checkout does not open | Browser console for script errors; ad blockers blocking checkout.razorpay.com |
| Verify fails after “success” in modal | Server logs for /api/payments/verify; clock skew is rare—usually wrong secret or order/policy mismatch |
| Webhook 503 “Webhook not configured” | RAZORPAY_WEBHOOK_SECRET unset—optional if you only use verify |
| Policy stays pending | Confirm payment.captured fired and amount matches policy premium in paise |
Related
Section titled “Related”- Development Setup — install, env, database
- Deployment — production env and Razorpay webhook URL
- API overview — payment routes at a glance