Admin · Razorpay
Take money online.
UPI, cards and netbanking via Razorpay popup. Shoppers never type card details into Rarefit.
Checking sign-in…
Checking key…
Step 1 · 5 minutes
Get your Razorpay test keys
- Open dashboard.razorpay.com → sign up as a business → stay in Test mode (sidebar toggle).
- Go to Settings → API Keys → Generate Key → copy the Key ID (starts with
rzp_test_). - Keep the Key Secret private — it goes only in the Cloud Function below, never in the site.
Step 2 · 2 minutes
Paste the Key ID, rebuild
- In the project, open
.envand setPUBLIC_RAZORPAY_KEY_ID=rzp_test_xxxx. - Run
npm run build(or restartnpm run dev). - Open checkout → choose Pay online → badge reads Test mode. Done — try a payment below.
Step 3 · test cards (no real money)
Try a test payment
Step 4 · recommended: order server (Cloud Function)
Without this, the site opens Checkout with the total directly (fine for testing). With it, the amount is locked server-side so it can't be tampered with. Deploy once:
// functions/index.js (firebase init functions, then: npm i razorpay)
const { onRequest } = require("firebase-functions/v2/https");
const Razorpay = require("razorpay");
const crypto = require("crypto");
const rzp = () => new Razorpay({
key_id: process.env.RAZORPAY_KEY_ID,
key_secret: process.env.RAZORPAY_KEY_SECRET,
});
exports.createOrder = onRequest({ cors: true }, async (req, res) => {
try {
const amount = Math.round(Number(req.body.amount));
if (!amount || amount < 100) { res.status(400).json({ error: "Bad amount" }); return; }
const order = await rzp().orders.create({ amount: amount, currency: "INR" });
res.json({ id: order.id });
} catch (e) { res.status(500).json({ error: "Order failed" }); }
});
exports.verifyPayment = onRequest({ cors: true }, async (req, res) => {
const b = req.body || {};
const text = b.razorpay_order_id + "|" + b.razorpay_payment_id;
const expected = crypto.createHmac("sha256", process.env.RAZORPAY_KEY_SECRET)
.update(text).digest("hex");
res.json({ ok: expected === b.razorpay_signature });
});- Set secrets:
firebase functions:secrets:set RAZORPAY_KEY_ID(andRAZORPAY_KEY_SECRET). - Deploy:
firebase deploy --only functions, then setPUBLIC_RAZORPAY_ORDER_URL=https://…cloudfunctions.net/createOrderin.envand rebuild.
Step 5 · go live checklist
- Complete Razorpay KYC → switch to Live mode → replace the Key ID with
rzp_live_…→ rebuild. Checkout badge flips to Live. - Add a Razorpay webhook (
payment.captured) pointing at your function to mark orders paid even if the shopper closes the tab. - Refunds happen in Razorpay dashboard → Payments → Refund (do this before touching stock back).
- Never commit the Key Secret to git — secrets live in Cloud Functions config only.