Commerce, payments and delivery · senior
Case study: payment checkout (Razorpay-style)
A strong payment design creates the order on the server, opens the gateway's checkout with that order id, treats the browser's success callback as unverified until the server checks the signature, uses webhooks as the source of truth, and shows a clear 'pending' state instead of guessing.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Razorpay flow: server calls the Orders API (amount in paise) → client opens Checkout with order_id and the public key id → handler returns razorpay_payment_id, razorpay_order_id, razorpay_signature → server verifies HMAC-SHA256 of order_id + '|' + payment_id with the key secret, using the order_id it stored, not the one from the client → fulfil only when the payment is captured.
- Webhooks (e.g. order.paid) are the primary asynchronous truth; when the UI needs an answer before the webhook, the server fetches the payment status.
- Never trust the client 'success' callback; never create orders from the browser (the docs note CORS errors, and the secret must stay on the server).
- Card data stays inside the gateway's iframe or page (PCI scope); your page only sees tokens and ids.
- States: created → attempted → paid | failed | unknown. A timeout is 'unknown/pending', not 'failed': poll the order status with backoff, and resume pending payments on the next app open.
- UPI on mobile web: intent (opens the UPI app) or collect (approve in the app); show a countdown and 'waiting for approval'; retries reuse the same order to avoid double charges.
- Embedding safety: load the SDK over HTTPS from the official domain, CSP allow-list, strict postMessage origin checks.
- Observability: funnel per method (card, UPI, netbanking), failure reasons, drop-off, latency; alert on success-rate drops by bank.
The red pen
Common traps: mistake → fix
Mistake: The handler fired, so the payment succeeded
Fix: verify the signature on the server and check capture.
Mistake: Mark the payment failed on timeout
Fix: it may succeed a minute later; show pending and reconcile.
Mistake: Put card inputs in your own form
Fix: PCI scope and data risk.
Mistake: Use test keys in production
Fix: users see success but no money moves (the docs warn about this).
Easy to hard
Questions interviewers ask, easy to hard
- Integrate a third-party payment gateway like Razorpay or Stripe into our checkout.
- The payment succeeds but the browser closes before the callback. How does the merchant know?
- Iframe, script SDK or redirect: what are the trade-offs?
- UPI approval is pending for 3 minutes. What does the UI do?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.