Payments 101 β How Money Actually Moves
The Mental Model
When you tap your card at a store, 12 different systems talk to each other in under 2 seconds. Understanding this flow is what separates a fintech engineer from a generic backend developer.
The Payment Ecosystem β Who Does What
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
β Customer β β β Merchant β β β Acquirer β β β Network β β β Issuer β
β (You) β β (Store) β β (Bank) β β(Visa/MC) β β (Bank) β
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
Has card Has terminal Processes Routes Approves/
for merchant transaction declines
| Entity | What They Do | Examples |
|---|---|---|
| Cardholder | You. Has the card/phone. | Any customer |
| Merchant | Sells goods/services. Has a POS terminal. | Amazon, Swiggy, local store |
| Acquirer | Merchantβs bank. Processes payments on merchantβs behalf. | HDFC, ICICI, Worldline |
| Card Network | Routes transactions between acquirer and issuer. Sets rules. | Visa, Mastercard, RuPay |
| Issuer | Customerβs bank. Issued the card. Approves/declines. | SBI, Axis, Kotak |
| Payment Gateway | Software layer between merchantβs website and acquirer. | Razorpay, Stripe, Juspay |
| Payment Processor | Handles the actual transaction processing. | Pine Labs, Worldline |
A Card Payment β Step by Step
In one picture β the request races up the chain to the issuer and the approval races back down:
sequenceDiagram
participant C as Cardholder
participant M as "Merchant POS"
participant A as "Acquirer bank"
participant N as "Card network"
participant I as "Issuer bank"
C->>M: Tap or insert card
M->>A: Send transaction
A->>N: Forward request
N->>I: Route to issuer
Note over I: Valid card<br/>Enough balance<br/>Not fraud
I-->>N: Approve or decline
N-->>A: Relay result
A-->>M: Relay result
M-->>C: Show Approved or Declined
1. Customer taps card on POS terminal
2. Terminal reads card data (EMV chip interaction β APDU commands)
3. Terminal sends transaction to Acquirer
4. Acquirer forwards to Card Network (Visa/MC)
5. Network routes to Issuer (customer's bank)
6. Issuer checks:
- Is the card valid?
- Does the customer have enough balance/credit?
- Does this look fraudulent?
7. Issuer sends approval/decline back through the chain
8. Terminal shows "Approved" or "Declined"
Total time: 1-3 seconds. But the money hasnβt actually moved yet.
Authorization vs Settlement (Critical to Understand)
Authorization (instant): βYes, this customer has Rs. 500. Iβm holding it.β
Settlement (hours/days): βOK, actually move the Rs. 500 from issuer to acquirer to merchant.β
Day 0 (3 PM): Customer buys coffee for Rs. 200
β Authorization: Rs. 200 held on card
β Customer sees Rs. 200 "pending" in bank app
Day 0 (11 PM): Batch settlement runs
β Acquirer sends all day's transactions to network
β Network sends to issuers
β Issuers debit actual amounts
Day 1-2: β Funds arrive in merchant's bank account
β Customer's "pending" becomes "completed"
Why this matters for engineers: When building payment systems, you handle authorizations (real-time, needs to be fast) separately from settlements (batch, needs to be accurate). These are different systems with different requirements.
UPI β Indiaβs Revolution
UPI (Unified Payments Interface) skips the card network entirely:
Customer's Phone β NPCI (UPI switch) β Customer's Bank
β Merchant's Bank
No card network in the middle β the PSP app talks to NPCI, and NPCI moves money account-to-account:
flowchart LR
P["Payer app<br/>GPay or PhonePe"] --> N["NPCI<br/>UPI switch"]
N --> PB["Payer bank<br/>debit"]
N --> MB["Merchant bank<br/>credit"]
PB -.-> N
MB -.-> N
N -.-> P
- Real-time settlement (unlike cards which take days)
- No intermediary fees (or very low)
- Account-to-account (no card involved)
Key UPI concepts:
- VPA (Virtual Payment Address):
darshan@upi - PSP (Payment Service Provider): The app β Google Pay, PhonePe, Paytm
- NPCI: The central switch that routes UPI transactions
Money Rules Every Fintech Engineer Must Know
1. Never Use Float/Double for Money
// THIS IS A BUG
double price = 0.1 + 0.2;
System.out.println(price); // 0.30000000000000004
// THIS IS CORRECT
BigDecimal price = new BigDecimal("0.1").add(new BigDecimal("0.2"));
System.out.println(price); // 0.3
Why: IEEE 754 floating point cannot represent 0.1 exactly. In a financial system processing millions of transactions, these tiny errors accumulate into real money.
2. Store Amounts in Smallest Unit
// Store Rs. 150.50 as 15050 (paise)
// Store $10.99 as 1099 (cents)
// No decimal arithmetic needed. Integer math is exact.
long amountInPaise = 15050;
3. Idempotency β The #1 Rule
If a payment request is sent twice (network timeout, retry), it should only be processed ONCE.
// Every payment request has a unique idempotency key
POST /payments
{
"idempotency_key": "pay_abc123_1234567890",
"amount": 15050,
"currency": "INR"
}
// Server logic:
// 1. Check if this idempotency_key was already processed
// 2. If yes β return the previous result (don't process again)
// 3. If no β process and store the key with the result
4. Double-Entry Bookkeeping
Every financial transaction has TWO entries β a debit and a credit. They must always balance.
Customer buys coffee for Rs. 200:
DEBIT: Customer account -200
CREDIT: Merchant account +200
NET: 0 (always zero)
If your ledger doesnβt net to zero, something is wrong.
Interview Questions Youβll Get
- βWhat happens when you tap your card at a POS terminal?β
- βWhatβs the difference between authorization and settlement?β
- βWhy canβt you use float for money in Java?β
- βWhat is idempotency and why does it matter in payments?β
- βHow does UPI work differently from card payments?β
You should be able to answer all five after reading this page.
Module done? Add it to todayβs tracker