Securing Direct UPI Gateways Against UTR Replay Attacks and Underpaid Tampering

Deep security guide covering the four mandatory server-side defenses against modified client amounts, stale bank credit replays, and parallel race exploits in direct UPI integrations.

Why Direct-to-Bank UPI Integrations Require Strict Security Invariants

Every online payment architecture—whether Visa/Mastercard, Razorpay, or direct NPCI UPI—faces attackers probing for logic flaws. In custom UPI integrations, real exploits rarely break cryptography inside banking apps; instead, they target sloppy merchant code that trusts browser parameters, skips settled amount verification, or fails to deduplicate 12-digit UTR numbers.

Attack Vectors & Exact UPIGateway.dev Defenses

Attack VectorHow Attackers Attempt ItHow UPIGateway.dev Stops It
DevTools Request Price EditAltering JSON `amount: 1` inside browser Network tab before order creationServer-derived `product_id` pricing in PostgreSQL + merchant server-side catalog lookup rule
Edited Mobile Transfer (Underpaying)Modifying UPI amount to ₹1 for a ₹999 order during checkoutVerifier compares settled rupee total vs `order.amount`; flags `FLAGGED_UNDERPAID` and returns `status: false`
UTR Replay / Screenshot ReuseSubmitting an old 12-digit bank reference from last week to verify a fresh orderStrict post-order timestamp guard (`alert >= create_date`) + atomic PostgreSQL `utr` uniqueness lock
Forged Redirect Query ParametersManually loading `/payment-success?status=SUCCESS&order_id=...` in browser address barBackend always calls `POST /api/check-order-status` directly and ignores unsigned query params

Exact `FLAGGED_UNDERPAID` Response Contract

{
  "status": false,
  "message": "Payment rejected: Underpaid transaction detected",
  "result": {
    "txnStatus": "FAILED",
    "orderId": "ORD_1732948102",
    "status": "FLAGGED_UNDERPAID",
    "amount": "999",
    "date": "2026-11-30T08:12:00.000Z",
    "utr": "433412345678",
    "redirect_url": null
  }
}

4-Point Developer Verification Checklist

  1. Verify `UPIGATEWAY_USER_TOKEN` exists strictly inside server `.env`, never in `VITE_*` or `NEXT_PUBLIC_*` browser builds.
  2. Inspect ALL four response fields before crediting customers: `resp.status === true`, `resp.result.status === 'SUCCESS'`, `resp.result.txnStatus === 'COMPLETED'`, and `Number(resp.result.amount) >= expectedOrderAmount`.
  3. Enforce `UNIQUE (utr)` and `WHERE status = 'PENDING'` conditional SQL updates inside your own orders ledger.
  4. Always verify `result.status !== 'FLAGGED_UNDERPAID'` and log underpaid attempts cleanly for fraud auditing.

Reference Webhook Verification Function Rejecting Underpaid Orders

export async function verifyStrictOrder(orderId, expectedAmountInr) {
  const resp = await fetch("https://upigateway.dev/api/check-order-status", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      user_token: process.env.UPIGATEWAY_USER_TOKEN,
      order_id: orderId,
    }),
  });
  const body = await resp.json();
  if (!body.status || body.result?.status === "FLAGGED_UNDERPAID") {
    return { verified: false, reason: body.result?.status || "REJECTED" };
  }
  const paid = Number(body.result?.amount || 0);
  const ok = body.result?.status === "SUCCESS" && body.result?.txnStatus === "COMPLETED" && paid >= expectedAmountInr && Boolean(body.result?.utr);
  return { verified: ok, utr: body.result?.utr || null, paid };
}

Related Integration Guides & Developer Resources

Explore more technical articles, code examples, and architecture guides on our official blog. Automate your Indian payment collection at zero percent fees with UPIGateway.dev.

We provide comprehensive developer documentation, ready-to-deploy SDKs for PHP and Node.js, and plug-and-play e-commerce plugins for WordPress and WooCommerce. Build modern payment checkout flows with direct bank settlement and full financial autonomy.

Back to Blog Index | Engineering Reports | View API Documentation | Explore Pricing Plans