DEV Community

Cover image for How UPI Works: The ₹0 Magic Behind Every Scan-and-Pay (System Design)
Tejas Patil
Tejas Patil

Posted on

How UPI Works: The ₹0 Magic Behind Every Scan-and-Pay (System Design)

System Design Simplified — Part 1

The chai stall

It's 8 AM. You're holding a cutting chai in one hand and your phone in the other. You scan a faded QR code on the counter, type four digits, and before Bablu looks up from his kettle, his phone says ₹20 received.

Two seconds. No card. No cash. No fee.

In August 2026 alone, UPI handled a record 24.51 billion transactions, about 791 million a day. That's roughly 85% of India's digital payments and nearly half of all real-time payments on Earth.

So what happened in those two seconds? Let's follow your ₹20.

Meet the cast

Every UPI payment has five characters, and each has exactly one job.

You. The person with the phone.

Your UPI app. PhonePe, Google Pay, Paytm. It does not hold your money. It's a messenger.

Your bank. Where your money lives. The only one allowed to take ₹20 out.

NPCI. The National Payments Corporation of India. It runs one central switch that every bank is plugged into. It holds no money either. It's the traffic cop at the junction.

Bablu's bank. Where the ₹20 lands.

One idea to remember: apps and NPCI are messengers. Only banks touch money.

The journey of ₹20, in motion

Purple = the request. Orange = the money. Green = done. Watch it loop once and the whole system makes sense.

Notice the order. Your bank is asked first. Money leaves your account before anyone asks Bablu's bank to accept it. That's deliberate: money stuck in transit can be reversed; money credited that was never debited cannot.

Wait, so what is Google Pay?

This is the part most explainers skip.

Google Pay, PhonePe, Paytm, CRED, Amazon Pay are not banks. NPCI has a strict rule: it talks only to banks. So how does an app made by Google reach the switch?

It borrows a bank.

Every UPI app partners with one or more licensed banks, called PSP banks (Payment Service Provider). The bank owns the actual connection to NPCI. It gets audited, holds the security certificates, and takes legal responsibility for every request the app sends. The app, officially a Third-Party Application Provider, rides on the bank's pipe.

You've seen this without noticing. The @okaxis in ramesh@okaxis means Google Pay is using Axis Bank as its PSP. @ybl is PhonePe on Yes Bank. @paytm is Paytm's own handle. The part after @ names the app's partner bank, not yours.

That's the twist: your money can sit in SBI while your Google Pay handle says Axis. Axis is the doorman who walks your request into NPCI. SBI still opens the vault.

Why build it this way? NPCI would rather trust 50 regulated banks than vet 500 apps. If an app misbehaves, its PSP bank answers for it.

There's a real-world reason the big apps now keep several PSP banks. In March 2020, PhonePe ran only on Yes Bank. When RBI put Yes Bank under a moratorium, NPCI blocked its handles, and PhonePe went down with it. Within months PhonePe added ICICI (@ibl) and later Axis (@axl). Today, if one partner bank is slow, the app quietly routes through another.

What NPCI actually does

The switch isn't a black box. It does four jobs on every single payment.

Directory. It keeps the phonebook. bablutea@okaxis maps to a real bank and account number. You never see that mapping, and neither does the person paying you.

Router. It asks your bank to debit first, then asks the receiver's bank to credit, each with a strict timeout. A slow bank gets marked pending; the switch moves on.

Tracker. If a reply never comes back, NPCI doesn't guess. It marks the payment pending, runs a check-status call, and reverses the debit if the credit never landed.

Tally. It records what every bank owes every other bank, all day. More on that below.

NPCI talks only to banks, over private certified lines. It never holds money and never sees your PIN.

The clever ideas inside

Your UPI ID is a nickname. ramesh@okaxis is like a saved contact. NPCI keeps the phonebook. Share it on a poster, switch banks later, the ID stays.

Your PIN never travels. You type it into a locked box provided by NPCI, called the common library. It's encrypted right there on your phone, and only your bank has the key. Google Pay cannot read your PIN. Neither can NPCI. Neither can Axis.

Your phone is the password. During setup, the app sends a silent SMS from your SIM. That binds your number, SIM and device together. There's no username. Your phone is the login; your PIN is the second factor.

It's a switch, not a wallet. A wallet has to hold your money. UPI never does. Money moves bank to bank, so there's no top-up, no middleman, no fee hiding in the spread.

When things go wrong

Money debited, Bablu shrugs, nothing received. What happened?

Your bank said yes and debited you. Then a message got lost between the switch and Bablu's bank. UPI doesn't guess. It marks the payment pending, and NPCI runs a check-status call to learn the truth. If the credit never landed, a reversal goes to your bank and the ₹20 comes back, usually within hours.

The promise: money is never in two places, and never nowhere. It's with you, with them, or in a tracked pending state that will resolve.

Did the banks actually move money?

Here's what almost nobody knows. When your bank debits ₹20 and Bablu's bank credits ₹20, the two banks haven't exchanged a rupee yet. Each just updated its own customer's balance.

Think of two friends who keep paying for each other all week. They don't hand over cash every time; they keep a tally and settle the difference on Sunday. NPCI is the friend with the notebook. Several times a day it tells the Reserve Bank of India "Axis owes SBI ₹340 crore net," and one transfer settles millions of chai payments.

That's why UPI is instant and free at the same time. The expensive part, moving real money between banks, happens only a few times a day, in bulk.

How does one switch survive 791 million hits a day?

Nobody waits for anyone. Every hop has a strict timeout. A slow bank gets marked pending; the switch moves on. Slow banks hurt their own customers, not the country.

The switch is stateless, copied many times. It only routes messages, so dozens of identical copies sit behind a load balancer. Any copy can handle any payment. One dies, nobody notices.

Every message has an ID that can't be reused. If your app resends because the network blinked, the switch sees the same transaction ID and says "already done" instead of charging you twice. This is called idempotency. It's the single most important idea in payments.

Five things to remember

  1. Apps and NPCI are messengers. Only banks hold money.
  2. Google Pay isn't a bank. It reaches NPCI through a partner PSP bank, named by the @ in your UPI ID.
  3. Your PIN is encrypted on your phone; only your bank can read it.
  4. Debit first, credit second. Pending is a tracked state, not a bug.
  5. Banks settle in batches, which is why instant can also be free.

Next in the series

Part 2: How Google Pay handles the Payment Pending screen without losing your money. Retries, timeouts and idempotency, told through one stuck ₹500.


Numbers from NPCI's monthly statistics for August 2026. Bablu Tea Stall is fictional; the system is not.

Top comments (1)

Collapse
 
tejas164321 profile image
Tejas Patil •

Thanks for reading!

One thing people keep asking: your UPI handle (@okaxis, @ybl) is the app's partner bank, not yours. Your money can sit in SBI while your handle says Axis.

Part 2 is about "Payment Pending" — where the money goes when it leaves your account but doesn't arrive. If you've had one stuck, tell me how long it took to come back. I'm collecting real stories.