<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aryan Gupta on Medium]]></title>
        <description><![CDATA[Stories by Aryan Gupta on Medium]]></description>
        <link>https://medium.com/@gupta.raj.aryan.2005?source=rss-7afa9305cca1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eL8Cc1e9aDK2RJ95</url>
            <title>Stories by Aryan Gupta on Medium</title>
            <link>https://medium.com/@gupta.raj.aryan.2005?source=rss-7afa9305cca1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:41:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gupta.raj.aryan.2005/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Week 05 — Auditing the Financial World]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/week-05-auditing-the-financial-world-07e4d4aabc23?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/07e4d4aabc23</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 12:14:10 GMT</pubDate>
            <atom:updated>2026-10-05T12:14:10.621Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*11hPokCOSCddvJjuWg7rxw.png" /></figure><h3>The €1.9 billion that never existed</h3><p>In June 2020, auditors asked two banks in the Philippines a simple question: is Wirecard’s €1.9 billion sitting with you? Both banks said no. The documents showing that money were fake.</p><p>Wirecard was no scrappy startup. It was a German payments giant that had replaced Commerzbank in the DAX, Germany’s blue-chip index, two years earlier. The missing cash was roughly a quarter of its entire balance sheet.</p><p>Within days, Wirecard admitted the money most likely did not exist. On June 25, 2020, it filed for insolvency, the first DAX member ever to do so. Its auditor, EY, had signed off on its accounts year after year.</p><p>Sit with that for a second. Investors bought the shares, banks lent the money and merchants routed payments through the company, all on the strength of numbers nobody had checked in the one way that mattered.</p><p>Which brings us to this week’s big question:</p><blockquote><strong><em>When billions of dollars exist only as numbers in spreadsheets and databases, who makes sure those numbers are real?</em></strong></blockquote><p>Here’s the deal for sticking with this episode. By the end, you’ll know the invisible chain that turns one sale into a signed audit opinion, and why almost every audit rule on Earth was written after a disaster. You’ll meet a 145-year-old quirk of mathematics that catches made-up numbers.</p><p>You’ll also learn the number one way fraud actually gets caught (it’s not auditors, and it’s not AI). And there’s a plot twist about Accenture that most people in finance have never heard.</p><p>One more thing: keep Wirecard in the back of your mind. We’ll come back to who actually exposed it, and it’s not who you’d expect.</p><h3>Clue 1: Money is just data now</h3><p>Your salary is a row in a database. A company’s billions are millions of rows in an ERP system. The financial statements you read are just those rows, summarised.</p><p>The rulebook for writing those rows is over 500 years old. In 1494, the Italian mathematician Luca Pacioli published the method merchants in Venice already used: double-entry bookkeeping. Every transaction is recorded twice, once as a debit and once as a credit, and the two sides must always balance.</p><p>If you work in tech, here’s the way to think about it: double-entry is the world’s oldest checksum. If the books don’t balance, something is wrong. If they do balance, that proves nothing on its own, and that gap is where auditors live.</p><h3>The three documents everyone argues about</h3><p>Statement</p><p>The question it answers</p><p>Where fraud likes to hide</p><p>Income statement</p><p>Did we make money this period?</p><p>Revenue booked too early, or expenses disguised as investments</p><p>Balance sheet</p><p>What do we own and owe right now?</p><p>Cash that doesn’t exist, debts kept off the books</p><p>Cash flow statement</p><p>Where did the actual cash go?</p><p>Harder to fake, which is why sceptics read it first</p><p>There’s an old line in finance: profit is an opinion, cash is a fact. Keep it in mind. It explains both Wirecard and a scandal from India we’ll open in Clue 3.</p><h3>Same company, different rulebook, different profit</h3><p>Accounting standards decide how each row gets written. The US uses GAAP, set by the FASB. Most of the world uses IFRS, set by the IASB, and India uses Ind AS, which is built on IFRS.</p><p>The differences are not trivia. US GAAP allows the LIFO inventory method; IFRS bans it. IFRS lets companies capitalise some development costs once strict tests are met; US GAAP mostly forces them to be expensed.</p><p>So the same factory, in the same year, can report different profits depending on the rulebook. Numbers in finance are not simply counted. They are judged, and wherever there is judgement, there is room to push.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*lxzcvgxTBOAGCAZA6Kk67A.png" /></figure><p>Auditors walk this chain both ways: tracing forward from source documents finds what’s missing, and vouching backward from the statements proves that what’s there is real.</p><p>That chain has a lot of hands on it. So who’s watching each link?</p><h3>Clue 2: The watchers</h3><p>No single person makes sure the numbers are real. A stack of watchers does, and each layer is designed to distrust the one below it.</p><h3>Layer one: controls built into the work</h3><p>The first defence is boring on purpose. It’s called internal control: rules wired into everyday processes so mistakes and theft get blocked before anyone needs to investigate.</p><p>The classic example is segregation of duties. The person who adds a new vendor to the system should never be the person who approves that vendor’s payments. Put both powers in one pair of hands and you’ve built a machine for paying fake suppliers.</p><p>Other everyday controls include a second person checking every payment (maker-checker), approval limits, monthly bank reconciliations and tight control over who can log in to what. Most large companies organise all this using the COSO framework, which starts with something you can’t automate: the tone at the top.</p><h3>Layers two and three: the company checks itself</h3><p>Risk and compliance teams set the rules and watch for breaches, from anti-money-laundering checks to sanctions screening. Internal audit then tests whether everyone is actually following those rules.</p><p>The key design choice: internal audit reports to the board’s audit committee, not to the CFO whose numbers it checks. The Institute of Internal Auditors calls this structure the Three Lines Model.</p><h3>Outside the walls</h3><p>The external auditor is an independent firm, usually one of the Big Four, that gives a formal opinion on whether the financial statements are fair. The audit committee, made of independent directors, hires that firm and grills it.</p><p>Above them sit the regulators: the SEC and PCAOB in the US, the FRC in the UK, SEBI and the NFRA in India. And outside the official system are the unofficial watchers: short sellers, journalists, analysts and whistleblowers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*iRawM6CWNYOF9UsqUIdb1A.png" /></figure><p>Follow the arrows: internal audit reports up to the board, not sideways to management, and the auditor answers to the audit committee rather than the CFO whose numbers it tests.</p><blockquote><strong><em>Pause and guess:</em></strong><em> which of these layers catches the most fraud? Hold that answer. The data lands in Clue 5, and almost everyone guesses wrong.</em></blockquote><h3>Clue 3: Every audit rule is a scar</h3><p>Almost every major audit rule exists because a specific company blew up. Read the rulebook closely and you’re walking through a museum of disasters.</p><h3>Case file: Enron, 2001</h3><p>Enron was America’s energy-trading superstar. It hid debt in off-the-books partnerships and booked profits it only hoped to earn years later. When it filed for bankruptcy in December 2001, its auditor, Arthur Andersen, was caught shredding Enron documents.</p><p>Andersen was convicted of obstruction of justice in 2002. The Supreme Court overturned that verdict in 2005, but by then the firm had already collapsed, taking tens of thousands of jobs with it. The Big Five became the Big Four.</p><h3>Case file: WorldCom, 2002</h3><p>Months later, WorldCom’s head of internal audit, Cynthia Cooper, spotted something odd. Ordinary running costs, fees paid to use other companies’ networks, had been reclassified as long-term investments. That one trick made expenses vanish and profit appear.</p><p>Her small team dug through the records, often at night, and traced $3.8 billion of it. WorldCom filed for bankruptcy in July 2002, the largest in US history at the time, and the final tally grew to roughly $11 billion.</p><p>Notice who caught it. Not the outside auditor (Arthur Andersen, again), but the company’s own internal audit team. Keep that in mind for Clue 5.</p><h3>The law that followed: Sarbanes-Oxley</h3><p>Nine days after WorldCom went bankrupt, the US signed the Sarbanes-Oxley Act, usually called SOX. It is still the backbone of corporate accountability in America.</p><p>Part of SOX</p><p>What it does</p><p>In plain English</p><p>Section 302</p><p>The CEO and CFO personally certify every periodic report</p><p>“I signed it, I own it”</p><p>Section 404</p><p>Management must assess its internal controls over financial reporting; for larger companies, the auditor tests them too</p><p>“Prove your controls actually work”</p><p>Section 906</p><p>Criminal penalties for knowingly false certifications, up to 20 years in prison for wilful ones</p><p>“Lie on this and you can go to jail”</p><p>Title I</p><p>Created the PCAOB to inspect and discipline audit firms</p><p>“The auditors now have auditors”</p><h3>Case file: Satyam, 2009</h3><p>On January 7, 2009, Ramalinga Raju, chairman of Satyam Computer Services, one of India’s largest IT firms, confessed in a letter. Satyam’s books showed over $1 billion in cash and bank balances. The real figure was $66 million. Raju compared it to riding a tiger he couldn’t get off without being eaten.</p><p>The SEC later laid out how the auditors missed it. PwC’s Indian affiliates let Satyam’s own managers mail out and collect the bank confirmations. In one year, Citibank directly confirmed a balance of about $330,000, while papers supplied by Satyam claimed $153 million at the same bank. The audit team filed both as genuine.</p><p>A PwC partner from outside India even warned the team in 2008: “We can only take credit for confirms we send and receive directly.” The SEC found that acting on that warning could have exposed the fraud that summer. In 2011, PwC’s India affiliates paid $7.5 million to US regulators.</p><p>India’s answer was the Companies Act 2013, which forced listed companies to rotate their auditors and made auditors report on internal financial controls. In 2018 it added an independent audit regulator, the National Financial Reporting Authority.</p><h3>Plot twist: Wirecard ran the same play</h3><p>Eleven years after Satyam, on another continent, Wirecard pulled almost the same trick: cash that didn’t exist, backed by documents that didn’t come straight from the bank.</p><p>So who exposed it? Not the auditor and not the regulator. The <em>Financial Times</em> had been publishing investigations for years, fed by whistleblowers and short sellers. Germany’s financial regulator, BaFin, spent that time probing the short sellers and journalists instead, even banning bets against Wirecard’s shares for two months in 2019.</p><p>Germany’s response came in 2021: listed companies must now rotate auditors after ten years, auditors face tighter limits on selling consulting to the companies they audit, and the regulator got sharper teeth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*uUGCccXYyO3Jxbb0kvlejA.png" /></figure><p>The pattern holds on three continents: the rules arrive after the damage, never before it.</p><p>Rules tell auditors what to do. But what does an audit actually look like from the inside? It’s not what most people picture.</p><h3>Clue 4: Inside an audit</h3><p>An audit does not check every transaction, and it does not guarantee there’s no fraud. It gives <em>reasonable assurance</em> that the financial statements are free of <em>material</em> misstatement, whether caused by error or fraud.</p><p>That sentence is the most misunderstood idea in finance. The gap between what the public thinks auditors do and what audits are built to do even has a name: the expectation gap.</p><h3>Materiality: what’s big enough to matter</h3><p>Auditors hunt for errors large enough to change a reasonable investor’s decision. A common starting point is about 5% of pre-tax profit. For a company earning $1 billion before tax, that puts the line near $50 million, so a $500 typo will never move the opinion.</p><p>They also aim their effort where the risk is. Auditing standards presume a fraud risk in how revenue is recognised, and treat management overriding its own controls as a risk in every single audit.</p><h3>Five questions behind every big number</h3><p>The question</p><p>Auditor’s term</p><p>How they test it</p><p>Is it real?</p><p>Existence</p><p>Confirm directly with the bank or customer; count the inventory</p><p>Is anything missing?</p><p>Completeness</p><p>Trace source documents into the ledger; hunt for unrecorded bills</p><p>Is the amount right?</p><p>Valuation</p><p>Recalculate; challenge estimates like bad debts and impairments</p><p>Does the company own it?</p><p>Rights and obligations</p><p>Read contracts, titles and loan agreements</p><p>Is it in the right period?</p><p>Cut-off</p><p>Check sales and shipments either side of year end</p><p>Then comes the rule that Satyam and Wirecard both broke: evidence the auditor gets directly from an independent outsider beats anything the client hands over. A bank confirmation the auditor sends and receives is gold. A PDF the client forwards is a rumour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*UaA7SiAOm3_dAhdch8wkjQ.png" /></figure><p>The fork in the middle decides how hard the rest of the audit is: strong controls let auditors lean on the system, weak ones force them to check far more of the underlying transactions.</p><h3>The four possible verdicts</h3><p>Opinion</p><p>What it says</p><p>What it signals</p><p>Unmodified (“clean”)</p><p>The statements are fairly presented</p><p>The default, and still not a guarantee</p><p>Qualified</p><p>Fair, except for one specific problem</p><p>A contained issue worth reading about</p><p>Adverse</p><p>The statements are materially wrong</p><p>Don’t rely on these numbers</p><p>Disclaimer</p><p>The auditor couldn’t get enough evidence to form a view</p><p>A serious red flag</p><p>And here’s the uncomfortable part: the people cooking the books know exactly where auditors look.</p><h3>Clue 5: Why people cook the books, and what really catches them</h3><p>Fraud needs three things at the same time: pressure, opportunity and a story the fraudster tells themselves. The criminologist Donald Cressey mapped this in the 1950s, and it’s still called the fraud triangle.</p><p>Pressure is a target to hit, a debt, a bonus. Opportunity is a weak control, or the power to override one. The story sounds like “I’ll pay it back” or “it’s just this quarter.”</p><p>Companies can’t read minds, so they attack the one side they control: opportunity. In the world’s largest fraud study, the ACFE’s <em>Occupational Fraud 2026</em> report, more than half of frauds happened because controls were missing (33%) or overridden (19%).</p><h3>Three flavours of fraud</h3><p>Type</p><p>What it looks like</p><p>Share of cases</p><p>Median loss</p><p>Asset misappropriation</p><p>Fake vendor invoices, stolen stock, padded expenses</p><p>90%</p><p>$100,000</p><p>Corruption</p><p>Bribes, kickbacks, hidden conflicts of interest</p><p>45%</p><p>$150,000</p><p>Financial statement fraud</p><p>Invented revenue, hidden debt, fake cash</p><p>6%</p><p>$1,000,000</p><p>Shares add up to more than 100% because many schemes mix types. The pattern to notice: the rarest kind, cooking the books themselves, does ten times the damage of the most common kind. And the higher the fraudster sits, the bigger the hole: owners and executives caused median losses more than nine times those of regular staff.</p><h3>The answer to the pause-and-guess</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*1xxwkjADlJ-5JqlDOJBrLA.png" /></figure><p>Tips. Not auditors, not algorithms: 43% of frauds were first exposed by someone speaking up, and more than half of those tips came from employees. The layer most people guess, the external auditor, sits near the bottom of the list.</p><p>That’s not quite the scandal it sounds like. External audits are designed to catch material misstatements in the accounts, not every employee padding an expense claim. But it should change how you picture the system: Cynthia Cooper at WorldCom and the Wirecard whistleblowers were the rule, not the exception.</p><p>Two more numbers from the study set up what comes next. Frauds caught within six months had a median loss of $40,000; those running over five years cost $1.1 million. And organisations using proactive data monitoring had median losses 53% lower, yet only about half of victim organisations had it.</p><p>So what happens when auditors stop sampling and start watching every single transaction?</p><h3>Clue 6: The machines arrive</h3><p>Technology is flipping audit from checking a sample to checking everything. The old way: pick 60 invoices out of two million, test them by hand, extrapolate. The new way: pull all two million from the ERP and let software surface the strange ones for a human to chase.</p><h3>ERP: where the truth lives</h3><p>ERP (enterprise resource planning) systems such as SAP S/4HANA, Oracle and Microsoft Dynamics run orders, inventory, payroll and the general ledger in one database. Every click leaves a timestamped trail.</p><p>That’s why auditors test IT general controls: who can log in, how changes reach the live system and whether anyone can edit data directly. At Satyam, managers used a “super user” function to slip thousands of fake invoices past normal billing controls. The auditors’ own IT testing had flagged more than 170 control deficiencies well before the confession.</p><h3>Data analytics: test the whole population</h3><p>With every journal entry in hand, auditors filter for the patterns fraud leaves behind:</p><p>Red flag</p><p>Why it’s suspicious</p><p>Posted at 2 a.m., on a weekend or a holiday</p><p>Real business rarely happens then; cover-ups often do</p><p>Posted by an unusual user, like a senior executive or IT admin</p><p>People who never book entries shouldn’t suddenly start</p><p>Perfectly round amounts, like 5,000,000.00</p><p>Real invoices are messy; invented numbers are tidy</p><p>Just under an approval limit, like 9,950 against a 10,000 limit</p><p>The classic way to dodge a second signature</p><p>Manual entries to revenue in the last days of a quarter</p><p>Where earnings get “managed”</p><p>Blank or vague descriptions, like “adjustment”</p><p>Nobody wanted to explain it</p><p>Reversed right after the period closes</p><p>Booked to hit a target, then quietly undone</p><h3>OCR and document AI: reading the paper trail</h3><p>OCR turns scanned invoices, contracts and bank statements into data. Document AI then pulls out vendor, amount, date and terms and matches them against the ERP at scale: purchase order, goods receipt and invoice, checked for every transaction instead of a sample.</p><p>It matters because paper is the fraudster’s favourite hiding place. In the ACFE study, creating fake physical documents was the most common way frauds were concealed, in 39% of cases. But a perfect scan of a forged bank letter is still forged, which is why the confirmation itself must come straight from the bank.</p><h3>Process mining: an X-ray of how work really flows</h3><p>Every ERP event carries a case ID, an activity and a timestamp. Process mining stitches those events into a map of how a process actually runs, then compares it with how the policy says it should run. Tools include Celonis, SAP Signavio and the open-source PM4Py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*DTH_NUubB-jP7SpnzOrgIg.png" /></figure><p>Each red line is a pattern auditors hunt for: orders raised after the invoice arrives, payments with no approval, supplier bank details changed right before a payment, and the same invoice paid twice.</p><h3>The 145-year-old law that catches liars</h3><p>In 1881, the astronomer Simon Newcomb noticed that the early pages of logarithm books were more worn than the later ones. People looked up numbers starting with 1 far more often than numbers starting with 9.</p><p>In 1938, the physicist Frank Benford confirmed it across thousands of real-world numbers. In many natural datasets, from invoice amounts to city populations, the first digit follows this rule:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yT7z0ThLea-iIDjyBD_pcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*txszGN9y9vz_BnjE-TlDIQ.png" /></figure><p>Humans inventing numbers tend to spread first digits far too evenly, and that shows up instantly against the curve. Forensic accountants have used the test since the 1990s. It has limits: it doesn’t fit assigned numbers like invoice IDs, capped amounts or small samples, so a mismatch is a reason to dig, never proof on its own.</p><p>Modern tools go further. Machine learning models learn what “normal” looks like for each account and flag outliers. Graph analytics connect vendors, employees, addresses and bank accounts, so a supplier sharing a bank account with someone in purchasing lights up immediately.</p><h3>Continuous auditing: from annual photo to live feed</h3><p>A traditional audit is a photograph taken once a year. Continuous auditing is CCTV: controls are tested automatically every day, and every exception lands in front of a person within hours instead of months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*DDVNloCuajxlBRiR99CSGg.png" /></figure><p>The software decides what deserves a look; a person still decides what it means, and every investigated alert feeds back into sharper rules.</p><p>The Big Four have built their own versions of this stack: Deloitte’s Omnia, EY’s Canvas and Helix, KPMG’s Clara and PwC’s Aura and Halo. Each one ingests a client’s ledger data and runs analytics across all of it.</p><p>Now point the same machinery at money moving between banks and across borders.</p><h3>Clue 7: Follow the money</h3><p>A financial statement audit asks whether a company’s numbers are real. Anti-money laundering (AML) asks a different question: is the money itself clean? Banks are legally required to answer it, on every customer and every transaction.</p><h3>KYC: know who you’re dealing with</h3><p>Before an account opens, Know Your Customer (KYC) checks kick in. The bank verifies the person’s identity, often using OCR on an ID document plus a live selfie match. For a company, it has to find the beneficial owner: the human who actually controls it, behind any chain of shell companies.</p><p>Every customer is screened against sanctions lists and lists of politically exposed persons, then given a risk rating. Higher risk means enhanced due diligence: more documents, more questions and closer monitoring.</p><h3>AML: watch the flow</h3><p>Laundering classically moves in three stages. Placement gets dirty cash into the system, layering shuffles it around to blur the trail, and integration brings it back looking legitimate.</p><p>Monitoring systems hunt for the fingerprints. Structuring means many deposits kept just under a reporting threshold, like the $10,000 cash-reporting line in the US. Money arrives and leaves within hours, mule accounts appear, and trade invoices get priced far above or below market.</p><p>Alerts go to human investigators. When suspicion holds up, the bank files a report with the national financial intelligence unit, such as FinCEN in the US or FIU-IND in India. Rule-based systems throw off huge numbers of false alarms, so banks increasingly use machine learning and network analysis to rank which alerts matter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlP7O9PIGS7Z9dDuXngG7w.png" /></figure><p>The left column runs once per customer; the right one never stops, and every false alarm that gets closed is a chance to sharpen the rules.</p><h3>Case file: TD Bank, 2024</h3><p>In October 2024, TD Bank became the largest bank in US history to plead guilty to Bank Secrecy Act program failures, with penalties of about $3 billion. Prosecutors said it left $18.3 trillion of customer activity unmonitored over six years. Three laundering networks moved more than $670 million through its accounts.</p><p>When a suspected trafficker bought more than $1 million in bank checks with cash in a single day, one employee asked a colleague whether that was laundering. The reply: “Oh, it 100% is.”</p><p>The lesson is the same one Satyam and Wirecard taught, just in a different building. The best monitoring system in the world is worthless if it isn’t switched on, funded and acted upon.</p><p>So who builds all this machinery, and who gets paid to check it? Meet the firms.</p><h3>Clue 8: The firms</h3><p>Four firms, Deloitte, PwC, EY and KPMG, audit the vast majority of the world’s biggest listed companies. And if you’ve been paying attention, every one of them has already appeared in this episode.</p><p>Firm</p><p>Audit tech platform</p><p>Where it showed up in this story</p><p>Deloitte</p><p>Omnia</p><p>Coming up in Clue 9, on the wrong side of an AI mistake</p><p>PwC</p><p>Aura and Halo</p><p>Its India affiliates audited Satyam</p><p>EY</p><p>Canvas and Helix</p><p>Wirecard’s auditor, until it refused to sign the 2019 accounts</p><p>KPMG</p><p>Clara</p><p>Replaced Andersen at WorldCom in 2002, and ran the 2020 special investigation into Wirecard</p><p>None of that makes them villains. Failures are simply the audits that make headlines. What it does show is how concentrated the system is: when trust in finance is on the line, it usually runs through one of four logos.</p><p>Here’s the tension inside all four. Audit is no longer their biggest business; tax, consulting and advisory are. So can you audit a company objectively while selling it lucrative consulting work? SOX banned many such services for US audit clients, and EY even planned to split its audit and consulting arms before calling the plan off in 2023.</p><h3>Plot twist: Accenture</h3><p>Accenture is not an auditor. It doesn’t sign audit opinions. But it’s on this week’s list for a reason most people have never heard.</p><p>Accenture began life as Andersen Consulting, the consulting arm of Arthur Andersen. After years of bitter fighting, an arbitrator ruled in August 2000 that it could break away, but had to give up the Andersen name by January 1, 2001. It became Accenture that day.</p><p>Less than a year later, Enron collapsed and dragged Arthur Andersen down with it. The child escaped the parent’s fate by a matter of months.</p><p>Today Accenture is one of the biggest builders of the systems auditors check: ERP rollouts, finance transformations, risk and compliance platforms and outsourced financial-crime operations for banks. It has grown from 65,000 people at the split to around 779,000.</p><p>Which brings us to the newest system everyone is racing to build, and a question nobody has fully answered yet: who audits the AI?</p><h3>Clue 9: Who audits the AI?</h3><p>AI is making audits faster and more complete, and it’s creating brand-new things that need auditing: the models themselves, and the fakes they make possible.</p><p>The upside is real. Software can now read every contract, invoice and board minute, draft working papers and flag anomalies across an entire ledger overnight. The catch is that AI can be confidently, fluently wrong, and so can the people who trust it.</p><h3>Case file: the report that cited books that don’t exist</h3><p>In October 2025, Deloitte Australia agreed to partially refund an A$440,000 fee to the Australian government. Its 237-page report contained apparent AI-generated errors, including references to research that doesn’t exist and a fabricated quote from a federal court judgment.</p><p>The revised version disclosed that a generative AI system, Azure OpenAI, had been used in writing it. The academic who caught the errors, Chris Rudge, pointed out that the report was effectively an audit of the department’s legal compliance. The checkers needed checking.</p><h3>Case file: the CFO who wasn’t there</h3><p>In early 2024, a finance worker in the Hong Kong office of engineering firm Arup joined a video call with people who looked and sounded like the company’s CFO and colleagues. Every one of them was a deepfake.</p><p>He went on to make 15 transfers totalling HK$200 million, about $25.6 million. Notice what actually failed: not the technology, but a payment control that a convincing face could unlock.</p><h3>The new risks, and the controls that stop them</h3><p>Risk</p><p>What it looks like</p><p>The control that stops it</p><p>Hallucination</p><p>Invented citations or quotes in a report</p><p>A human checks every source; AI use is disclosed</p><p>Deepfakes</p><p>A “CFO” on video ordering an urgent, secret transfer</p><p>Call back on a known number; two approvers for big payments</p><p>Black-box flags</p><p>“The model said so” sitting in an audit file</p><p>Documented reasoning another auditor can re-perform</p><p>Automation bias</p><p>Accepting the green tick without looking</p><p>Re-test a sample by hand; rotate who reviews</p><p>Bad data in</p><p>A model analysing a ledger someone can edit directly</p><p>IT controls over access and changes</p><p>That fourth row is Satyam all over again. The SEC found PwC India’s team trusted Satyam’s paperwork largely because they believed its leaders were honest. Swap “leaders” for “the algorithm” and you have the AI-era version of the same mistake.</p><p>Which is why the one audit skill that doesn’t automate is professional scepticism: the habit of asking “how do I actually know this is true?” and refusing to accept a document just because it looks official.</p><p>So let’s finally answer the question we started with.</p><h3>The verdict: who makes sure the numbers are real?</h3><p>Nobody, on their own. The financial world doesn’t run on trust; it runs on organised distrust, layer after layer of people and machines whose job is to try to prove the numbers false.</p><p>Safety engineers have a picture for this, borrowed from accident investigation: the Swiss cheese model. Every layer of defence is a slice with holes in it. A disaster only gets through when the holes in every slice happen to line up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzr8cdDlP0THkQa_J9pVkg.png" /></figure><p>Wirecard is the textbook case. Bank balances were never confirmed at the source, the regulator was looking at the critics, and much of the business sat with third-party partners nobody could see into. The holes lined up for years, until journalists and whistleblowers, a slice outside the official stack, finally blocked the path.</p><p>So here’s the answer to this week’s big question. <strong>A number becomes real when enough independent people, and now machines, have tried to prove it false and failed.</strong></p><p>That’s why independence matters so much: internal audit reporting to the board instead of the CFO, and auditors confirming cash with the bank instead of the client. And it’s why the single most effective fraud detector in the data isn’t software at all. It’s someone deciding to speak up.</p><h3>Your turn</h3><p>Which slice of the cheese do you think is weakest right now: the companies, the auditors or the regulators? And will AI close the holes, or punch new ones? Drop your answer in the comments.</p><p>If this changed how you’ll read the next “clean audit opinion” headline, send it to the one friend who still thinks auditors check every transaction.</p><p><strong>Next week, Week 06:</strong> [add next week’s topic and a one-line hook here].</p><h3>Sources</h3><ul><li><a href="https://www.acfe-mexico.com.mx/inicio/sitepad-data/uploads/2026/07/Reporte-a-las-Naciones-2026.pdf">ACFE, <em>Occupational Fraud 2026: A Report to the Nations</em></a>: fraud types, losses, detection methods and controls</li><li><a href="https://www.malaymail.com/news/money/2020/06/22/wirecard-thinks-us2.1b-was-a-fiction-in-growing-disaster/1877903">Reuters via Malay Mail, “Wirecard thinks US$2.1b was a fiction in growing ‘disaster’” (June 22, 2020)</a></li><li><a href="https://www.everycrsreport.com/reports/RS21253.html">Congressional Research Service, <em>WorldCom: The Accounting Scandal</em> (RS21253, August 2002)</a></li><li><a href="https://www.sec.gov/news/press/2011/2011-82.htm">SEC press release 2011–82, “SEC Charges India-Based Affiliates of PWC for Role in Satyam Accounting Fraud”</a></li><li><a href="https://www.sec.gov/litigation/admin/2011/34-64184.pdf">SEC order, Release №64184 (April 5, 2011)</a>: Satyam’s confirmations, the Citibank figures, the super-user invoices and the IT control findings</li><li><a href="https://newjerseymonitor.com/2024/10/10/feds-hit-td-bank-with-3b-in-penalties-for-money-laundering-scheme-benefitting-drug-traffickers/">New Jersey Monitor, “Feds hit TD Bank with $3B in penalties” (October 10, 2024)</a></li><li><a href="https://dc.fortune.com/2025/10/26/the-story-behind-accenture-name-arthur-andersen-25th-anniversary/">Fortune, “The 25th-anniversary story of Accenture’s name” (October 26, 2025)</a></li><li><a href="https://ny1.com/nyc/all-boroughs/ap-top-news/2025/10/07/deloitte-to-partially-refund-australian-government-for-report-with-apparent-ai-generated-errors">AP via NY1, “Deloitte to partially refund Australian government for report with apparent AI-generated errors” (October 7, 2025)</a></li><li><a href="https://edition.cnn.com/2024/05/16/tech/arup-deepfake-scam-loss-hong-kong-intl-hnk">CNN, “British engineering giant Arup revealed as $25 million deepfake scam victim” (May 16, 2024)</a></li></ul><p>Background on Enron, Sarbanes-Oxley, COSO, the Three Lines Model, Benford’s law and the post-scandal laws in India and Germany is drawn from general knowledge rather than the pages above.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07e4d4aabc23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WEEK 04 — Debt, Securities & Wall Street]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/week-04-debt-securities-wall-street-e3207579cc1b?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3207579cc1b</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 15:22:44 GMT</pubDate>
            <atom:updated>2026-09-15T15:22:44.797Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFI0UQe5V3wux2zGRDKAjw.png" /></figure><h3>How Do You Turn an Idea Into Billions of Dollars?</h3><p>A company can have the best idea in the world.</p><p>It can have brilliant engineers, millions of users and a market that could be worth hundreds of billions of dollars.</p><p>But there is a problem.</p><p><strong>Building the future is expensive.</strong></p><p>A company might need $500 million to build factories.</p><p>$2 billion to acquire another company.</p><p>$10 billion to build data centers.</p><p>Or $50 billion to expand globally.</p><p>So where does all that money come from?</p><p>This is where Wall Street gets interesting.</p><p>Because Wall Street isn’t really about people shouting <em>“Buy!”</em> and <em>“Sell!”</em> on a trading floor.</p><p>At its core, Wall Street is about one thing:</p><blockquote><strong><em>Moving capital from people who have it to people who can put it to work.</em></strong></blockquote><p>And behind that simple idea sits one of the most complicated pieces of financial and technological infrastructure ever built.</p><h3>Imagine You Built the Next Big AI Company</h3><p>Let’s say you’ve built a company called <strong>NovaAI</strong>.</p><p>Your model is incredible.</p><p>Microsoft wants to use it.</p><p>Banks want to deploy it.</p><p>Millions of people are using your product.</p><p>Now you have a different problem.</p><p>You need <strong>$5 billion</strong>.</p><p>You could try to raise money from private investors.</p><p>You could sell part of the company.</p><p>You could borrow money.</p><p>You could go public.</p><p>You could acquire another company.</p><p>Or you could use some combination of all of them.</p><p>Suddenly, building an AI company isn’t just an engineering problem anymore.</p><p>It’s a <strong>capital problem</strong>.</p><p>And this is where firms like Goldman Sachs, JPMorgan and Morgan Stanley enter the picture.</p><h3>The People Who Move Billions</h3><p>If you’ve ever wondered what investment banks actually <em>do</em>, this is probably the simplest way to think about them:</p><p><strong>They help companies, governments and investors navigate the capital markets.</strong></p><p>A company needs money.</p><p>An investor has money.</p><p>The investment bank helps connect the two.</p><p>But doing that at the scale of billions of dollars is incredibly complicated.</p><p>Goldman Sachs, for example, works across IPOs, debt financing, leveraged finance, derivatives, structured finance and M&amp;A.</p><p>JPMorgan’s capital-markets business works across both equity and debt, including IPOs, bond offerings, leveraged finance and large-scale capital raises.</p><p>Morgan Stanley does much of the same, advising companies and governments on M&amp;A, IPOs, debt offerings, restructurings and other capital-raising transactions.</p><p>But let’s make this real.</p><h3>Apple Needs $10 Billion. What Happens?</h3><p>Imagine Apple wants to build a massive new manufacturing facility.</p><p>It needs $10 billion.</p><p>Apple has two broad choices.</p><h3>Option 1: Sell ownership</h3><p>Apple could issue new shares.</p><p>Investors give Apple money.</p><p>In return, investors receive a piece of Apple.</p><p>That’s <strong>equity</strong>.</p><h3>Option 2: Borrow money</h3><p>Apple could issue bonds.</p><p>Investors give Apple money.</p><p>Apple promises to pay interest and eventually return the principal.</p><p>That’s <strong>debt</strong>.</p><p>And that tiny distinction is one of the foundations of modern finance.</p><p><strong>Equity = ownership.</strong></p><p><strong>Debt = borrowing.</strong></p><h3>So What Exactly Is a Bond?</h3><p>Think of a bond as an IOU that can be bought and sold.</p><p>You lend a company ₹1,000.</p><p>The company says:</p><blockquote><em>“I’ll pay you interest every year and give your ₹1,000 back after 10 years.”</em></blockquote><p>That’s basically a bond.</p><p>Now multiply that by billions.</p><p>A company can issue:</p><p><strong>$5 billion of 10-year bonds</strong></p><p>and suddenly thousands of institutional investors can lend money to that company.</p><p>Those investors might include:</p><ul><li>Pension funds</li><li>Insurance companies</li><li>Mutual funds</li><li>Asset managers</li><li>Sovereign wealth funds</li><li>Banks</li><li>Hedge funds</li></ul><p>This is <strong>fixed income</strong>.</p><p>And it is one of the biggest parts of global financial markets.</p><p>JPMorgan’s debt-capital-markets business, for example, combines debt structuring with distribution to investors and works on everything from ordinary bond refinancing to multi-billion-dollar financings.</p><h3>But Why Would Anyone Lend Billions to a Company?</h3><p>Because someone has to put their money somewhere.</p><p>Imagine you’re running a pension fund with <strong>$100 billion</strong>.</p><p>You don’t want all of that money sitting in cash.</p><p>You need investments that can generate returns while matching your future obligations.</p><p>So you might buy:</p><p><strong>Government bonds</strong></p><p><strong>Corporate bonds</strong></p><p><strong>Stocks</strong></p><p><strong>Mortgage-backed securities</strong></p><p>and many other financial assets.</p><p>And this creates a giant loop:</p><blockquote><em>Companies need money → Investors have money → Markets connect them.</em></blockquote><p>That’s the capital market.</p><h3>Then Comes the IPO</h3><p>Now let’s say NovaAI becomes enormous.</p><p>It has billions in revenue.</p><p>Investors want to own a piece of it.</p><p>The founders decide:</p><blockquote><strong><em>We’re going public.</em></strong></blockquote><p>Welcome to the <strong>IPO</strong>.</p><p>An Initial Public Offering is essentially the moment a private company starts selling shares to public investors.</p><p>But here’s the part most people don’t see.</p><p>An IPO isn’t simply:</p><blockquote><em>“Put the company on the stock exchange.”</em></blockquote><p>There is an enormous amount of work behind it.</p><p>Investment banks help with:</p><p><strong>Valuation</strong></p><p>↓<br><strong>Structuring</strong></p><p>↓<br><strong>Regulatory process</strong></p><p>↓<br><strong>Investor demand</strong></p><p>↓<br><strong>Pricing</strong></p><p>↓<br><strong>Allocation</strong></p><p>↓<br><strong>Market launch</strong></p><p>This is why you’ll often hear about Goldman Sachs, JPMorgan or Morgan Stanley being the <strong>lead bookrunner</strong> or <strong>underwriter</strong> on an IPO.</p><p>JPMorgan, for example, describes its equity-capital-markets business as covering IPOs, common-stock offerings, convertibles and private placements.</p><h3>And Then There Is M&amp;A</h3><p>Now imagine NovaAI looks at another company and says:</p><blockquote><em>“Instead of spending five years building this technology ourselves, why don’t we just buy the company?”</em></blockquote><p>The company costs <strong>$8 billion</strong>.</p><p>Now you have an acquisition.</p><p>That’s <strong>M&amp;A — Mergers &amp; Acquisitions</strong>.</p><p>But where does the $8 billion come from?</p><p>Maybe:</p><p>$3B → Cash</p><p>$2B → New debt</p><p>$3B → Shares</p><p>Suddenly, buying another company becomes a financial-engineering problem.</p><p>How much is the company actually worth?</p><p>Should NovaAI pay cash?</p><p>Should it borrow?</p><p>Should it issue shares?</p><p>How will the acquisition affect earnings?</p><p>Can the combined companies create enough value?</p><p>Investment banks spend enormous amounts of time answering questions like these.</p><p>Goldman Sachs, for example, advises clients on acquisitions, divestitures, restructurings, spin-offs and other complex transactions.</p><p>Morgan Stanley similarly works on acquisitions, mergers, joint ventures, restructurings, leveraged buyouts and other strategic transactions.</p><p>So when you see a headline saying:</p><blockquote><strong><em>“Company X acquires Company Y for $20 billion.”</em></strong></blockquote><p>there is usually an entire army of bankers, lawyers, accountants, investors, engineers and risk teams behind that one sentence.</p><h3>The Part That Gets Really Interesting: Securitization</h3><p>Now let’s move away from companies.</p><p>Imagine a bank has <strong>100,000 mortgages</strong>.</p><p>Each homeowner pays the bank every month.</p><p>Instead of keeping all those loans on its balance sheet, the financial system can pool similar loans together and create securities backed by those cash flows.</p><p>Investors can then buy those securities.</p><p>That’s <strong>securitization</strong>.</p><p>The basic idea is:</p><p><strong>Loans</strong></p><p>↓</p><p><strong>Pool the loans</strong></p><p>↓</p><p><strong>Structure the cash flows</strong></p><p>↓</p><p><strong>Create securities</strong></p><p>↓</p><p><strong>Sell them to investors</strong></p><p>Goldman Sachs, for example, describes structured finance as financing backed by assets and cash flows, including securitizations.</p><p>It’s a strange concept at first.</p><p>You’re essentially taking thousands of individual financial contracts and transforming them into something that can be packaged, priced and sold to investors.</p><p>And that’s one of the recurring themes of modern finance:</p><blockquote><strong><em>Turn cash flows into financial assets.</em></strong></blockquote><h3>Then We Get to Derivatives</h3><p>Now imagine you’re a company with $5 billion of debt.</p><p>Your interest payments depend on interest rates.</p><p>If rates suddenly rise, your costs could explode.</p><p>You don’t necessarily want to bet on interest rates.</p><p>You just want to <strong>reduce your risk</strong>.</p><p>That’s where derivatives come in.</p><p>An interest-rate swap, for example, can allow a company to exchange one type of interest-rate exposure for another.</p><p>Similarly, a multinational company might use currency derivatives to manage exposure to exchange-rate movements.</p><p>A commodity company might hedge oil prices.</p><p>A bank might hedge credit exposure.</p><p>So derivatives aren’t simply complicated financial bets.</p><p>A huge part of the institutional market is about one thing:</p><blockquote><strong><em>Managing risk.</em></strong></blockquote><p>Goldman Sachs specifically describes corporate derivatives as tools for managing exposure to interest rates, foreign exchange, commodities and credit spreads.</p><h3>Here’s Where Wall Street Becomes a Technology Company</h3><p>This is the part I find most interesting.</p><p>Because none of this can happen at global scale with spreadsheets and people making phone calls.</p><p>Imagine an institutional investor wants to buy:</p><p><strong>$500 million of Microsoft stock.</strong></p><p>You can’t necessarily dump $500 million into the market in one transaction.</p><p>You might move the price.</p><p>So the trading system needs to figure out:</p><ul><li>Where is the liquidity?</li><li>What’s the current spread?</li><li>How volatile is the stock?</li><li>How much market impact will the order create?</li><li>Which exchange should receive the order?</li><li>How quickly should the order be executed?</li><li>What’s the cheapest execution strategy?</li></ul><p>And suddenly, you need software.</p><p>A lot of software.</p><h3>The Wall Street Technology Stack</h3><p>Behind the scenes you’ll find things like:</p><h3>Market Data Systems</h3><p>Millions of prices and financial events flowing through systems every second.</p><h3>Pricing Engines</h3><p>Systems that calculate what financial instruments are worth.</p><h3>Risk Engines</h3><p>Systems that ask:</p><blockquote><em>“What happens to the bank if the market moves against us?”</em></blockquote><h3>Order Management Systems</h3><p>Systems that track and manage huge numbers of orders.</p><h3>Execution Algorithms</h3><p>Algorithms that determine how large orders should actually be executed.</p><h3>Trading Systems</h3><p>Infrastructure that connects banks and institutional investors to financial markets.</p><p>This is why engineering is such a huge part of modern finance.</p><p>Goldman Sachs itself describes engineering as being at the critical center of its businesses, while its institutional platform includes technology for market intelligence, pre-trade analytics, risk management and trading.</p><h3>And This Is Where JPMorgan Gets Interesting</h3><p>JPMorgan isn’t simply a bank where people deposit money.</p><p>Its institutional business touches:</p><p><strong>Investment banking</strong></p><p><strong>Fixed income</strong></p><p><strong>Equities</strong></p><p><strong>Foreign exchange</strong></p><p><strong>Commodities</strong></p><p><strong>Payments</strong></p><p><strong>Risk</strong></p><p><strong>Trading</strong></p><p><strong>Capital markets</strong></p><p>The scale is enormous.</p><p>And this gets to a point Jamie Dimon has made repeatedly about the importance of scale in banking.</p><p>The idea behind the quote you’re referring to is essentially:</p><blockquote><strong><em>“We fund countries. We fund the U.S. government. And for that, you need to be big.”</em></strong></blockquote><p>I would treat that as a <strong>paraphrase rather than a verified verbatim quote</strong>. What is clear from Dimon’s own shareholder letters is that he has repeatedly emphasized JPMorgan’s role in lending, capital markets, government relationships, technology and maintaining a very large balance sheet.</p><p>And the underlying idea is fascinating.</p><p>Because if you’re financing a small company, scale matters.</p><p>But if you’re helping finance:</p><p><strong>multinational corporations</strong></p><p><strong>governments</strong></p><p><strong>infrastructure</strong></p><p><strong>energy projects</strong></p><p><strong>large acquisitions</strong></p><p><strong>global trade</strong></p><p>then the financial institution itself becomes infrastructure.</p><p>You need capital.</p><p>You need technology.</p><p>You need risk systems.</p><p>You need global offices.</p><p>You need relationships with investors.</p><p>You need traders.</p><p>You need lawyers.</p><p>You need engineers.</p><p>You need the ability to move billions without the entire system falling apart.</p><p><strong>That’s what scale buys you.</strong></p><h3>Goldman Sachs, JPMorgan, Morgan Stanley — What’s the Difference?</h3><p>They overlap heavily, but it’s useful to understand what they’re known for.</p><h3>Goldman Sachs</h3><p>Think:</p><p><strong>M&amp;A + Capital Markets + Trading + Structuring</strong></p><p>Goldman is deeply involved in helping companies raise capital, execute acquisitions and manage financial risks. Its financing business spans equity, debt, leveraged finance, derivatives and structured finance.</p><h3>JPMorgan</h3><p>Think:</p><p><strong>Banking + Capital Markets + Markets + Massive Balance Sheet</strong></p><p>JPMorgan has one of the broadest financial footprints in the world, spanning consumer banking, commercial banking, investment banking, markets, payments and asset management.</p><p>Its capital-markets business works across both debt and equity financing.</p><h3>Morgan Stanley</h3><p>Think:</p><p><strong>Investment Banking + Trading + Wealth Management</strong></p><p>Morgan Stanley advises corporations, governments and institutions on M&amp;A and capital raising while also operating major sales-and-trading and wealth-management businesses.</p><h3>The Bigger Picture</h3><p>Now let’s go back to our fictional company.</p><p>Remember NovaAI?</p><p>It started with an idea.</p><p>Then:</p><p><strong>Idea</strong></p><p>↓</p><p><strong>Startup</strong></p><p>↓</p><p><strong>Investors</strong></p><p>↓</p><p><strong>Growth</strong></p><p>↓</p><p><strong>Debt / Equity</strong></p><p>↓</p><p><strong>IPO</strong></p><p>↓</p><p><strong>M&amp;A</strong></p><p>↓</p><p><strong>Global expansion</strong></p><p>↓</p><p><strong>Billions of dollars of capital</strong></p><p>And somewhere behind every step are financial institutions, investors, markets and technology.</p><p>That’s why I think the most interesting way to look at Wall Street isn’t:</p><blockquote><em>“People trading stocks.”</em></blockquote><p>It’s this:</p><blockquote><strong><em>Wall Street is the infrastructure that decides where enormous amounts of capital go.</em></strong></blockquote><p>A new AI company needs $10 billion?</p><p>Capital markets.</p><p>A government needs to raise money?</p><p>Bond markets.</p><p>A company wants to buy its competitor?</p><p>M&amp;A.</p><p>A pension fund wants stable returns?</p><p>Fixed income.</p><p>A bank wants to manage interest-rate exposure?</p><p>Derivatives.</p><p>An investor wants to execute a $500 million trade?</p><p>Trading systems and algorithmic execution.</p><p>A bank needs to know how much risk it is taking?</p><p>Risk engines.</p><p>Suddenly, all those terms from the beginning stop sounding like random finance vocabulary.</p><p>They become pieces of the same machine.</p><h3>The Big Question</h3><p>So, <strong>how does a company turn an idea into billions of dollars of capital?</strong></p><p>It doesn’t happen in one transaction.</p><p>It happens through an ecosystem.</p><p><strong>Entrepreneurs create ideas.</strong></p><p><strong>Companies create businesses.</strong></p><p><strong>Investment banks structure financing.</strong></p><p><strong>Markets connect borrowers and investors.</strong></p><p><strong>Investors provide capital.</strong></p><p><strong>Technology moves information and orders.</strong></p><p><strong>Risk systems keep the machine from blowing up.</strong></p><p>And eventually…</p><p>an idea that started in someone’s head can become a company worth billions.</p><p>That is the real story of Wall Street.</p><p>Not stocks.</p><p>Not suits.</p><p>Not trading floors.</p><p><strong>Capital.</strong></p><p>And the technology that moves it.</p><h3>WEEK 04 IN ONE LINE</h3><blockquote><strong><em>Wall Street is where ideas meet capital — and technology is the infrastructure that makes that meeting possible.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3207579cc1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WEEK 03 — THE MONEY BEHIND STARTUPS]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/week-03-the-money-behind-startups-9d77e44fb3b4?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d77e44fb3b4</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 13:39:32 GMT</pubDate>
            <atom:updated>2026-09-07T13:39:32.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsIJj37Mtg-NIeLZz2KPhA.png" /></figure><h3>The Big Question</h3><blockquote><strong><em>Where does the money that builds the next billion-dollar company actually come from?</em></strong></blockquote><p>A startup doesn’t usually become a billion-dollar company because someone simply “gives it money.”</p><p>There is an entire financial system behind it.</p><p>Founders raise capital from investors.</p><p>Investors negotiate ownership.</p><p>Lawyers structure the deal.</p><p>Financial models determine valuation.</p><p>Cap tables track who owns what.</p><p>And eventually, the company either gets acquired or goes public.</p><p><strong>So let’s follow the money.</strong></p><h3>01 — First: What Is Startup Capital?</h3><p>Imagine you start a company.</p><p>You need:</p><ul><li>₹20 lakh to build the first product</li><li>₹1 crore to hire a team</li><li>₹10 crore to scale</li><li>₹100 crore to expand internationally</li></ul><p>Where does that money come from?</p><p>There are two broad possibilities:</p><h3>Equity</h3><p>You give someone <strong>ownership</strong> in exchange for money.</p><h3>Debt</h3><p>You borrow money and promise to <strong>repay it</strong>, usually with interest.</p><p>This distinction is fundamental.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GnfQXb813pSpRSqO" /></figure><h3>02 — Equity vs Debt</h3><p>Suppose your startup is worth <strong>₹10 crore</strong>.</p><p>An investor gives you <strong>₹2 crore</strong>.</p><p>If it’s an equity investment, the investor might receive:</p><p><strong>₹2 crore / ₹12 crore = 16.67%</strong></p><p>The company now has:</p><p>Before investmentAfter investmentFounder100%Investor0%<strong>Total100%</strong></p><p>After investment:</p><p>ShareholderOwnershipFounder83.33%Investor16.67%<strong>Total100%</strong></p><p>The founder didn’t borrow ₹2 crore.</p><p>They <strong>sold part of the company.</strong></p><p>That’s equity.</p><h3>03 — Venture Capital</h3><p>This is where <strong>VC</strong> enters the picture.</p><p>A venture capital firm raises money from investors called <strong>Limited Partners (LPs)</strong>.</p><p>Those LPs can include:</p><ul><li>Pension funds</li><li>Endowments</li><li>Family offices</li><li>Sovereign wealth funds</li><li>Institutions</li><li>High-net-worth individuals</li></ul><p>The VC becomes the <strong>General Partner (GP)</strong> managing that fund.</p><p>The VC then invests the fund into startups.</p><p>So the money flow looks like:</p><pre>LPs<br>         │<br>         │ Capital<br>         ▼<br>   ┌─────────────┐<br>   │ VC FUND     │<br>   │             │<br>   │ Managed by  │<br>   │ GP / VC     │<br>   └──────┬──────┘<br>          │<br>          │ Investment<br>          ▼<br>      STARTUPS<br>       /  |  \<br>      /   |   \<br>     ▼    ▼    ▼<br>  Startup Startup Startup</pre><p>This is one of the most important diagrams in the entire week.</p><h3>04 — Venture Capital vs Private Equity</h3><p>They’re both investing in companies.</p><p>But they’re usually playing very different games.</p><h3>Venture Capital</h3><p>VC typically invests in <strong>high-growth startups</strong>.</p><p>The company may:</p><ul><li>Have limited revenue</li><li>Be unprofitable</li><li>Have enormous potential</li><li>Need capital to scale</li></ul><p>The investor is betting on <strong>future growth</strong>.</p><h3>Private Equity</h3><p>PE typically invests in <strong>more mature businesses</strong>.</p><p>The company may already have:</p><ul><li>Significant revenue</li><li>Predictable cash flows</li><li>Established operations</li></ul><p>PE often focuses heavily on improving the company’s operations and eventually selling its stake.</p><p>Think:</p><p><strong>VC → “What could this company become?”</strong></p><p><strong>PE → “How can we make this established company more valuable?”</strong></p><h3>05 — The Startup Funding Ladder</h3><p>A startup doesn’t normally jump directly from an idea to ₹500 crore.</p><p>Capital often arrives in stages.</p><pre>IDEA<br> │<br> ▼<br>Bootstrapping<br> │<br> ▼<br>Angel / Pre-seed<br> │<br> ▼<br>Seed<br> │<br> ▼<br>Series A<br> │<br> ▼<br>Series B<br> │<br> ▼<br>Series C+<br> │<br> ▼<br>Growth / PE<br> │<br> ▼<br>IPO / Acquisition</pre><p>Each round answers a different question.</p><h3>Pre-seed</h3><p><strong>Can we build something?</strong></p><h3>Seed</h3><p><strong>Does anyone actually want it?</strong></p><h3>Series A</h3><p><strong>Can this become a scalable business?</strong></p><h3>Series B</h3><p><strong>Can we scale it aggressively?</strong></p><h3>Later stages</h3><p><strong>Can this become a massive company?</strong></p><h3>06 — Valuation</h3><p>Now comes the fun part.</p><p>Someone says:</p><blockquote><em>“Your startup is worth ₹100 crore.”</em></blockquote><p>But what does that actually mean?</p><p>For startups, valuation isn’t simply:</p><p><strong>Revenue × some number</strong></p><p>It can involve:</p><ul><li>Revenue</li><li>Growth</li><li>Market size</li><li>Competition</li><li>Technology</li><li>Team</li><li>Unit economics</li><li>Future potential</li><li>Comparable companies</li><li>Investor demand</li></ul><p>And sometimes…</p><p><strong>negotiation.</strong></p><h3>07 — Pre-Money vs Post-Money</h3><p>This is where things get interesting.</p><p>Suppose:</p><p><strong>Pre-money valuation = ₹100 crore</strong></p><p>An investor invests:</p><p><strong>₹25 crore</strong></p><p>Then:</p><p><strong>Post-money = ₹125 crore</strong></p><p>Investor ownership:</p><p><strong>₹25 crore / ₹125 crore = 20%</strong></p><p>Founder ownership:</p><p><strong>80%</strong></p><p>Simple.</p><pre>PRE-MONEY<br>₹100 Cr<br>   +<br>INVESTMENT<br>₹25 Cr<br>   │<br>   ▼<br>POST-MONEY<br>₹125 Cr</pre><pre>Investor = 20%<br>Founders = 80%</pre><p>This distinction becomes extremely important when reading term sheets.</p><h3>08 — Dilution</h3><p>Now imagine the company raises another round.</p><p>The company is now worth:</p><p><strong>₹400 crore pre-money</strong></p><p>A new investor invests:</p><p><strong>₹100 crore</strong></p><p>Post-money:</p><p><strong>₹500 crore</strong></p><p>New investor:</p><p><strong>100 / 500 = 20%</strong></p><p>But here’s the interesting part.</p><p>The existing shareholders don’t necessarily lose shares.</p><p>They lose <strong>percentage ownership</strong>.</p><p>For example:</p><pre>BEFORE</pre><pre>Founder       80%<br>Investor      20%<br></pre><pre>NEW ROUND</pre><pre>Founder       64%<br>Old Investor  16%<br>New Investor  20%</pre><p>The founder went from <strong>80% → 64%</strong>.</p><p>That’s dilution.</p><p>But if the company grew from ₹125 crore to ₹500 crore, owning 64% of a much larger company can still be economically better.</p><p><strong>Dilution isn’t automatically bad.</strong></p><h3>09 — ESOPs</h3><p>Now we need employees.</p><p>Suppose you hire your first engineer.</p><p>You can’t compete with Google on salary.</p><p>So you offer:</p><blockquote><strong><em>Salary + ESOPs</em></strong></blockquote><p>ESOP = <strong>Employee Stock Option Plan</strong></p><p>You’re effectively saying:</p><blockquote><em>“If we build this company together and it becomes valuable, you’ll participate in that upside.”</em></blockquote><p>A startup might create an <strong>ESOP pool</strong> before or during a funding round.</p><p>This introduces another important concept:</p><pre>Company<br>   │<br>   ├── Founders<br>   │<br>   ├── Investors<br>   │<br>   └── ESOP Pool<br>          │<br>          ├── Engineer<br>          ├── Designer<br>          ├── Product<br>          └── Employees</pre><h3>10 — SAFE</h3><p>Now imagine you’re a founder.</p><p>You don’t want to spend weeks negotiating a full equity round.</p><p>You raise:</p><p><strong>₹50 lakh</strong></p><p>But you don’t determine the exact share price today.</p><p>Instead, the investment can convert into equity later under agreed terms.</p><p>That’s where a <strong>SAFE</strong> comes in.</p><p>SAFE stands for:</p><p><strong>Simple Agreement for Future Equity.</strong></p><p>The investor gives money today.</p><p>The equity is determined later, typically when a future financing event occurs.</p><p>A SAFE can include concepts such as:</p><ul><li>Valuation cap</li><li>Discount</li><li>Conversion mechanics</li></ul><h3>11 — Convertible Notes</h3><p>Convertible notes solve a similar problem, but they’re structured as <strong>debt initially</strong>.</p><p>The investor gives the startup money as a note.</p><p>Instead of simply receiving repayment, the note can convert into equity under specified conditions.</p><p>Conceptually:</p><pre>Investor<br>   │<br>   │ ₹ Investment<br>   ▼<br>Convertible Note<br>   │<br>   │ Future Financing<br>   ▼<br>Equity</pre><p>The difference between <strong>SAFE vs Convertible Note</strong> is worth understanding because they can look similar from the outside while having different legal/economic mechanics.</p><h3>12 — Term Sheets</h3><p>Eventually, someone says:</p><blockquote><em>“We’re interested in investing.”</em></blockquote><p>Now comes the <strong>term sheet</strong>.</p><p>Think of it as the blueprint for the investment.</p><p>It can cover things like:</p><ul><li>Valuation</li><li>Investment amount</li><li>Ownership</li><li>Liquidation preference</li><li>Board rights</li><li>Voting rights</li><li>Founder vesting</li><li>Anti-dilution provisions</li><li>ESOP pool</li><li>Information rights</li><li>Conditions to closing</li></ul><p>The headline valuation might get all the attention.</p><p>But the <strong>fine print can matter just as much.</strong></p><h3>13 — The Cap Table</h3><p>This is where everything finally comes together.</p><p>A <strong>capitalization table</strong>, or cap table, tracks ownership.</p><p>Imagine:</p><p>HolderSharesOwnershipFounder A6,000,00060%Founder B2,000,00020%Investor A1,500,00015%ESOP Pool500,0005%<strong>Total10,000,000100%</strong></p><p>Now raise another round.</p><p>Everything changes.</p><p>The cap table becomes the source of truth for:</p><p><strong>Who owns what?</strong></p><h3>14 — This Is Where Technology Enters</h3><p>Managing this manually with Excel becomes painful very quickly.</p><p>Imagine:</p><ul><li>4 founders</li><li>50 employees</li><li>3 investors</li><li>5 funding rounds</li><li>Multiple SAFEs</li><li>Convertible notes</li><li>ESOP grants</li><li>Different share classes</li></ul><p>Suddenly you’re managing thousands of ownership relationships.</p><p>That’s why modern startups use <strong>cap-table platforms</strong>.</p><p>Technology turns:</p><pre>Funding agreements<br>        +<br>Share issuance<br>        +<br>Employee options<br>        +<br>Investor ownership<br>        +<br>Dilution<br>        ↓<br>    CAP TABLE</pre><p>into a system that can automatically model ownership changes.</p><h3>15 — Financial Modelling</h3><p>Now imagine an investor asks:</p><blockquote><em>“What happens if revenue grows 50% every year?”</em></blockquote><p>Or:</p><blockquote><em>“What happens if you raise another ₹100 crore?”</em></blockquote><p>Or:</p><blockquote><em>“What happens to founder ownership after three rounds?”</em></blockquote><p>That’s financial modelling.</p><p>You create assumptions.</p><p>Then model different scenarios.</p><pre>ASSUMPTIONS<br>                     │<br>        ┌────────────┼────────────┐<br>        ▼            ▼            ▼<br>     Revenue       Costs       Funding<br>        │            │            │<br>        └────────────┼────────────┘<br>                     ▼<br>               FINANCIAL MODEL<br>                     │<br>        ┌────────────┼────────────┐<br>        ▼            ▼            ▼<br>     Valuation     Cash       Dilution</pre><p>This is essentially turning <strong>business assumptions into numbers.</strong></p><h3>16 — Data Rooms</h3><p>Now you’re raising money.</p><p>An investor doesn’t simply transfer ₹50 crore because your pitch deck looks cool.</p><p>They investigate.</p><p>You give them access to a <strong>data room</strong> containing documents such as:</p><ul><li>Financial statements</li><li>Contracts</li><li>Cap table</li><li>Customer information</li><li>Legal documents</li><li>Intellectual property</li><li>Employee agreements</li><li>Tax records</li><li>Business metrics</li></ul><p>This process is called:</p><h3>Due Diligence</h3><p>The investor is essentially asking:</p><blockquote><strong><em>“Is this company actually what you say it is?”</em></strong></blockquote><h3>17 — AI Enters the Deal Room</h3><p>And this is where things are getting really interesting.</p><p>Instead of humans manually reading thousands of documents, AI systems can assist with:</p><h3>Document analysis</h3><p>Extract important clauses from contracts.</p><h3>Financial analysis</h3><p>Identify unusual trends in financial statements.</p><h3>Risk detection</h3><p>Flag potentially problematic terms.</p><h3>Valuation analysis</h3><p>Compare companies and financial metrics.</p><h3>Deal analysis</h3><p>Summarize an investment opportunity and surface potential risks.</p><p>The human investor still makes the decision.</p><p>But AI can increasingly act as the <strong>research and analysis layer.</strong></p><h3>18 — Who Actually Does This?</h3><p>Now we reach the industry layer.</p><p>Some of the major names you should know:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*9tRiz7i2Z6BT3Cs5" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BJ91QP8WvZF4OEfo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*BJvahcNhwqg8Ni8Q" /></figure><h3>Sequoia</h3><p>One of Silicon Valley’s most historically influential venture firms.</p><h3>Accel</h3><p>A global venture capital firm with a major presence in both the US and India.</p><h3>Peak XV Partners</h3><p>A major venture capital firm focused on India and other markets.</p><h3>Andreessen Horowitz</h3><p>Often known as <strong>a16z</strong>, a major technology-focused venture capital firm.</p><h3>Y Combinator</h3><p>Different from a traditional VC firm in structure and best known for its accelerator model.</p><p>The important thing isn’t memorizing their names.</p><p>It’s understanding <strong>the role they play in the capital ecosystem.</strong></p><h3>19 — The Complete Money Flow</h3><p>Now let’s connect everything.</p><pre>LIMITED PARTNERS<br>                       │<br>                       │ Capital<br>                       ▼<br>                ┌─────────────┐<br>                │   VC FUND   │<br>                └──────┬──────┘<br>                       │<br>                       │ Investment<br>                       ▼<br>                 ┌───────────┐<br>                 │  STARTUP  │<br>                 └─────┬─────┘<br>                       │<br>          ┌────────────┼────────────┐<br>          ▼            ▼            ▼<br>       Founders      Employees    Investors<br>          │            │            │<br>          ▼            ▼            ▼<br>       Equity         ESOP        Equity<br>          │<br>          └────────────┬────────────┘<br>                       ▼<br>                  CAP TABLE<br>                       │<br>                       ▼<br>                 COMPANY VALUE<br>                       │<br>              ┌────────┴────────┐<br>              ▼                 ▼<br>           ACQUISITION          IPO<br>              │                 │<br>              └────────┬────────┘<br>                       ▼<br>                    RETURNS</pre><p><strong>This is the startup financial machine.</strong></p><h3>20 — The Part Nobody Talks About</h3><p>Here’s the interesting part.</p><p>A founder can raise:</p><p><strong>₹10 crore</strong></p><p>and still end up owning less of the company than before.</p><p>Why?</p><p>Because raising capital changes the ownership structure.</p><p>But that doesn’t necessarily mean the founder lost money.</p><p>Suppose:</p><h3>Before</h3><p>Founder owns:</p><p><strong>100% × ₹10 crore = ₹10 crore</strong></p><h3>After investment</h3><p>Founder owns:</p><p><strong>70%</strong></p><p>Company valuation:</p><p><strong>₹50 crore</strong></p><p>Founder stake:</p><p><strong>70% × ₹50 crore = ₹35 crore</strong></p><p>The founder owns less of the company.</p><p>But their stake became much more valuable.</p><p>That’s the fundamental trade:</p><blockquote><strong><em>Give up ownership today to potentially create much more value tomorrow.</em></strong></blockquote><h3>21 — And That’s Venture Capital</h3><p>VC isn’t simply:</p><blockquote><strong><em>“Invest money → get shares.”</em></strong></blockquote><p>It’s a bet on asymmetric outcomes.</p><p>Imagine a fund invests in 20 startups.</p><p>Maybe:</p><ul><li>10 fail</li><li>5 return modestly</li><li>3 do well</li><li>1 becomes huge</li><li>1 becomes enormous</li></ul><p>That enormous outcome can potentially compensate for many failures.</p><p>This is why venture capital behaves very differently from traditional lending.</p><h3>22 — So Where Does the Money Come From?</h3><p>Let’s answer the original question.</p><blockquote><strong><em>Where does the money that builds the next billion-dollar company actually come from?</em></strong></blockquote><p>It can originate from:</p><p><strong>Individuals → Angel investors → VC funds → Institutional LPs → Growth investors → Private equity → Public markets</strong></p><p>And it moves through a financial infrastructure involving:</p><p><strong>Term sheets → Valuation → Cap tables → SAFEs → Convertible notes → Equity → Debt → ESOPs → Due diligence → Financial models</strong></p><p>Behind every startup you’ve heard of is an entire financial system determining:</p><p><strong>who owns it, who funds it, how much it’s worth, and who gets paid when it succeeds.</strong></p><h3>THE TAKEAWAY</h3><p>If you remember only <strong>five things</strong> from Week 3:</p><p><strong>1. Equity = ownership.</strong></p><p><strong>2. Debt = borrowing.</strong></p><p><strong>3. Valuation determines the price of ownership.</strong></p><p><strong>4. Dilution changes ownership percentages when new shares/capital enter the picture.</strong></p><p><strong>5. Venture capital is ultimately a bet on future company value.</strong></p><p>And that’s the deeper lesson:</p><blockquote><strong><em>A startup isn’t just an engineering system.</em></strong></blockquote><blockquote><strong><em>It’s also a financial system.</em></strong></blockquote><p>Next week, we can go one level deeper.</p><p><strong>We’ll take the money itself and follow it through the financial infrastructure.</strong> 💳</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d77e44fb3b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WEEK 02 — Engineering Money at Scale]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/week-02-engineering-money-at-scale-8d202ec189a9?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d202ec189a9</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 05:49:47 GMT</pubDate>
            <atom:updated>2026-08-31T05:49:47.977Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>(WELCOME TO DIVE INTO FINTECH WITH ARYAN </strong>😄 <strong>!!)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnYNZnZGBxoNscwOxckBcw.png" /></figure><h3>One ₹10,000 payment, followed all the way down.</h3><p>You tap Pay. ₹10,000.</p><p>Your bank sends an SMS: <strong>debited</strong>. The merchant’s page says: <strong>Payment Failed</strong>. The gateway’s logs say: <strong>TIMEOUT</strong>.</p><p>Three systems, three different answers, and here’s the uncomfortable part: none of them is lying. Every one of them is reporting the truth as it knows it.</p><p>Most people assume somebody screwed up. A bad deploy, a lazy engineer, a cheap server. Almost never. What you just experienced is the normal, designed-for behaviour of a distributed system that moves real money across networks it doesn’t own, through banks it can’t control, in under three seconds.</p><p>We’re going to follow that exact payment through a production payment system. By the end you’ll know precisely where your ₹10,000 went and why it comes back.</p><p><strong>Contents</strong></p><ol><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#1">Who actually moves the money</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#2">Anatomy of a ₹10,000 transaction</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#3">The real problem: distributed systems plus money</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#4">Idempotency</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#5">Event-driven payments</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#6">Making banks fail gracefully</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#7">Reconciliation, refunds and chargebacks</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#8">Self-healing and disaster recovery</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#9">The final boss</a></li></ol><p>&lt;a name=”1&quot;&gt;&lt;/a&gt;</p><h3>1. Who actually moves the money?</h3><p>You think of a payment as two parties: you and the shop. It’s closer to eight, and each one has a specific job.</p><p><strong>Customer.</strong> You. You have an account at a bank, and a card or UPI handle that points to it.</p><p><strong>Merchant.</strong> The business taking your money. Wants payments to work, does not want to build payment infrastructure, and legally cannot touch card numbers without heavy PCI-DSS compliance.</p><p><strong>Payment Gateway.</strong> The piece that captures payment details, encrypts them, and forwards them toward the banking network. Pure plumbing. Think of it as a secure courier: it doesn’t hold your money, it carries the message.</p><p><strong>Payment Aggregator.</strong> Here’s the problem a gateway alone doesn’t solve. To receive money directly, every merchant needs its own merchant account with an acquiring bank, which means paperwork, underwriting, and weeks of onboarding. An aggregator solves this by holding one master merchant account and letting thousands of small merchants sit underneath it. <strong>Razorpay</strong> and <strong>Cashfree</strong> are aggregators. This is why a two-person startup in Chennai can accept payments the same afternoon it signs up.</p><p><strong>Payment Service Provider (PSP).</strong> The umbrella term for anyone providing the technical and financial pipes to accept payments. In UPI specifically it has an exact meaning: the PSP is the entity that holds your UPI handle and talks to NPCI on your behalf. When you use yourname@ybl, Yes Bank is the PSP behind PhonePe.</p><p><strong>Payment Orchestrator.</strong> A layer above the gateways. It doesn’t process payments itself; it decides <em>which</em> gateway or bank to route each payment through, in real time, based on who’s healthy right now. <strong>Juspay</strong> is the well-known Indian example, and this distinction matters more than it sounds. Two companies can use the exact same underlying banks and see success rates several percentage points apart purely on routing quality.</p><p><strong>Wallets.</strong> <strong>MobiKwik</strong> and similar. A prepaid balance you top up, which becomes its own funding source. Faster than a card because the money is already inside the system, but it’s a closed loop until it settles out.</p><p><strong>Acquiring Bank.</strong> The merchant’s bank. It “acquires” the transaction on the merchant’s behalf, takes on the risk, and eventually deposits money in the merchant’s account.</p><p><strong>Issuing Bank.</strong> Your bank. It “issued” your card or account. It is the only party in this entire chain that can actually say yes or no, because it’s the only one holding your ₹10,000.</p><p><strong>Card Networks.</strong> Visa, Mastercard, RuPay, Amex. They’re not banks and they don’t lend you money. They operate the rails and the rulebook that let an acquiring bank in one country talk to an issuing bank in another. They also set interchange fees and run the dispute process.</p><p><strong>UPI and NPCI.</strong> In India, UPI bypasses card rails entirely. NPCI runs the switch. Instead of a card number moving through Visa, a virtual payment address moves through NPCI, which routes it directly bank-to-bank. Lower cost, different failure modes, and the reason India’s payment volumes look the way they do.</p><pre>You                                                    Your Bank<br>   │                                                     (Issuer)<br>   ▼                                                         ▲<br>Merchant ──► Gateway ──► Aggregator ──► Network ──► Acquiring│<br>                          / PSP        (Visa/NPCI)   Bank ───┘<br>                             ▲<br>                             │<br>                      Orchestrator<br>                    (routes across many)</pre><p><strong>So when you click Pay, who touches your money?</strong> Strictly speaking, only two entities ever <em>hold</em> it: your issuing bank and, eventually, the acquiring bank. Everyone in between touches the <em>message about</em> your money. That distinction is the entire subject of this article, because messages get lost and money doesn’t.</p><p>&lt;a name=”2&quot;&gt;&lt;/a&gt;</p><h3>2. Anatomy of a ₹10,000 transaction</h3><p>Six stages. Most people think it’s one.</p><pre>Customer<br>   ↓  initiation<br>Merchant<br>   ↓<br>Gateway / PSP<br>   ↓  authentication<br>Payment Network<br>   ↓<br>Acquiring Bank<br>   ↓<br>Issuing Bank<br>   ↓  authorization<br>Response  ──────────────┐<br>   ↓  capture           │  (this return path<br>Processing              │   is where things<br>   ↓                    │   go wrong)<br>Settlement  ────────────┘</pre><p><strong>Initiation.</strong> You submit payment details. The merchant’s server never sees your card number if they’re doing it right; the gateway hands the browser a token or hosted field, so raw card data goes straight to the gateway. This is not paranoia, it’s the difference between a PCI-DSS scope of one form field and a scope of your entire backend.</p><p><strong>Authentication.</strong> Proving you are you. 3D Secure for cards, which is that OTP screen redirecting you to your bank’s domain. UPI PIN for UPI. Note what’s happening here: the merchant and gateway are deliberately cut out of the loop. Your bank authenticates you directly and tells everyone else the result. Nobody in the middle ever sees your PIN.</p><p><strong>Authorization.</strong> Your issuing bank checks balance, fraud rules, velocity limits, and card status, then either approves or declines. On approval it places a <strong>hold</strong> on ₹10,000. Your available balance drops. <strong>No money has moved.</strong> This is a promise, not a transfer.</p><p><strong>Capture.</strong> The merchant claims the authorized amount. For most e-commerce this is automatic and instant. For hotels, car rentals and fuel pumps it isn’t, which is why a petrol pump holds ₹5,000 on your card and captures ₹1,847 later. Auth and capture are separate operations for a reason.</p><p><strong>Processing / Clearing.</strong> The network batches captured transactions and exchanges them between banks. Fees get calculated. Interchange gets split between issuer, acquirer and network.</p><p><strong>Settlement.</strong> Money actually leaves your account and lands in the merchant’s, in a batch, on a schedule. <strong>T+1 or T+2 for most Indian merchants</strong>, longer for higher-risk categories.</p><h3>Authorization ≠ Settlement</h3><p>This single line explains most confusion about “where is my money.”</p><p>Authorization Settlement When Instant T+1, T+2 or later What moved Nothing Actual funds Reversible by Void / auth expiry Refund Who knows Everyone, immediately A batch file, hours later</p><p>Your “instant” payment was a reservation. The transfer happens later, quietly, in a file. Hold onto that, because it’s the mechanism that eventually returns your ₹10,000.</p><p>&lt;a name=”3&quot;&gt;&lt;/a&gt;</p><h3>3. The real problem: distributed systems plus money</h3><p>Now the engineering nightmare. Here is everything that can go wrong on a single payment, and why each one is genuinely hard.</p><p><strong>The bank responds slowly.</strong> Not down, just slow. 8 seconds instead of 400ms. Your threads are all blocked waiting. Your connection pool drains. Traffic that has nothing to do with that bank starts failing too. Slowness spreads further than outages do, because an outage fails fast and slowness holds your resources hostage.</p><p><strong>The network times out.</strong> You sent the request. You got nothing back. See below, this is the big one.</p><p><strong>The API request gets duplicated.</strong> A user double-taps. A load balancer retries on a 504. A mobile client on flaky 4G resends. Your service now sees two identical payment requests and has to decide whether they’re one payment or two.</p><p><strong>The bank succeeds but the response is lost.</strong> The money moved. You don’t know. Your system says failed. The customer’s balance says otherwise.</p><p><strong>Your payment service crashes mid-flow.</strong> You wrote “authorization sent” to the database, called the bank, and the pod got OOM-killed before writing the result. On restart, what state is that payment in? You need every transaction to be in a persisted, resumable state at every step, which means writing intent <em>before</em> acting, always.</p><p><strong>The database becomes unavailable.</strong> You cannot record what happened. Do you keep accepting payments and risk having no record, or reject payments you could have processed? In money, the answer is always reject. An unrecorded payment is worse than a declined one.</p><p><strong>Two systems disagree about status.</strong> Your ledger says SUCCESS, the bank’s file says FAILED. Both are internally consistent. Somebody has to be authoritative, and it is never you.</p><h3>The Two Generals Problem</h3><p>Strip the scenario down. You send a request. The response doesn’t arrive. What happened?</p><ul><li>The bank never received it?</li><li>The bank received it, declined it, and the response was lost?</li><li>The bank received it, <strong>approved it, moved ₹10,000</strong>, and the response was lost?</li></ul><p>You cannot tell. Not with better logging, not with a faster client, not with more retries. The information physically does not exist on your side of the wire.</p><p>This is the Two Generals Problem in a suit. Two parties communicating over an unreliable channel can never both become certain the other received a message. You can stack acknowledgements forever and never close the gap. It is proven impossible, not merely difficult.</p><p>Which gives us the single most important sentence in payments engineering:</p><blockquote><strong><em>A timeout is not a failure. A timeout is an unknown.</em></strong></blockquote><p>Systems that treat timeouts as failures do the obvious thing. They retry. And that’s how people get charged twice.</p><p>&lt;a name=”4&quot;&gt;&lt;/a&gt;</p><h3>4. Idempotency: don’t charge ₹10,000 twice</h3><p>Since a timeout means “unknown,” you <em>must</em> retry to find out. And since retrying might duplicate a real charge, retries have to be safe. That property is <strong>idempotency</strong>: doing an operation N times has the same effect as doing it once.</p><h3>Idempotency keys</h3><p>The client generates a unique key <strong>once</strong>, before the first attempt, and reuses it for every retry of that same logical operation.</p><pre>Attempt 1 → key: PAY_12345 → no record → process → SUCCESS<br>                                          (response lost in transit)</pre><pre>Attempt 2 → key: PAY_12345 → record found → return stored SUCCESS<br>Attempt 3 → key: PAY_12345 → record found → return stored SUCCESS</pre><p>Three requests. One financial operation. Attempts 2 and 3 don’t re-execute anything, they replay a stored result.</p><p>The key must be generated by the <strong>client</strong>, not the server. A server-generated ID is new on every request, which defeats the entire purpose. It must also be tied to the operation’s content, so that a genuine second ₹10,000 payment to the same merchant gets a different key.</p><h3>Unique transaction IDs vs idempotency keys</h3><p>These get conflated constantly. They’re different.</p><ul><li><strong>Idempotency key</strong> is about the <em>request</em>. It answers: have I seen this attempt before?</li><li><strong>Transaction ID</strong> is about the <em>money</em>. It’s your permanent reference for the financial record, used in ledgers, reconciliation and support tickets.</li></ul><p>One idempotency key maps to exactly one transaction ID. Many retries map to one key.</p><h3>Database constraints do the real work</h3><p>Here’s the detail that separates people who’ve read about this from people who’ve shipped it.</p><p>The naive implementation is: check if the key exists, and if not, insert it. That’s two statements with a gap between them, and under concurrent retries, which happen constantly, two requests can both pass the check before either one inserts. You’ve built a race condition into your payment path.</p><p><strong>Put a </strong><strong>UNIQUE constraint on the idempotency key column and insert first.</strong> Let the database reject the duplicate and catch that error. The database is the only component in your stack that can actually serialise that decision. Application-level checking is a suggestion; a unique index is a guarantee.</p><h3>Exactly-once is a lie (mostly)</h3><p>You’ll see “exactly-once delivery” advertised. Over an unreliable network it’s impossible in the general case. What’s actually achievable is:</p><ul><li><strong>At-most-once</strong>: send it, don’t retry. You’ll lose payments. Unacceptable.</li><li><strong>At-least-once</strong>: retry until acknowledged. You’ll get duplicates. Acceptable.</li><li><strong>At-least-once delivery + idempotent processing = exactly-once <em>effect</em></strong>.</li></ul><p>That last line is how every real payment system works. You don’t prevent duplicate messages, you make duplicates harmless.</p><h3>Safe retries</h3><p>A retry is safe only when all three are true: the operation carries an idempotency key, the key is enforced at the database, and the retry policy is bounded. Miss any one and you’re building a double-charge machine with backoff.</p><p>&lt;a name=”5&quot;&gt;&lt;/a&gt;</p><h3>5. Event-driven payments</h3><p>Once a payment is authorized, a lot of things need to happen. Update the ledger. Score it for fraud. Notify the merchant. Email the customer. Feed reconciliation. Update analytics.</p><p>If you do all of that inline before responding, your payment API is only as fast and as available as your <strong>slowest dependency</strong>. The notification service goes down and payments stop. That’s an unacceptable coupling, so payments go asynchronous.</p><h3>Message queues and event buses</h3><p>A <strong>message queue</strong> is point-to-point: one producer, one consumer, message consumed and gone. Good for work distribution, like “process these refunds.”</p><p>An <strong>event bus</strong> is publish-subscribe: one producer, many independent consumers, each reading at its own pace. Kafka is the canonical example. Good for facts, like “payment PAY_12345 was authorized,” where five different services each care for different reasons.</p><p>Payments use both. Auth results go on a bus because many services care. Refund processing goes on a queue because exactly one worker should handle each one.</p><pre>Payment Authorized<br>             │<br>             ▼<br>        Event Bus (Kafka)<br>     ┌───────┼───────┬────────────┐<br>     ▼       ▼       ▼            ▼<br>  Ledger   Risk   Notification  Reconciliation<br>     │<br>     ▼<br>  (settlement pipeline)</pre><p><strong>Producers</strong> publish and move on. They don’t know or care who’s listening, which is exactly the decoupling you want. <strong>Consumers</strong> subscribe, track their own offset, and can be added later without touching the producer. That last property is underrated: six months from now you’ll add a fraud-analytics service, and you’ll add it without redeploying the payment path.</p><h3>Ordering</h3><p>You do <strong>not</strong> want global ordering across all payments. That would serialise your entire throughput onto one partition and cap you at whatever a single consumer can handle.</p><p>You want ordering <strong>per payment</strong>. Partition by payment ID. Then authorized → captured → refunded always arrives in sequence for a given transaction, while a million unrelated transactions process in parallel. Getting the partition key right is one of the highest-leverage decisions in the architecture.</p><h3>Delivery guarantees</h3><p>Kafka and friends give you <strong>at-least-once</strong> by default. Consumers <em>will</em> occasionally see the same event twice, from a rebalance, a redelivery after a crash, or a slow ack.</p><p>Which means the idempotency lesson from section 4 repeats one layer down: <strong>every consumer must be idempotent too.</strong> If your ledger service isn’t, a redelivered event double-credits a merchant. Same bug, different floor of the building.</p><h3>Dead-letter queues</h3><p>Some messages will never succeed. Malformed payload, a referenced record that doesn’t exist, a bug. If you retry them forever they block the partition and everything behind them stalls.</p><p>A <strong>dead-letter queue</strong> catches anything that fails after N attempts and parks it. The stream keeps moving. A human, or an automated repair job, deals with the DLQ later. In payments, “later” is fine. “Blocked” is not, because a blocked partition means every payment behind it is stuck too.</p><p>&lt;a name=”6&quot;&gt;&lt;/a&gt;</p><h3>6. Making banks fail gracefully</h3><p>Banks go down. Not hypothetically. Routinely, often in maintenance windows announced badly or not at all. Your job is to survive it.</p><p><strong>The central question: if Bank A is dying, how do you avoid dying with it?</strong></p><h3>Transient vs permanent failures</h3><p>Before you retry anything, classify the failure. This is the step people skip.</p><ul><li><strong>Transient</strong>: timeout, 503, connection reset, “bank temporarily unavailable.” Retry these.</li><li><strong>Permanent</strong>: insufficient funds, card expired, invalid credentials, fraud decline. <strong>Never retry these.</strong> Retrying a declined card doesn’t get you a different answer, it gets you rate-limited by the bank and flagged for suspicious behaviour.</li></ul><p>A retry policy without failure classification is a way to convert one problem into two.</p><h3>Exponential backoff and jitter</h3><p>If ten thousand requests fail and all retry after exactly one second, you’ve built a synchronised hammer that hits the recovering bank ten thousand times at once. It falls over again. That’s a <strong>thundering herd</strong>, and it turns a 30-second blip into a 30-minute outage.</p><p><strong>Exponential backoff</strong>: wait 1s, then 2s, 4s, 8s. Gives the dependency room to breathe.</p><p><strong>Jitter</strong>: add a random offset so retries spread out instead of arriving as a wave. Backoff without jitter still synchronises your clients, just at wider intervals. Jitter is not optional.</p><p><strong>Retry limits</strong>: bounded, always. Typically 3 to 5 attempts, then stop and mark the payment for reconciliation rather than retrying into the void.</p><h3>Circuit breakers</h3><p>A piece of state sitting in front of each dependency, with three modes:</p><pre>┌──────────┐  failures &gt; threshold   ┌────────┐<br>   │  CLOSED  │ ──────────────────────► │  OPEN  │<br>   │ traffic  │                         │ reject │<br>   │  flows   │ ◄────────────────────── │  fast  │<br>   └──────────┘      probe succeeds     └────────┘<br>        ▲                                    │<br>        │                                    │ after cooldown<br>        │            ┌────────────┐          │<br>        └────────────│ HALF-OPEN  │ ◄────────┘<br>                     │ let a few  │<br>                     │  through   │<br>                     └────────────┘</pre><p><strong>Closed</strong>: normal operation, failures counted in a rolling window. <strong>Open</strong>: threshold crossed. Stop calling entirely. Fail immediately, in microseconds, without waiting for a timeout. <strong>Half-open</strong>: after a cooldown, allow a handful of probe requests. Success closes the circuit. Failure trips it open again.</p><p>The counter-intuitive part is that Open state deliberately rejects requests that <em>might</em> have succeeded. That’s the trade, and it’s the right one. Failing 10,000 requests in 5ms each is far better than hanging 10,000 requests for 30 seconds each and exhausting every thread you own. The circuit breaker exists to protect <strong>you</strong>, not the bank.</p><h3>Failover and multi-bank routing</h3><p><strong>Primary and secondary</strong>: if HDFC’s acquiring endpoint is degraded, route to ICICI. Same payment, different rail.</p><p><strong>Multi-bank routing</strong> goes further and makes routing a live decision based on real-time success rates, latency, cost per transaction, and card BIN. A Kotak card might have a 96% success rate through one gateway and 89% through another at 3pm on a Friday. Routing on that data is worth real money, and it’s exactly why orchestration layers exist as a business.</p><h3>Load management</h3><p><strong>Rate limiting.</strong> Every bank imposes TPS caps. Exceed them and they throttle or block you outright. You rate-limit <em>outbound</em> traffic per bank to stay under their ceiling, and <em>inbound</em> per merchant so one client can’t consume your whole quota.</p><p><strong>Backpressure.</strong> When downstream can’t keep up, the pressure has to go somewhere. The wrong answer is to buffer infinitely until you run out of memory and lose everything in flight. The right answer is to push the signal upstream: slow your consumers, reject new work at the edge with a clear 429, and let clients back off. Backpressure is the system admitting its limits instead of pretending.</p><p><strong>Queue buffering.</strong> Absorb spikes rather than dropping them. A festival sale sends 10x normal traffic for twenty minutes. You can’t scale the bank, but you can queue and drain at a sustainable rate. Payments tolerate a few seconds of added latency far better than they tolerate failures.</p><p>&lt;a name=”7&quot;&gt;&lt;/a&gt;</p><h3>7. Reconciliation, refunds and chargebacks</h3><p>This is the financial correctness layer. Everything above tries to prevent problems. This part assumes prevention failed and fixes reality anyway.</p><h3>The mismatch</h3><pre>Our system   →  SUCCESS<br>Bank report  →  SUCCESS<br>Settlement   →  MISSING      ⚠</pre><p>Money that should have arrived, didn’t. Or arrived and shouldn’t have. Both happen daily at any real scale.</p><h3>The moving parts</h3><p><strong>Transaction ledger.</strong> Your internal, append-only record of every state change on every payment. Append-only matters: you never update a row to change history, you write a new entry. authorized → captured → refunded is four rows, not one row edited four times. When a dispute happens eight months later, you need the sequence, not the current value.</p><p><strong>Bank reports and settlement files.</strong> Every day, banks and networks send flat files listing every transaction they believe happened, with amounts, fees, and status. Often still CSV over SFTP. Unglamorous, and it is the actual source of truth.</p><p><strong>Reconciliation engine.</strong> The job that does a three-way match: your ledger, the bank’s report, and money actually received. It runs daily, sometimes hourly, and classifies every discrepancy.</p><h3>Mismatch types and their fixes</h3><p>Our ledger Bank file Reality Action SUCCESS absent no money We were wrong. Mark failed. FAILED SUCCESS money moved <strong>We lost the response. Auto-refund.</strong> SUCCESS SUCCESS not settled Chase the bank. ₹10,000 ₹9,982 fees deducted Expected. Book the fee. ₹10,000 ₹8,000 genuine mismatch Manual queue. Human review.</p><p><strong>Automated reconciliation</strong> handles the known patterns, which is 95%+ of volume. <strong>Manual reconciliation</strong> handles the rest, and every payments company has a team doing exactly this. The goal isn’t zero manual work, it’s keeping manual work bounded as volume grows.</p><p>Row two is your ₹10,000. Remember it.</p><h3>Refunds</h3><p>A refund is <strong>merchant-initiated</strong>. You ask, the merchant agrees, money flows back along the same rails.</p><pre>SUCCESS<br>   ↓  refund requested<br>PROCESSING<br>   ↓  bank confirms<br>REFUNDED</pre><p>Engineering notes that matter: a refund is its own transaction with its own idempotency key, because double-refunding is as bad as double-charging. It must be linked to the original payment ID. And you must guard against refunding more than the original amount across multiple partial refunds, which is a real bug people ship.</p><p>Refunds are slower than payments because they ride the settlement cycle. That “5–7 working days” isn’t a brush-off, it’s a batch file and a clearing cycle.</p><h3>Chargebacks</h3><p>A chargeback is <strong>customer-initiated, through their bank, against the merchant’s will.</strong> That distinction is everything.</p><p><strong>Refund ≠ Chargeback:</strong></p><p>Refund Chargeback Initiated by Merchant Customer, via issuing bank Merchant consent Yes No Cost to merchant Transaction fee Fee <strong>plus</strong> penalty, often ₹500–2,000 Timeline Days Weeks to months Reputation None Tracked; high ratios get you terminated</p><p>How a dispute propagates:</p><pre>Customer disputes with issuing bank<br>        ↓<br>Issuing bank provisionally credits customer, raises dispute<br>        ↓<br>Card network / NPCI routes it to acquiring bank<br>        ↓<br>Acquiring bank debits merchant, requests evidence<br>        ↓<br>Merchant submits proof of delivery, logs, auth records<br>        ↓<br>Network arbitrates → won or lost</pre><p>The engineering consequence: your system needs to reproduce, months later, exactly what happened during a payment. Auth codes, timestamps, IP, device fingerprint, 3DS result, delivery confirmation. If your logging has a 30-day retention and a chargeback lands on day 45, you lose by default. Not because you were wrong, but because you can’t prove you were right.</p><p>And the ratio matters. Networks track chargebacks as a percentage of transactions. Cross roughly 1% and you enter monitoring programmes. Stay there and your acquirer drops you.</p><p>&lt;a name=”8&quot;&gt;&lt;/a&gt;</p><h3>8. Self-healing and disaster recovery</h3><p>Zoom all the way out. What kills a payment system, and what keeps it alive?</p><p><strong>Database failure.</strong> Replication with automatic promotion. A primary with synchronous replicas for the ledger, because in payments you accept slower writes to guarantee no committed transaction is lost. For non-financial data, async replication is fine. Choose per dataset, not globally.</p><p><strong>Service failure.</strong> Redundancy plus <strong>health checks</strong>. Distinguish liveness (“is the process running”) from readiness (“can it actually serve traffic”). A payment service that’s up but has lost its database connection must fail readiness so the load balancer stops sending it work. Instances that fail health checks get pulled and replaced automatically.</p><p><strong>Bank outage.</strong> Circuit breakers and multi-bank routing from section 6.</p><p><strong>Network outage.</strong> Multiple availability zones, redundant paths, and the assumption that any single link will vanish without notice.</p><p><strong>Region failure.</strong> Multi-region deployment with the ability to fail over. This is where it gets genuinely hard, because financial data has residency requirements and cross-region replication has real lag. Most Indian payment companies run multi-AZ within a region and treat full region failover as a documented, rehearsed manual process rather than an automatic one.</p><p><strong>Traffic spikes.</strong> Autoscaling, queue buffering, rate limiting, and load shedding. When you can’t serve everything, degrade deliberately: keep authorizations alive and let analytics lag.</p><p><strong>Partial failures.</strong> The hardest category and the most common. Not “everything is down” but “the ledger is fine, notifications are dead, and one bank is slow.” The system must keep working in a diminished state without a human deciding what to sacrifice at 3am. That’s what circuit breakers, DLQs and backpressure are all for.</p><h3>Backups, RPO and RTO</h3><p>Two numbers define your disaster posture, and if you can’t state them you don’t have a plan.</p><p><strong>RPO — Recovery Point Objective.</strong> How much data you can afford to lose, measured in time. RPO of 5 minutes means a disaster could cost you the last 5 minutes of writes. <strong>For a payment ledger, the target is effectively zero</strong>, which is why you use synchronous replication and write-ahead logs rather than periodic snapshots. Losing five minutes of payments means losing money that customers were actually charged.</p><p><strong>RTO — Recovery Time Objective.</strong> How long you can afford to be down. Every minute of downtime is failed transactions and merchants losing revenue, so RTO is measured in minutes, not hours.</p><p>Backups still exist for a different reason: replication faithfully replicates corruption and bad deletes. A replica protects you from hardware failure. A backup protects you from a bad migration. You need both, and an untested backup is not a backup.</p><h3>Reconciliation after recovery</h3><p>The step everyone forgets. When you come back up, <strong>you do not know what happened during the outage.</strong> Payments were in flight. Some completed at the bank. Some didn’t. Your records have a hole.</p><p>The recovery sequence:</p><ol><li>Restore service, but <strong>do not</strong> blindly retry in-flight transactions.</li><li>Query the bank for the status of every payment that was pending when you went down. Idempotency keys make this safe, since you can re-query without re-charging.</li><li>Run reconciliation against the bank’s file for the outage window.</li><li>Repair the ledger to match reality.</li><li>Auto-refund anything the bank charged that you failed.</li></ol><p>Reconciliation is the mechanism that converts an outage from a permanent loss into a temporary inconsistency. This is why it’s the last line of defence and not an accounting afterthought.</p><p>&lt;a name=”9&quot;&gt;&lt;/a&gt;</p><h3>9. The final boss</h3><p>Back to where we started.</p><pre>You         →  ₹10,000 deducted<br>Your bank   →  SUCCESS<br>Gateway     →  TIMEOUT<br>Merchant    →  FAILED</pre><p>Here’s exactly what happened, in order.</p><p>Your issuing bank received the authorization request. It checked your balance, ran its fraud rules, approved it, and placed a hold on ₹10,000. From its point of view the transaction is complete and correct. It sent you an SMS because it did what it was asked.</p><p><strong>The response packet died on the way back.</strong> A dropped connection, a load balancer recycling, a two-second GC pause on the wrong node. Doesn’t matter which.</p><p>The gateway waited. Its timeout fired. It knew only one thing: no response. Not “failed”, just <em>unknown</em>. But it has to return something to the merchant within a bounded time, and the safe default when you can’t confirm money moved is to not claim it did. So it reported failure.</p><p>The merchant showed you an error, because the merchant knows only what the gateway told it.</p><p><strong>Every single component behaved correctly.</strong> Nobody had a bug. The system was briefly, structurally wrong about reality, because the fact needed to be right did not exist anywhere it could be read.</p><p>Then the machinery from sections 4 through 8 takes over. The gateway’s reconciliation job runs. Tonight’s settlement file arrives from the bank listing a successful ₹10,000 authorization. The engine matches it against a ledger entry marked FAILED. Row two of the mismatch table. It fires an automatic reversal, and the hold on your account releases.</p><p>Nobody lied to you. The system just didn’t know yet, and it was built to find out.</p><h3>What to actually take away</h3><p>A payment system’s job is <strong>not</strong> to be correct at every instant. That’s provably impossible during a network partition. Its job is to be <strong>eventually, verifiably correct</strong>, and to never lose money while getting there.</p><p>Every technique here serves that one goal:</p><ul><li><strong>Idempotency</strong> so retries don’t duplicate money.</li><li><strong>Event-driven design</strong> so one slow service can’t take down authorization.</li><li><strong>Backoff, jitter and circuit breakers</strong> so a dying bank doesn’t take you with it.</li><li><strong>Multi-bank routing</strong> so one bank isn’t a single point of failure.</li><li><strong>Append-only ledgers</strong> so you can prove what happened months later.</li><li><strong>Reconciliation</strong> as the ground truth that overrules whatever your system believed.</li></ul><p>The next time a payment fails and the money still leaves your account, you’ll know precisely what happened. A response packet died in transit, and a batch job scheduled for tomorrow morning is already going to fix it.Engineering Money at Scale</p><h3>One ₹10,000 payment, followed all the way down.</h3><p>You tap Pay. ₹10,000.</p><p>Your bank sends an SMS: <strong>debited</strong>. The merchant’s page says: <strong>Payment Failed</strong>. The gateway’s logs say: <strong>TIMEOUT</strong>.</p><p>Three systems, three different answers, and here’s the uncomfortable part: none of them is lying. Every one of them is reporting the truth as it knows it.</p><p>Most people assume somebody screwed up. A bad deploy, a lazy engineer, a cheap server. Almost never. What you just experienced is the normal, designed-for behaviour of a distributed system that moves real money across networks it doesn’t own, through banks it can’t control, in under three seconds.</p><p>We’re going to follow that exact payment through a production payment system. By the end you’ll know precisely where your ₹10,000 went and why it comes back.</p><p><strong>Contents</strong></p><ol><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#1">Who actually moves the money</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#2">Anatomy of a ₹10,000 transaction</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#3">The real problem: distributed systems plus money</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#4">Idempotency</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#5">Event-driven payments</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#6">Making banks fail gracefully</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#7">Reconciliation, refunds and chargebacks</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#8">Self-healing and disaster recovery</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#9">The final boss</a></li></ol><p>&lt;a name=”1&quot;&gt;&lt;/a&gt;</p><h3>1. Who actually moves the money?</h3><p>You think of a payment as two parties: you and the shop. It’s closer to eight, and each one has a specific job.</p><p><strong>Customer.</strong> You. You have an account at a bank, and a card or UPI handle that points to it.</p><p><strong>Merchant.</strong> The business taking your money. Wants payments to work, does not want to build payment infrastructure, and legally cannot touch card numbers without heavy PCI-DSS compliance.</p><p><strong>Payment Gateway.</strong> The piece that captures payment details, encrypts them, and forwards them toward the banking network. Pure plumbing. Think of it as a secure courier: it doesn’t hold your money, it carries the message.</p><p><strong>Payment Aggregator.</strong> Here’s the problem a gateway alone doesn’t solve. To receive money directly, every merchant needs its own merchant account with an acquiring bank, which means paperwork, underwriting, and weeks of onboarding. An aggregator solves this by holding one master merchant account and letting thousands of small merchants sit underneath it. <strong>Razorpay</strong> and <strong>Cashfree</strong> are aggregators. This is why a two-person startup in Chennai can accept payments the same afternoon it signs up.</p><p><strong>Payment Service Provider (PSP).</strong> The umbrella term for anyone providing the technical and financial pipes to accept payments. In UPI specifically it has an exact meaning: the PSP is the entity that holds your UPI handle and talks to NPCI on your behalf. When you use yourname@ybl, Yes Bank is the PSP behind PhonePe.</p><p><strong>Payment Orchestrator.</strong> A layer above the gateways. It doesn’t process payments itself; it decides <em>which</em> gateway or bank to route each payment through, in real time, based on who’s healthy right now. <strong>Juspay</strong> is the well-known Indian example, and this distinction matters more than it sounds. Two companies can use the exact same underlying banks and see success rates several percentage points apart purely on routing quality.</p><p><strong>Wallets.</strong> <strong>MobiKwik</strong> and similar. A prepaid balance you top up, which becomes its own funding source. Faster than a card because the money is already inside the system, but it’s a closed loop until it settles out.</p><p><strong>Acquiring Bank.</strong> The merchant’s bank. It “acquires” the transaction on the merchant’s behalf, takes on the risk, and eventually deposits money in the merchant’s account.</p><p><strong>Issuing Bank.</strong> Your bank. It “issued” your card or account. It is the only party in this entire chain that can actually say yes or no, because it’s the only one holding your ₹10,000.</p><p><strong>Card Networks.</strong> Visa, Mastercard, RuPay, Amex. They’re not banks and they don’t lend you money. They operate the rails and the rulebook that let an acquiring bank in one country talk to an issuing bank in another. They also set interchange fees and run the dispute process.</p><p><strong>UPI and NPCI.</strong> In India, UPI bypasses card rails entirely. NPCI runs the switch. Instead of a card number moving through Visa, a virtual payment address moves through NPCI, which routes it directly bank-to-bank. Lower cost, different failure modes, and the reason India’s payment volumes look the way they do.</p><pre>You                                                    Your Bank<br>   │                                                     (Issuer)<br>   ▼                                                         ▲<br>Merchant ──► Gateway ──► Aggregator ──► Network ──► Acquiring│<br>                          / PSP        (Visa/NPCI)   Bank ───┘<br>                             ▲<br>                             │<br>                      Orchestrator<br>                    (routes across many)</pre><p><strong>So when you click Pay, who touches your money?</strong> Strictly speaking, only two entities ever <em>hold</em> it: your issuing bank and, eventually, the acquiring bank. Everyone in between touches the <em>message about</em> your money. That distinction is the entire subject of this article, because messages get lost and money doesn’t.</p><p>&lt;a name=”2&quot;&gt;&lt;/a&gt;</p><h3>2. Anatomy of a ₹10,000 transaction</h3><p>Six stages. Most people think it’s one.</p><pre>Customer<br>   ↓  initiation<br>Merchant<br>   ↓<br>Gateway / PSP<br>   ↓  authentication<br>Payment Network<br>   ↓<br>Acquiring Bank<br>   ↓<br>Issuing Bank<br>   ↓  authorization<br>Response  ──────────────┐<br>   ↓  capture           │  (this return path<br>Processing              │   is where things<br>   ↓                    │   go wrong)<br>Settlement  ────────────┘</pre><p><strong>Initiation.</strong> You submit payment details. The merchant’s server never sees your card number if they’re doing it right; the gateway hands the browser a token or hosted field, so raw card data goes straight to the gateway. This is not paranoia, it’s the difference between a PCI-DSS scope of one form field and a scope of your entire backend.</p><p><strong>Authentication.</strong> Proving you are you. 3D Secure for cards, which is that OTP screen redirecting you to your bank’s domain. UPI PIN for UPI. Note what’s happening here: the merchant and gateway are deliberately cut out of the loop. Your bank authenticates you directly and tells everyone else the result. Nobody in the middle ever sees your PIN.</p><p><strong>Authorization.</strong> Your issuing bank checks balance, fraud rules, velocity limits, and card status, then either approves or declines. On approval it places a <strong>hold</strong> on ₹10,000. Your available balance drops. <strong>No money has moved.</strong> This is a promise, not a transfer.</p><p><strong>Capture.</strong> The merchant claims the authorized amount. For most e-commerce this is automatic and instant. For hotels, car rentals and fuel pumps it isn’t, which is why a petrol pump holds ₹5,000 on your card and captures ₹1,847 later. Auth and capture are separate operations for a reason.</p><p><strong>Processing / Clearing.</strong> The network batches captured transactions and exchanges them between banks. Fees get calculated. Interchange gets split between issuer, acquirer and network.</p><p><strong>Settlement.</strong> Money actually leaves your account and lands in the merchant’s, in a batch, on a schedule. <strong>T+1 or T+2 for most Indian merchants</strong>, longer for higher-risk categories.</p><h3>Authorization ≠ Settlement</h3><p>This single line explains most confusion about “where is my money.”</p><p>Authorization Settlement When Instant T+1, T+2 or later What moved Nothing Actual funds Reversible by Void / auth expiry Refund Who knows Everyone, immediately A batch file, hours later</p><p>Your “instant” payment was a reservation. The transfer happens later, quietly, in a file. Hold onto that, because it’s the mechanism that eventually returns your ₹10,000.</p><p>&lt;a name=”3&quot;&gt;&lt;/a&gt;</p><h3>3. The real problem: distributed systems plus money</h3><p>Now the engineering nightmare. Here is everything that can go wrong on a single payment, and why each one is genuinely hard.</p><p><strong>The bank responds slowly.</strong> Not down, just slow. 8 seconds instead of 400ms. Your threads are all blocked waiting. Your connection pool drains. Traffic that has nothing to do with that bank starts failing too. Slowness spreads further than outages do, because an outage fails fast and slowness holds your resources hostage.</p><p><strong>The network times out.</strong> You sent the request. You got nothing back. See below, this is the big one.</p><p><strong>The API request gets duplicated.</strong> A user double-taps. A load balancer retries on a 504. A mobile client on flaky 4G resends. Your service now sees two identical payment requests and has to decide whether they’re one payment or two.</p><p><strong>The bank succeeds but the response is lost.</strong> The money moved. You don’t know. Your system says failed. The customer’s balance says otherwise.</p><p><strong>Your payment service crashes mid-flow.</strong> You wrote “authorization sent” to the database, called the bank, and the pod got OOM-killed before writing the result. On restart, what state is that payment in? You need every transaction to be in a persisted, resumable state at every step, which means writing intent <em>before</em> acting, always.</p><p><strong>The database becomes unavailable.</strong> You cannot record what happened. Do you keep accepting payments and risk having no record, or reject payments you could have processed? In money, the answer is always reject. An unrecorded payment is worse than a declined one.</p><p><strong>Two systems disagree about status.</strong> Your ledger says SUCCESS, the bank’s file says FAILED. Both are internally consistent. Somebody has to be authoritative, and it is never you.</p><h3>The Two Generals Problem</h3><p>Strip the scenario down. You send a request. The response doesn’t arrive. What happened?</p><ul><li>The bank never received it?</li><li>The bank received it, declined it, and the response was lost?</li><li>The bank received it, <strong>approved it, moved ₹10,000</strong>, and the response was lost?</li></ul><p>You cannot tell. Not with better logging, not with a faster client, not with more retries. The information physically does not exist on your side of the wire.</p><p>This is the Two Generals Problem in a suit. Two parties communicating over an unreliable channel can never both become certain the other received a message. You can stack acknowledgements forever and never close the gap. It is proven impossible, not merely difficult.</p><p>Which gives us the single most important sentence in payments engineering:</p><blockquote><strong><em>A timeout is not a failure. A timeout is an unknown.</em></strong></blockquote><p>Systems that treat timeouts as failures do the obvious thing. They retry. And that’s how people get charged twice.</p><p>&lt;a name=”4&quot;&gt;&lt;/a&gt;</p><h3>4. Idempotency: don’t charge ₹10,000 twice</h3><p>Since a timeout means “unknown,” you <em>must</em> retry to find out. And since retrying might duplicate a real charge, retries have to be safe. That property is <strong>idempotency</strong>: doing an operation N times has the same effect as doing it once.</p><h3>Idempotency keys</h3><p>The client generates a unique key <strong>once</strong>, before the first attempt, and reuses it for every retry of that same logical operation.</p><pre>Attempt 1 → key: PAY_12345 → no record → process → SUCCESS<br>                                          (response lost in transit)</pre><pre>Attempt 2 → key: PAY_12345 → record found → return stored SUCCESS<br>Attempt 3 → key: PAY_12345 → record found → return stored SUCCESS</pre><p>Three requests. One financial operation. Attempts 2 and 3 don’t re-execute anything, they replay a stored result.</p><p>The key must be generated by the <strong>client</strong>, not the server. A server-generated ID is new on every request, which defeats the entire purpose. It must also be tied to the operation’s content, so that a genuine second ₹10,000 payment to the same merchant gets a different key.</p><h3>Unique transaction IDs vs idempotency keys</h3><p>These get conflated constantly. They’re different.</p><ul><li><strong>Idempotency key</strong> is about the <em>request</em>. It answers: have I seen this attempt before?</li><li><strong>Transaction ID</strong> is about the <em>money</em>. It’s your permanent reference for the financial record, used in ledgers, reconciliation and support tickets.</li></ul><p>One idempotency key maps to exactly one transaction ID. Many retries map to one key.</p><h3>Database constraints do the real work</h3><p>Here’s the detail that separates people who’ve read about this from people who’ve shipped it.</p><p>The naive implementation is: check if the key exists, and if not, insert it. That’s two statements with a gap between them, and under concurrent retries, which happen constantly, two requests can both pass the check before either one inserts. You’ve built a race condition into your payment path.</p><p><strong>Put a </strong><strong>UNIQUE constraint on the idempotency key column and insert first.</strong> Let the database reject the duplicate and catch that error. The database is the only component in your stack that can actually serialise that decision. Application-level checking is a suggestion; a unique index is a guarantee.</p><h3>Exactly-once is a lie (mostly)</h3><p>You’ll see “exactly-once delivery” advertised. Over an unreliable network it’s impossible in the general case. What’s actually achievable is:</p><ul><li><strong>At-most-once</strong>: send it, don’t retry. You’ll lose payments. Unacceptable.</li><li><strong>At-least-once</strong>: retry until acknowledged. You’ll get duplicates. Acceptable.</li><li><strong>At-least-once delivery + idempotent processing = exactly-once <em>effect</em></strong>.</li></ul><p>That last line is how every real payment system works. You don’t prevent duplicate messages, you make duplicates harmless.</p><h3>Safe retries</h3><p>A retry is safe only when all three are true: the operation carries an idempotency key, the key is enforced at the database, and the retry policy is bounded. Miss any one and you’re building a double-charge machine with backoff.</p><p>&lt;a name=”5&quot;&gt;&lt;/a&gt;</p><h3>5. Event-driven payments</h3><p>Once a payment is authorized, a lot of things need to happen. Update the ledger. Score it for fraud. Notify the merchant. Email the customer. Feed reconciliation. Update analytics.</p><p>If you do all of that inline before responding, your payment API is only as fast and as available as your <strong>slowest dependency</strong>. The notification service goes down and payments stop. That’s an unacceptable coupling, so payments go asynchronous.</p><h3>Message queues and event buses</h3><p>A <strong>message queue</strong> is point-to-point: one producer, one consumer, message consumed and gone. Good for work distribution, like “process these refunds.”</p><p>An <strong>event bus</strong> is publish-subscribe: one producer, many independent consumers, each reading at its own pace. Kafka is the canonical example. Good for facts, like “payment PAY_12345 was authorized,” where five different services each care for different reasons.</p><p>Payments use both. Auth results go on a bus because many services care. Refund processing goes on a queue because exactly one worker should handle each one.</p><pre>Payment Authorized<br>             │<br>             ▼<br>        Event Bus (Kafka)<br>     ┌───────┼───────┬────────────┐<br>     ▼       ▼       ▼            ▼<br>  Ledger   Risk   Notification  Reconciliation<br>     │<br>     ▼<br>  (settlement pipeline)</pre><p><strong>Producers</strong> publish and move on. They don’t know or care who’s listening, which is exactly the decoupling you want. <strong>Consumers</strong> subscribe, track their own offset, and can be added later without touching the producer. That last property is underrated: six months from now you’ll add a fraud-analytics service, and you’ll add it without redeploying the payment path.</p><h3>Ordering</h3><p>You do <strong>not</strong> want global ordering across all payments. That would serialise your entire throughput onto one partition and cap you at whatever a single consumer can handle.</p><p>You want ordering <strong>per payment</strong>. Partition by payment ID. Then authorized → captured → refunded always arrives in sequence for a given transaction, while a million unrelated transactions process in parallel. Getting the partition key right is one of the highest-leverage decisions in the architecture.</p><h3>Delivery guarantees</h3><p>Kafka and friends give you <strong>at-least-once</strong> by default. Consumers <em>will</em> occasionally see the same event twice, from a rebalance, a redelivery after a crash, or a slow ack.</p><p>Which means the idempotency lesson from section 4 repeats one layer down: <strong>every consumer must be idempotent too.</strong> If your ledger service isn’t, a redelivered event double-credits a merchant. Same bug, different floor of the building.</p><h3>Dead-letter queues</h3><p>Some messages will never succeed. Malformed payload, a referenced record that doesn’t exist, a bug. If you retry them forever they block the partition and everything behind them stalls.</p><p>A <strong>dead-letter queue</strong> catches anything that fails after N attempts and parks it. The stream keeps moving. A human, or an automated repair job, deals with the DLQ later. In payments, “later” is fine. “Blocked” is not, because a blocked partition means every payment behind it is stuck too.</p><p>&lt;a name=”6&quot;&gt;&lt;/a&gt;</p><h3>6. Making banks fail gracefully</h3><p>Banks go down. Not hypothetically. Routinely, often in maintenance windows announced badly or not at all. Your job is to survive it.</p><p><strong>The central question: if Bank A is dying, how do you avoid dying with it?</strong></p><h3>Transient vs permanent failures</h3><p>Before you retry anything, classify the failure. This is the step people skip.</p><ul><li><strong>Transient</strong>: timeout, 503, connection reset, “bank temporarily unavailable.” Retry these.</li><li><strong>Permanent</strong>: insufficient funds, card expired, invalid credentials, fraud decline. <strong>Never retry these.</strong> Retrying a declined card doesn’t get you a different answer, it gets you rate-limited by the bank and flagged for suspicious behaviour.</li></ul><p>A retry policy without failure classification is a way to convert one problem into two.</p><h3>Exponential backoff and jitter</h3><p>If ten thousand requests fail and all retry after exactly one second, you’ve built a synchronised hammer that hits the recovering bank ten thousand times at once. It falls over again. That’s a <strong>thundering herd</strong>, and it turns a 30-second blip into a 30-minute outage.</p><p><strong>Exponential backoff</strong>: wait 1s, then 2s, 4s, 8s. Gives the dependency room to breathe.</p><p><strong>Jitter</strong>: add a random offset so retries spread out instead of arriving as a wave. Backoff without jitter still synchronises your clients, just at wider intervals. Jitter is not optional.</p><p><strong>Retry limits</strong>: bounded, always. Typically 3 to 5 attempts, then stop and mark the payment for reconciliation rather than retrying into the void.</p><h3>Circuit breakers</h3><p>A piece of state sitting in front of each dependency, with three modes:</p><pre>┌──────────┐  failures &gt; threshold   ┌────────┐<br>   │  CLOSED  │ ──────────────────────► │  OPEN  │<br>   │ traffic  │                         │ reject │<br>   │  flows   │ ◄────────────────────── │  fast  │<br>   └──────────┘      probe succeeds     └────────┘<br>        ▲                                    │<br>        │                                    │ after cooldown<br>        │            ┌────────────┐          │<br>        └────────────│ HALF-OPEN  │ ◄────────┘<br>                     │ let a few  │<br>                     │  through   │<br>                     └────────────┘</pre><p><strong>Closed</strong>: normal operation, failures counted in a rolling window. <strong>Open</strong>: threshold crossed. Stop calling entirely. Fail immediately, in microseconds, without waiting for a timeout. <strong>Half-open</strong>: after a cooldown, allow a handful of probe requests. Success closes the circuit. Failure trips it open again.</p><p>The counter-intuitive part is that Open state deliberately rejects requests that <em>might</em> have succeeded. That’s the trade, and it’s the right one. Failing 10,000 requests in 5ms each is far better than hanging 10,000 requests for 30 seconds each and exhausting every thread you own. The circuit breaker exists to protect <strong>you</strong>, not the bank.</p><h3>Failover and multi-bank routing</h3><p><strong>Primary and secondary</strong>: if HDFC’s acquiring endpoint is degraded, route to ICICI. Same payment, different rail.</p><p><strong>Multi-bank routing</strong> goes further and makes routing a live decision based on real-time success rates, latency, cost per transaction, and card BIN. A Kotak card might have a 96% success rate through one gateway and 89% through another at 3pm on a Friday. Routing on that data is worth real money, and it’s exactly why orchestration layers exist as a business.</p><h3>Load management</h3><p><strong>Rate limiting.</strong> Every bank imposes TPS caps. Exceed them and they throttle or block you outright. You rate-limit <em>outbound</em> traffic per bank to stay under their ceiling, and <em>inbound</em> per merchant so one client can’t consume your whole quota.</p><p><strong>Backpressure.</strong> When downstream can’t keep up, the pressure has to go somewhere. The wrong answer is to buffer infinitely until you run out of memory and lose everything in flight. The right answer is to push the signal upstream: slow your consumers, reject new work at the edge with a clear 429, and let clients back off. Backpressure is the system admitting its limits instead of pretending.</p><p><strong>Queue buffering.</strong> Absorb spikes rather than dropping them. A festival sale sends 10x normal traffic for twenty minutes. You can’t scale the bank, but you can queue and drain at a sustainable rate. Payments tolerate a few seconds of added latency far better than they tolerate failures.</p><p>&lt;a name=”7&quot;&gt;&lt;/a&gt;</p><h3>7. Reconciliation, refunds and chargebacks</h3><p>This is the financial correctness layer. Everything above tries to prevent problems. This part assumes prevention failed and fixes reality anyway.</p><h3>The mismatch</h3><pre>Our system   →  SUCCESS<br>Bank report  →  SUCCESS<br>Settlement   →  MISSING      ⚠</pre><p>Money that should have arrived, didn’t. Or arrived and shouldn’t have. Both happen daily at any real scale.</p><h3>The moving parts</h3><p><strong>Transaction ledger.</strong> Your internal, append-only record of every state change on every payment. Append-only matters: you never update a row to change history, you write a new entry. authorized → captured → refunded is four rows, not one row edited four times. When a dispute happens eight months later, you need the sequence, not the current value.</p><p><strong>Bank reports and settlement files.</strong> Every day, banks and networks send flat files listing every transaction they believe happened, with amounts, fees, and status. Often still CSV over SFTP. Unglamorous, and it is the actual source of truth.</p><p><strong>Reconciliation engine.</strong> The job that does a three-way match: your ledger, the bank’s report, and money actually received. It runs daily, sometimes hourly, and classifies every discrepancy.</p><h3>Mismatch types and their fixes</h3><p>Our ledger Bank file Reality Action SUCCESS absent no money We were wrong. Mark failed. FAILED SUCCESS money moved <strong>We lost the response. Auto-refund.</strong> SUCCESS SUCCESS not settled Chase the bank. ₹10,000 ₹9,982 fees deducted Expected. Book the fee. ₹10,000 ₹8,000 genuine mismatch Manual queue. Human review.</p><p><strong>Automated reconciliation</strong> handles the known patterns, which is 95%+ of volume. <strong>Manual reconciliation</strong> handles the rest, and every payments company has a team doing exactly this. The goal isn’t zero manual work, it’s keeping manual work bounded as volume grows.</p><p>Row two is your ₹10,000. Remember it.</p><h3>Refunds</h3><p>A refund is <strong>merchant-initiated</strong>. You ask, the merchant agrees, money flows back along the same rails.</p><pre>SUCCESS<br>   ↓  refund requested<br>PROCESSING<br>   ↓  bank confirms<br>REFUNDED</pre><p>Engineering notes that matter: a refund is its own transaction with its own idempotency key, because double-refunding is as bad as double-charging. It must be linked to the original payment ID. And you must guard against refunding more than the original amount across multiple partial refunds, which is a real bug people ship.</p><p>Refunds are slower than payments because they ride the settlement cycle. That “5–7 working days” isn’t a brush-off, it’s a batch file and a clearing cycle.</p><h3>Chargebacks</h3><p>A chargeback is <strong>customer-initiated, through their bank, against the merchant’s will.</strong> That distinction is everything.</p><p><strong>Refund ≠ Chargeback:</strong></p><p>Refund Chargeback Initiated by Merchant Customer, via issuing bank Merchant consent Yes No Cost to merchant Transaction fee Fee <strong>plus</strong> penalty, often ₹500–2,000 Timeline Days Weeks to months Reputation None Tracked; high ratios get you terminated</p><p>How a dispute propagates:</p><pre>Customer disputes with issuing bank<br>        ↓<br>Issuing bank provisionally credits customer, raises dispute<br>        ↓<br>Card network / NPCI routes it to acquiring bank<br>        ↓<br>Acquiring bank debits merchant, requests evidence<br>        ↓<br>Merchant submits proof of delivery, logs, auth records<br>        ↓<br>Network arbitrates → won or lost</pre><p>The engineering consequence: your system needs to reproduce, months later, exactly what happened during a payment. Auth codes, timestamps, IP, device fingerprint, 3DS result, delivery confirmation. If your logging has a 30-day retention and a chargeback lands on day 45, you lose by default. Not because you were wrong, but because you can’t prove you were right.</p><p>And the ratio matters. Networks track chargebacks as a percentage of transactions. Cross roughly 1% and you enter monitoring programmes. Stay there and your acquirer drops you.</p><p>&lt;a name=”8&quot;&gt;&lt;/a&gt;</p><h3>8. Self-healing and disaster recovery</h3><p>Zoom all the way out. What kills a payment system, and what keeps it alive?</p><p><strong>Database failure.</strong> Replication with automatic promotion. A primary with synchronous replicas for the ledger, because in payments you accept slower writes to guarantee no committed transaction is lost. For non-financial data, async replication is fine. Choose per dataset, not globally.</p><p><strong>Service failure.</strong> Redundancy plus <strong>health checks</strong>. Distinguish liveness (“is the process running”) from readiness (“can it actually serve traffic”). A payment service that’s up but has lost its database connection must fail readiness so the load balancer stops sending it work. Instances that fail health checks get pulled and replaced automatically.</p><p><strong>Bank outage.</strong> Circuit breakers and multi-bank routing from section 6.</p><p><strong>Network outage.</strong> Multiple availability zones, redundant paths, and the assumption that any single link will vanish without notice.</p><p><strong>Region failure.</strong> Multi-region deployment with the ability to fail over. This is where it gets genuinely hard, because financial data has residency requirements and cross-region replication has real lag. Most Indian payment companies run multi-AZ within a region and treat full region failover as a documented, rehearsed manual process rather than an automatic one.</p><p><strong>Traffic spikes.</strong> Autoscaling, queue buffering, rate limiting, and load shedding. When you can’t serve everything, degrade deliberately: keep authorizations alive and let analytics lag.</p><p><strong>Partial failures.</strong> The hardest category and the most common. Not “everything is down” but “the ledger is fine, notifications are dead, and one bank is slow.” The system must keep working in a diminished state without a human deciding what to sacrifice at 3am. That’s what circuit breakers, DLQs and backpressure are all for.</p><h3>Backups, RPO and RTO</h3><p>Two numbers define your disaster posture, and if you can’t state them you don’t have a plan.</p><p><strong>RPO — Recovery Point Objective.</strong> How much data you can afford to lose, measured in time. RPO of 5 minutes means a disaster could cost you the last 5 minutes of writes. <strong>For a payment ledger, the target is effectively zero</strong>, which is why you use synchronous replication and write-ahead logs rather than periodic snapshots. Losing five minutes of payments means losing money that customers were actually charged.</p><p><strong>RTO — Recovery Time Objective.</strong> How long you can afford to be down. Every minute of downtime is failed transactions and merchants losing revenue, so RTO is measured in minutes, not hours.</p><p>Backups still exist for a different reason: replication faithfully replicates corruption and bad deletes. A replica protects you from hardware failure. A backup protects you from a bad migration. You need both, and an untested backup is not a backup.</p><h3>Reconciliation after recovery</h3><p>The step everyone forgets. When you come back up, <strong>you do not know what happened during the outage.</strong> Payments were in flight. Some completed at the bank. Some didn’t. Your records have a hole.</p><p>The recovery sequence:</p><ol><li>Restore service, but <strong>do not</strong> blindly retry in-flight transactions.</li><li>Query the bank for the status of every payment that was pending when you went down. Idempotency keys make this safe, since you can re-query without re-charging.</li><li>Run reconciliation against the bank’s file for the outage window.</li><li>Repair the ledger to match reality.</li><li>Auto-refund anything the bank charged that you failed.</li></ol><p>Reconciliation is the mechanism that converts an outage from a permanent loss into a temporary inconsistency. This is why it’s the last line of defence and not an accounting afterthought.</p><p>&lt;a name=”9&quot;&gt;&lt;/a&gt;</p><h3>9. The final boss</h3><p>Back to where we started.</p><pre>You         →  ₹10,000 deducted<br>Your bank   →  SUCCESS<br>Gateway     →  TIMEOUT<br>Merchant    →  FAILED</pre><p>Here’s exactly what happened, in order.</p><p>Your issuing bank received the authorization request. It checked your balance, ran its fraud rules, approved it, and placed a hold on ₹10,000. From its point of view the transaction is complete and correct. It sent you an SMS because it did what it was asked.</p><p><strong>The response packet died on the way back.</strong> A dropped connection, a load balancer recycling, a two-second GC pause on the wrong node. Doesn’t matter which.</p><p>The gateway waited. Its timeout fired. It knew only one thing: no response. Not “failed”, just <em>unknown</em>. But it has to return something to the merchant within a bounded time, and the safe default when you can’t confirm money moved is to not claim it did. So it reported failure.</p><p>The merchant showed you an error, because the merchant knows only what the gateway told it.</p><p><strong>Every single component behaved correctly.</strong> Nobody had a bug. The system was briefly, structurally wrong about reality, because the fact needed to be right did not exist anywhere it could be read.</p><p>Then the machinery from sections 4 through 8 takes over. The gateway’s reconciliation job runs. Tonight’s settlement file arrives from the bank listing a successful ₹10,000 authorization. The engine matches it against a ledger entry marked FAILED. Row two of the mismatch table. It fires an automatic reversal, and the hold on your account releases.</p><p>Nobody lied to you. The system just didn’t know yet, and it was built to find out.</p><h3>What to actually take away</h3><p>A payment system’s job is <strong>not</strong> to be correct at every instant. That’s provably impossible during a network partition. Its job is to be <strong>eventually, verifiably correct</strong>, and to never lose money while getting there.</p><p>Every technique here serves that one goal:</p><ul><li><strong>Idempotency</strong> so retries don’t duplicate money.</li><li><strong>Event-driven design</strong> so one slow service can’t take down authorization.</li><li><strong>Backoff, jitter and circuit breakers</strong> so a dying bank doesn’t take you with it.</li><li><strong>Multi-bank routing</strong> so one bank isn’t a single point of failure.</li><li><strong>Append-only ledgers</strong> so you can prove what happened months later.</li><li><strong>Reconciliation</strong> as the ground truth that overrules whatever your system believed.</li></ul><p>The next time a payment fails and the money still leaves your account, you’ll know precisely what happened. A response packet died in transit, and a batch job scheduled for tomorrow morning is already going to fix it.Engineering Money at Scale</p><h3>One ₹10,000 payment, followed all the way down.</h3><p>You tap Pay. ₹10,000.</p><p>Your bank sends an SMS: <strong>debited</strong>. The merchant’s page says: <strong>Payment Failed</strong>. The gateway’s logs say: <strong>TIMEOUT</strong>.</p><p>Three systems, three different answers, and here’s the uncomfortable part: none of them is lying. Every one of them is reporting the truth as it knows it.</p><p>Most people assume somebody screwed up. A bad deploy, a lazy engineer, a cheap server. Almost never. What you just experienced is the normal, designed-for behaviour of a distributed system that moves real money across networks it doesn’t own, through banks it can’t control, in under three seconds.</p><p>We’re going to follow that exact payment through a production payment system. By the end you’ll know precisely where your ₹10,000 went and why it comes back.</p><p><strong>Contents</strong></p><ol><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#1">Who actually moves the money</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#2">Anatomy of a ₹10,000 transaction</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#3">The real problem: distributed systems plus money</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#4">Idempotency</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#5">Event-driven payments</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#6">Making banks fail gracefully</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#7">Reconciliation, refunds and chargebacks</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#8">Self-healing and disaster recovery</a></li><li><a href="https://claude.ai/chat/4400986c-7944-491b-b339-877ef44dc317#9">The final boss</a></li></ol><p>&lt;a name=”1&quot;&gt;&lt;/a&gt;</p><h3>1. Who actually moves the money?</h3><p>You think of a payment as two parties: you and the shop. It’s closer to eight, and each one has a specific job.</p><p><strong>Customer.</strong> You. You have an account at a bank, and a card or UPI handle that points to it.</p><p><strong>Merchant.</strong> The business taking your money. Wants payments to work, does not want to build payment infrastructure, and legally cannot touch card numbers without heavy PCI-DSS compliance.</p><p><strong>Payment Gateway.</strong> The piece that captures payment details, encrypts them, and forwards them toward the banking network. Pure plumbing. Think of it as a secure courier: it doesn’t hold your money, it carries the message.</p><p><strong>Payment Aggregator.</strong> Here’s the problem a gateway alone doesn’t solve. To receive money directly, every merchant needs its own merchant account with an acquiring bank, which means paperwork, underwriting, and weeks of onboarding. An aggregator solves this by holding one master merchant account and letting thousands of small merchants sit underneath it. <strong>Razorpay</strong> and <strong>Cashfree</strong> are aggregators. This is why a two-person startup in Chennai can accept payments the same afternoon it signs up.</p><p><strong>Payment Service Provider (PSP).</strong> The umbrella term for anyone providing the technical and financial pipes to accept payments. In UPI specifically it has an exact meaning: the PSP is the entity that holds your UPI handle and talks to NPCI on your behalf. When you use yourname@ybl, Yes Bank is the PSP behind PhonePe.</p><p><strong>Payment Orchestrator.</strong> A layer above the gateways. It doesn’t process payments itself; it decides <em>which</em> gateway or bank to route each payment through, in real time, based on who’s healthy right now. <strong>Juspay</strong> is the well-known Indian example, and this distinction matters more than it sounds. Two companies can use the exact same underlying banks and see success rates several percentage points apart purely on routing quality.</p><p><strong>Wallets.</strong> <strong>MobiKwik</strong> and similar. A prepaid balance you top up, which becomes its own funding source. Faster than a card because the money is already inside the system, but it’s a closed loop until it settles out.</p><p><strong>Acquiring Bank.</strong> The merchant’s bank. It “acquires” the transaction on the merchant’s behalf, takes on the risk, and eventually deposits money in the merchant’s account.</p><p><strong>Issuing Bank.</strong> Your bank. It “issued” your card or account. It is the only party in this entire chain that can actually say yes or no, because it’s the only one holding your ₹10,000.</p><p><strong>Card Networks.</strong> Visa, Mastercard, RuPay, Amex. They’re not banks and they don’t lend you money. They operate the rails and the rulebook that let an acquiring bank in one country talk to an issuing bank in another. They also set interchange fees and run the dispute process.</p><p><strong>UPI and NPCI.</strong> In India, UPI bypasses card rails entirely. NPCI runs the switch. Instead of a card number moving through Visa, a virtual payment address moves through NPCI, which routes it directly bank-to-bank. Lower cost, different failure modes, and the reason India’s payment volumes look the way they do.</p><pre>You                                                    Your Bank<br>   │                                                     (Issuer)<br>   ▼                                                         ▲<br>Merchant ──► Gateway ──► Aggregator ──► Network ──► Acquiring│<br>                          / PSP        (Visa/NPCI)   Bank ───┘<br>                             ▲<br>                             │<br>                      Orchestrator<br>                    (routes across many)</pre><p><strong>So when you click Pay, who touches your money?</strong> Strictly speaking, only two entities ever <em>hold</em> it: your issuing bank and, eventually, the acquiring bank. Everyone in between touches the <em>message about</em> your money. That distinction is the entire subject of this article, because messages get lost and money doesn’t.</p><p>&lt;a name=”2&quot;&gt;&lt;/a&gt;</p><h3>2. Anatomy of a ₹10,000 transaction</h3><p>Six stages. Most people think it’s one.</p><pre>Customer<br>   ↓  initiation<br>Merchant<br>   ↓<br>Gateway / PSP<br>   ↓  authentication<br>Payment Network<br>   ↓<br>Acquiring Bank<br>   ↓<br>Issuing Bank<br>   ↓  authorization<br>Response  ──────────────┐<br>   ↓  capture           │  (this return path<br>Processing              │   is where things<br>   ↓                    │   go wrong)<br>Settlement  ────────────┘</pre><p><strong>Initiation.</strong> You submit payment details. The merchant’s server never sees your card number if they’re doing it right; the gateway hands the browser a token or hosted field, so raw card data goes straight to the gateway. This is not paranoia, it’s the difference between a PCI-DSS scope of one form field and a scope of your entire backend.</p><p><strong>Authentication.</strong> Proving you are you. 3D Secure for cards, which is that OTP screen redirecting you to your bank’s domain. UPI PIN for UPI. Note what’s happening here: the merchant and gateway are deliberately cut out of the loop. Your bank authenticates you directly and tells everyone else the result. Nobody in the middle ever sees your PIN.</p><p><strong>Authorization.</strong> Your issuing bank checks balance, fraud rules, velocity limits, and card status, then either approves or declines. On approval it places a <strong>hold</strong> on ₹10,000. Your available balance drops. <strong>No money has moved.</strong> This is a promise, not a transfer.</p><p><strong>Capture.</strong> The merchant claims the authorized amount. For most e-commerce this is automatic and instant. For hotels, car rentals and fuel pumps it isn’t, which is why a petrol pump holds ₹5,000 on your card and captures ₹1,847 later. Auth and capture are separate operations for a reason.</p><p><strong>Processing / Clearing.</strong> The network batches captured transactions and exchanges them between banks. Fees get calculated. Interchange gets split between issuer, acquirer and network.</p><p><strong>Settlement.</strong> Money actually leaves your account and lands in the merchant’s, in a batch, on a schedule. <strong>T+1 or T+2 for most Indian merchants</strong>, longer for higher-risk categories.</p><h3>Authorization ≠ Settlement</h3><p>This single line explains most confusion about “where is my money.”</p><p>Authorization Settlement When Instant T+1, T+2 or later What moved Nothing Actual funds Reversible by Void / auth expiry Refund Who knows Everyone, immediately A batch file, hours later</p><p>Your “instant” payment was a reservation. The transfer happens later, quietly, in a file. Hold onto that, because it’s the mechanism that eventually returns your ₹10,000.</p><p>&lt;a name=”3&quot;&gt;&lt;/a&gt;</p><h3>3. The real problem: distributed systems plus money</h3><p>Now the engineering nightmare. Here is everything that can go wrong on a single payment, and why each one is genuinely hard.</p><p><strong>The bank responds slowly.</strong> Not down, just slow. 8 seconds instead of 400ms. Your threads are all blocked waiting. Your connection pool drains. Traffic that has nothing to do with that bank starts failing too. Slowness spreads further than outages do, because an outage fails fast and slowness holds your resources hostage.</p><p><strong>The network times out.</strong> You sent the request. You got nothing back. See below, this is the big one.</p><p><strong>The API request gets duplicated.</strong> A user double-taps. A load balancer retries on a 504. A mobile client on flaky 4G resends. Your service now sees two identical payment requests and has to decide whether they’re one payment or two.</p><p><strong>The bank succeeds but the response is lost.</strong> The money moved. You don’t know. Your system says failed. The customer’s balance says otherwise.</p><p><strong>Your payment service crashes mid-flow.</strong> You wrote “authorization sent” to the database, called the bank, and the pod got OOM-killed before writing the result. On restart, what state is that payment in? You need every transaction to be in a persisted, resumable state at every step, which means writing intent <em>before</em> acting, always.</p><p><strong>The database becomes unavailable.</strong> You cannot record what happened. Do you keep accepting payments and risk having no record, or reject payments you could have processed? In money, the answer is always reject. An unrecorded payment is worse than a declined one.</p><p><strong>Two systems disagree about status.</strong> Your ledger says SUCCESS, the bank’s file says FAILED. Both are internally consistent. Somebody has to be authoritative, and it is never you.</p><h3>The Two Generals Problem</h3><p>Strip the scenario down. You send a request. The response doesn’t arrive. What happened?</p><ul><li>The bank never received it?</li><li>The bank received it, declined it, and the response was lost?</li><li>The bank received it, <strong>approved it, moved ₹10,000</strong>, and the response was lost?</li></ul><p>You cannot tell. Not with better logging, not with a faster client, not with more retries. The information physically does not exist on your side of the wire.</p><p>This is the Two Generals Problem in a suit. Two parties communicating over an unreliable channel can never both become certain the other received a message. You can stack acknowledgements forever and never close the gap. It is proven impossible, not merely difficult.</p><p>Which gives us the single most important sentence in payments engineering:</p><blockquote><strong><em>A timeout is not a failure. A timeout is an unknown.</em></strong></blockquote><p>Systems that treat timeouts as failures do the obvious thing. They retry. And that’s how people get charged twice.</p><p>&lt;a name=”4&quot;&gt;&lt;/a&gt;</p><h3>4. Idempotency: don’t charge ₹10,000 twice</h3><p>Since a timeout means “unknown,” you <em>must</em> retry to find out. And since retrying might duplicate a real charge, retries have to be safe. That property is <strong>idempotency</strong>: doing an operation N times has the same effect as doing it once.</p><h3>Idempotency keys</h3><p>The client generates a unique key <strong>once</strong>, before the first attempt, and reuses it for every retry of that same logical operation.</p><pre>Attempt 1 → key: PAY_12345 → no record → process → SUCCESS<br>                                          (response lost in transit)</pre><pre>Attempt 2 → key: PAY_12345 → record found → return stored SUCCESS<br>Attempt 3 → key: PAY_12345 → record found → return stored SUCCESS</pre><p>Three requests. One financial operation. Attempts 2 and 3 don’t re-execute anything, they replay a stored result.</p><p>The key must be generated by the <strong>client</strong>, not the server. A server-generated ID is new on every request, which defeats the entire purpose. It must also be tied to the operation’s content, so that a genuine second ₹10,000 payment to the same merchant gets a different key.</p><h3>Unique transaction IDs vs idempotency keys</h3><p>These get conflated constantly. They’re different.</p><ul><li><strong>Idempotency key</strong> is about the <em>request</em>. It answers: have I seen this attempt before?</li><li><strong>Transaction ID</strong> is about the <em>money</em>. It’s your permanent reference for the financial record, used in ledgers, reconciliation and support tickets.</li></ul><p>One idempotency key maps to exactly one transaction ID. Many retries map to one key.</p><h3>Database constraints do the real work</h3><p>Here’s the detail that separates people who’ve read about this from people who’ve shipped it.</p><p>The naive implementation is: check if the key exists, and if not, insert it. That’s two statements with a gap between them, and under concurrent retries, which happen constantly, two requests can both pass the check before either one inserts. You’ve built a race condition into your payment path.</p><p><strong>Put a </strong><strong>UNIQUE constraint on the idempotency key column and insert first.</strong> Let the database reject the duplicate and catch that error. The database is the only component in your stack that can actually serialise that decision. Application-level checking is a suggestion; a unique index is a guarantee.</p><h3>Exactly-once is a lie (mostly)</h3><p>You’ll see “exactly-once delivery” advertised. Over an unreliable network it’s impossible in the general case. What’s actually achievable is:</p><ul><li><strong>At-most-once</strong>: send it, don’t retry. You’ll lose payments. Unacceptable.</li><li><strong>At-least-once</strong>: retry until acknowledged. You’ll get duplicates. Acceptable.</li><li><strong>At-least-once delivery + idempotent processing = exactly-once <em>effect</em></strong>.</li></ul><p>That last line is how every real payment system works. You don’t prevent duplicate messages, you make duplicates harmless.</p><h3>Safe retries</h3><p>A retry is safe only when all three are true: the operation carries an idempotency key, the key is enforced at the database, and the retry policy is bounded. Miss any one and you’re building a double-charge machine with backoff.</p><p>&lt;a name=”5&quot;&gt;&lt;/a&gt;</p><h3>5. Event-driven payments</h3><p>Once a payment is authorized, a lot of things need to happen. Update the ledger. Score it for fraud. Notify the merchant. Email the customer. Feed reconciliation. Update analytics.</p><p>If you do all of that inline before responding, your payment API is only as fast and as available as your <strong>slowest dependency</strong>. The notification service goes down and payments stop. That’s an unacceptable coupling, so payments go asynchronous.</p><h3>Message queues and event buses</h3><p>A <strong>message queue</strong> is point-to-point: one producer, one consumer, message consumed and gone. Good for work distribution, like “process these refunds.”</p><p>An <strong>event bus</strong> is publish-subscribe: one producer, many independent consumers, each reading at its own pace. Kafka is the canonical example. Good for facts, like “payment PAY_12345 was authorized,” where five different services each care for different reasons.</p><p>Payments use both. Auth results go on a bus because many services care. Refund processing goes on a queue because exactly one worker should handle each one.</p><pre>Payment Authorized<br>             │<br>             ▼<br>        Event Bus (Kafka)<br>     ┌───────┼───────┬────────────┐<br>     ▼       ▼       ▼            ▼<br>  Ledger   Risk   Notification  Reconciliation<br>     │<br>     ▼<br>  (settlement pipeline)</pre><p><strong>Producers</strong> publish and move on. They don’t know or care who’s listening, which is exactly the decoupling you want. <strong>Consumers</strong> subscribe, track their own offset, and can be added later without touching the producer. That last property is underrated: six months from now you’ll add a fraud-analytics service, and you’ll add it without redeploying the payment path.</p><h3>Ordering</h3><p>You do <strong>not</strong> want global ordering across all payments. That would serialise your entire throughput onto one partition and cap you at whatever a single consumer can handle.</p><p>You want ordering <strong>per payment</strong>. Partition by payment ID. Then authorized → captured → refunded always arrives in sequence for a given transaction, while a million unrelated transactions process in parallel. Getting the partition key right is one of the highest-leverage decisions in the architecture.</p><h3>Delivery guarantees</h3><p>Kafka and friends give you <strong>at-least-once</strong> by default. Consumers <em>will</em> occasionally see the same event twice, from a rebalance, a redelivery after a crash, or a slow ack.</p><p>Which means the idempotency lesson from section 4 repeats one layer down: <strong>every consumer must be idempotent too.</strong> If your ledger service isn’t, a redelivered event double-credits a merchant. Same bug, different floor of the building.</p><h3>Dead-letter queues</h3><p>Some messages will never succeed. Malformed payload, a referenced record that doesn’t exist, a bug. If you retry them forever they block the partition and everything behind them stalls.</p><p>A <strong>dead-letter queue</strong> catches anything that fails after N attempts and parks it. The stream keeps moving. A human, or an automated repair job, deals with the DLQ later. In payments, “later” is fine. “Blocked” is not, because a blocked partition means every payment behind it is stuck too.</p><p>&lt;a name=”6&quot;&gt;&lt;/a&gt;</p><h3>6. Making banks fail gracefully</h3><p>Banks go down. Not hypothetically. Routinely, often in maintenance windows announced badly or not at all. Your job is to survive it.</p><p><strong>The central question: if Bank A is dying, how do you avoid dying with it?</strong></p><h3>Transient vs permanent failures</h3><p>Before you retry anything, classify the failure. This is the step people skip.</p><ul><li><strong>Transient</strong>: timeout, 503, connection reset, “bank temporarily unavailable.” Retry these.</li><li><strong>Permanent</strong>: insufficient funds, card expired, invalid credentials, fraud decline. <strong>Never retry these.</strong> Retrying a declined card doesn’t get you a different answer, it gets you rate-limited by the bank and flagged for suspicious behaviour.</li></ul><p>A retry policy without failure classification is a way to convert one problem into two.</p><h3>Exponential backoff and jitter</h3><p>If ten thousand requests fail and all retry after exactly one second, you’ve built a synchronised hammer that hits the recovering bank ten thousand times at once. It falls over again. That’s a <strong>thundering herd</strong>, and it turns a 30-second blip into a 30-minute outage.</p><p><strong>Exponential backoff</strong>: wait 1s, then 2s, 4s, 8s. Gives the dependency room to breathe.</p><p><strong>Jitter</strong>: add a random offset so retries spread out instead of arriving as a wave. Backoff without jitter still synchronises your clients, just at wider intervals. Jitter is not optional.</p><p><strong>Retry limits</strong>: bounded, always. Typically 3 to 5 attempts, then stop and mark the payment for reconciliation rather than retrying into the void.</p><h3>Circuit breakers</h3><p>A piece of state sitting in front of each dependency, with three modes:</p><pre>┌──────────┐  failures &gt; threshold   ┌────────┐<br>   │  CLOSED  │ ──────────────────────► │  OPEN  │<br>   │ traffic  │                         │ reject │<br>   │  flows   │ ◄────────────────────── │  fast  │<br>   └──────────┘      probe succeeds     └────────┘<br>        ▲                                    │<br>        │                                    │ after cooldown<br>        │            ┌────────────┐          │<br>        └────────────│ HALF-OPEN  │ ◄────────┘<br>                     │ let a few  │<br>                     │  through   │<br>                     └────────────┘</pre><p><strong>Closed</strong>: normal operation, failures counted in a rolling window. <strong>Open</strong>: threshold crossed. Stop calling entirely. Fail immediately, in microseconds, without waiting for a timeout. <strong>Half-open</strong>: after a cooldown, allow a handful of probe requests. Success closes the circuit. Failure trips it open again.</p><p>The counter-intuitive part is that Open state deliberately rejects requests that <em>might</em> have succeeded. That’s the trade, and it’s the right one. Failing 10,000 requests in 5ms each is far better than hanging 10,000 requests for 30 seconds each and exhausting every thread you own. The circuit breaker exists to protect <strong>you</strong>, not the bank.</p><h3>Failover and multi-bank routing</h3><p><strong>Primary and secondary</strong>: if HDFC’s acquiring endpoint is degraded, route to ICICI. Same payment, different rail.</p><p><strong>Multi-bank routing</strong> goes further and makes routing a live decision based on real-time success rates, latency, cost per transaction, and card BIN. A Kotak card might have a 96% success rate through one gateway and 89% through another at 3pm on a Friday. Routing on that data is worth real money, and it’s exactly why orchestration layers exist as a business.</p><h3>Load management</h3><p><strong>Rate limiting.</strong> Every bank imposes TPS caps. Exceed them and they throttle or block you outright. You rate-limit <em>outbound</em> traffic per bank to stay under their ceiling, and <em>inbound</em> per merchant so one client can’t consume your whole quota.</p><p><strong>Backpressure.</strong> When downstream can’t keep up, the pressure has to go somewhere. The wrong answer is to buffer infinitely until you run out of memory and lose everything in flight. The right answer is to push the signal upstream: slow your consumers, reject new work at the edge with a clear 429, and let clients back off. Backpressure is the system admitting its limits instead of pretending.</p><p><strong>Queue buffering.</strong> Absorb spikes rather than dropping them. A festival sale sends 10x normal traffic for twenty minutes. You can’t scale the bank, but you can queue and drain at a sustainable rate. Payments tolerate a few seconds of added latency far better than they tolerate failures.</p><p>&lt;a name=”7&quot;&gt;&lt;/a&gt;</p><h3>7. Reconciliation, refunds and chargebacks</h3><p>This is the financial correctness layer. Everything above tries to prevent problems. This part assumes prevention failed and fixes reality anyway.</p><h3>The mismatch</h3><pre>Our system   →  SUCCESS<br>Bank report  →  SUCCESS<br>Settlement   →  MISSING      ⚠</pre><p>Money that should have arrived, didn’t. Or arrived and shouldn’t have. Both happen daily at any real scale.</p><h3>The moving parts</h3><p><strong>Transaction ledger.</strong> Your internal, append-only record of every state change on every payment. Append-only matters: you never update a row to change history, you write a new entry. authorized → captured → refunded is four rows, not one row edited four times. When a dispute happens eight months later, you need the sequence, not the current value.</p><p><strong>Bank reports and settlement files.</strong> Every day, banks and networks send flat files listing every transaction they believe happened, with amounts, fees, and status. Often still CSV over SFTP. Unglamorous, and it is the actual source of truth.</p><p><strong>Reconciliation engine.</strong> The job that does a three-way match: your ledger, the bank’s report, and money actually received. It runs daily, sometimes hourly, and classifies every discrepancy.</p><h3>Mismatch types and their fixes</h3><p>Our ledger Bank file Reality Action SUCCESS absent no money We were wrong. Mark failed. FAILED SUCCESS money moved <strong>We lost the response. Auto-refund.</strong> SUCCESS SUCCESS not settled Chase the bank. ₹10,000 ₹9,982 fees deducted Expected. Book the fee. ₹10,000 ₹8,000 genuine mismatch Manual queue. Human review.</p><p><strong>Automated reconciliation</strong> handles the known patterns, which is 95%+ of volume. <strong>Manual reconciliation</strong> handles the rest, and every payments company has a team doing exactly this. The goal isn’t zero manual work, it’s keeping manual work bounded as volume grows.</p><p>Row two is your ₹10,000. Remember it.</p><h3>Refunds</h3><p>A refund is <strong>merchant-initiated</strong>. You ask, the merchant agrees, money flows back along the same rails.</p><pre>SUCCESS<br>   ↓  refund requested<br>PROCESSING<br>   ↓  bank confirms<br>REFUNDED</pre><p>Engineering notes that matter: a refund is its own transaction with its own idempotency key, because double-refunding is as bad as double-charging. It must be linked to the original payment ID. And you must guard against refunding more than the original amount across multiple partial refunds, which is a real bug people ship.</p><p>Refunds are slower than payments because they ride the settlement cycle. That “5–7 working days” isn’t a brush-off, it’s a batch file and a clearing cycle.</p><h3>Chargebacks</h3><p>A chargeback is <strong>customer-initiated, through their bank, against the merchant’s will.</strong> That distinction is everything.</p><p><strong>Refund ≠ Chargeback:</strong></p><p>Refund Chargeback Initiated by Merchant Customer, via issuing bank Merchant consent Yes No Cost to merchant Transaction fee Fee <strong>plus</strong> penalty, often ₹500–2,000 Timeline Days Weeks to months Reputation None Tracked; high ratios get you terminated</p><p>How a dispute propagates:</p><pre>Customer disputes with issuing bank<br>        ↓<br>Issuing bank provisionally credits customer, raises dispute<br>        ↓<br>Card network / NPCI routes it to acquiring bank<br>        ↓<br>Acquiring bank debits merchant, requests evidence<br>        ↓<br>Merchant submits proof of delivery, logs, auth records<br>        ↓<br>Network arbitrates → won or lost</pre><p>The engineering consequence: your system needs to reproduce, months later, exactly what happened during a payment. Auth codes, timestamps, IP, device fingerprint, 3DS result, delivery confirmation. If your logging has a 30-day retention and a chargeback lands on day 45, you lose by default. Not because you were wrong, but because you can’t prove you were right.</p><p>And the ratio matters. Networks track chargebacks as a percentage of transactions. Cross roughly 1% and you enter monitoring programmes. Stay there and your acquirer drops you.</p><p>&lt;a name=”8&quot;&gt;&lt;/a&gt;</p><h3>8. Self-healing and disaster recovery</h3><p>Zoom all the way out. What kills a payment system, and what keeps it alive?</p><p><strong>Database failure.</strong> Replication with automatic promotion. A primary with synchronous replicas for the ledger, because in payments you accept slower writes to guarantee no committed transaction is lost. For non-financial data, async replication is fine. Choose per dataset, not globally.</p><p><strong>Service failure.</strong> Redundancy plus <strong>health checks</strong>. Distinguish liveness (“is the process running”) from readiness (“can it actually serve traffic”). A payment service that’s up but has lost its database connection must fail readiness so the load balancer stops sending it work. Instances that fail health checks get pulled and replaced automatically.</p><p><strong>Bank outage.</strong> Circuit breakers and multi-bank routing from section 6.</p><p><strong>Network outage.</strong> Multiple availability zones, redundant paths, and the assumption that any single link will vanish without notice.</p><p><strong>Region failure.</strong> Multi-region deployment with the ability to fail over. This is where it gets genuinely hard, because financial data has residency requirements and cross-region replication has real lag. Most Indian payment companies run multi-AZ within a region and treat full region failover as a documented, rehearsed manual process rather than an automatic one.</p><p><strong>Traffic spikes.</strong> Autoscaling, queue buffering, rate limiting, and load shedding. When you can’t serve everything, degrade deliberately: keep authorizations alive and let analytics lag.</p><p><strong>Partial failures.</strong> The hardest category and the most common. Not “everything is down” but “the ledger is fine, notifications are dead, and one bank is slow.” The system must keep working in a diminished state without a human deciding what to sacrifice at 3am. That’s what circuit breakers, DLQs and backpressure are all for.</p><h3>Backups, RPO and RTO</h3><p>Two numbers define your disaster posture, and if you can’t state them you don’t have a plan.</p><p><strong>RPO — Recovery Point Objective.</strong> How much data you can afford to lose, measured in time. RPO of 5 minutes means a disaster could cost you the last 5 minutes of writes. <strong>For a payment ledger, the target is effectively zero</strong>, which is why you use synchronous replication and write-ahead logs rather than periodic snapshots. Losing five minutes of payments means losing money that customers were actually charged.</p><p><strong>RTO — Recovery Time Objective.</strong> How long you can afford to be down. Every minute of downtime is failed transactions and merchants losing revenue, so RTO is measured in minutes, not hours.</p><p>Backups still exist for a different reason: replication faithfully replicates corruption and bad deletes. A replica protects you from hardware failure. A backup protects you from a bad migration. You need both, and an untested backup is not a backup.</p><h3>Reconciliation after recovery</h3><p>The step everyone forgets. When you come back up, <strong>you do not know what happened during the outage.</strong> Payments were in flight. Some completed at the bank. Some didn’t. Your records have a hole.</p><p>The recovery sequence:</p><ol><li>Restore service, but <strong>do not</strong> blindly retry in-flight transactions.</li><li>Query the bank for the status of every payment that was pending when you went down. Idempotency keys make this safe, since you can re-query without re-charging.</li><li>Run reconciliation against the bank’s file for the outage window.</li><li>Repair the ledger to match reality.</li><li>Auto-refund anything the bank charged that you failed.</li></ol><p>Reconciliation is the mechanism that converts an outage from a permanent loss into a temporary inconsistency. This is why it’s the last line of defence and not an accounting afterthought.</p><p>&lt;a name=”9&quot;&gt;&lt;/a&gt;</p><h3>9. The final boss</h3><p>Back to where we started.</p><pre>You         →  ₹10,000 deducted<br>Your bank   →  SUCCESS<br>Gateway     →  TIMEOUT<br>Merchant    →  FAILED</pre><p>Here’s exactly what happened, in order.</p><p>Your issuing bank received the authorization request. It checked your balance, ran its fraud rules, approved it, and placed a hold on ₹10,000. From its point of view the transaction is complete and correct. It sent you an SMS because it did what it was asked.</p><p><strong>The response packet died on the way back.</strong> A dropped connection, a load balancer recycling, a two-second GC pause on the wrong node. Doesn’t matter which.</p><p>The gateway waited. Its timeout fired. It knew only one thing: no response. Not “failed”, just <em>unknown</em>. But it has to return something to the merchant within a bounded time, and the safe default when you can’t confirm money moved is to not claim it did. So it reported failure.</p><p>The merchant showed you an error, because the merchant knows only what the gateway told it.</p><p><strong>Every single component behaved correctly.</strong> Nobody had a bug. The system was briefly, structurally wrong about reality, because the fact needed to be right did not exist anywhere it could be read.</p><p>Then the machinery from sections 4 through 8 takes over. The gateway’s reconciliation job runs. Tonight’s settlement file arrives from the bank listing a successful ₹10,000 authorization. The engine matches it against a ledger entry marked FAILED. Row two of the mismatch table. It fires an automatic reversal, and the hold on your account releases.</p><p>Nobody lied to you. The system just didn’t know yet, and it was built to find out.</p><h3>What to actually take away</h3><p>A payment system’s job is <strong>not</strong> to be correct at every instant. That’s provably impossible during a network partition. Its job is to be <strong>eventually, verifiably correct</strong>, and to never lose money while getting there.</p><p>Every technique here serves that one goal:</p><ul><li><strong>Idempotency</strong> so retries don’t duplicate money.</li><li><strong>Event-driven design</strong> so one slow service can’t take down authorization.</li><li><strong>Backoff, jitter and circuit breakers</strong> so a dying bank doesn’t take you with it.</li><li><strong>Multi-bank routing</strong> so one bank isn’t a single point of failure.</li><li><strong>Append-only ledgers</strong> so you can prove what happened months later.</li><li><strong>Reconciliation</strong> as the ground truth that overrules whatever your system believed.</li></ul><p>The next time a payment fails and the money still leaves your account, you’ll know precisely what happened. A response packet died in transit, and a batch job scheduled for tomorrow morning is already going to fix it.fdg</p><h3>One ₹10,000 payment, followed all the way down.</h3><p>You tap Pay. ₹10,000.</p><p>Your bank sends an SMS: <strong>debited</strong>. The merchant’s page says: <strong>Payment Failed</strong>. The gateway’s logs say: <strong>TIMEOUT</strong>.</p><p>Three systems, three different answers, and here’s the uncomfortable part: none of them is lying. Every one of them is reporting the truth as it knows it.</p><p>Most people assume somebody screwed up. A bad deploy, a lazy engineer, a cheap server. Almost never. What you just experienced is the normal, designed-for behaviour of a distributed system that moves real money across networks it doesn’t own, through banks it can’t control, in under three seconds.</p><p>We’re going to follow that exact payment through a production payment system. By the end you’ll know precisely where your ₹10,000 went and why it comes back.</p><h3>1. Who actually moves the money?</h3><p>You think of a payment as two parties: you and the shop. It’s closer to eight, and each one has a specific job.</p><p><strong>Customer.</strong> You. You have an account at a bank, and a card or UPI handle that points to it.</p><p><strong>Merchant.</strong> The business taking your money. Wants payments to work, does not want to build payment infrastructure, and legally cannot touch card numbers without heavy PCI-DSS compliance.</p><p><strong>Payment Gateway.</strong> The piece that captures payment details, encrypts them, and forwards them toward the banking network. Pure plumbing. Think of it as a secure courier: it doesn’t hold your money, it carries the message.</p><p><strong>Payment Aggregator.</strong> Here’s the problem a gateway alone doesn’t solve. To receive money directly, every merchant needs its own merchant account with an acquiring bank, which means paperwork, underwriting, and weeks of onboarding. An aggregator solves this by holding one master merchant account and letting thousands of small merchants sit underneath it. <strong>Razorpay</strong> and <strong>Cashfree</strong> are aggregators. This is why a two-person startup in Chennai can accept payments the same afternoon it signs up.</p><p><strong>Payment Service Provider (PSP).</strong> The umbrella term for anyone providing the technical and financial pipes to accept payments. In UPI specifically it has an exact meaning: the PSP is the entity that holds your UPI handle and talks to NPCI on your behalf. When you use yourname@ybl, Yes Bank is the PSP behind PhonePe.</p><p><strong>Payment Orchestrator.</strong> A layer above the gateways. It doesn’t process payments itself; it decides <em>which</em> gateway or bank to route each payment through, in real time, based on who’s healthy right now. <strong>Juspay</strong> is the well-known Indian example, and this distinction matters more than it sounds. Two companies can use the exact same underlying banks and see success rates several percentage points apart purely on routing quality.</p><p><strong>Wallets.</strong> <strong>MobiKwik</strong> and similar. A prepaid balance you top up, which becomes its own funding source. Faster than a card because the money is already inside the system, but it’s a closed loop until it settles out.</p><p><strong>Acquiring Bank.</strong> The merchant’s bank. It “acquires” the transaction on the merchant’s behalf, takes on the risk, and eventually deposits money in the merchant’s account.</p><p><strong>Issuing Bank.</strong> Your bank. It “issued” your card or account. It is the only party in this entire chain that can actually say yes or no, because it’s the only one holding your ₹10,000.</p><p><strong>Card Networks.</strong> Visa, Mastercard, RuPay, Amex. They’re not banks and they don’t lend you money. They operate the rails and the rulebook that let an acquiring bank in one country talk to an issuing bank in another. They also set interchange fees and run the dispute process.</p><p><strong>UPI and NPCI.</strong> In India, UPI bypasses card rails entirely. NPCI runs the switch. Instead of a card number moving through Visa, a virtual payment address moves through NPCI, which routes it directly bank-to-bank. Lower cost, different failure modes, and the reason India’s payment volumes look the way they do.</p><pre>You                                                    Your Bank<br>   │                                                     (Issuer)<br>   ▼                                                         ▲<br>Merchant ──► Gateway ──► Aggregator ──► Network ──► Acquiring│<br>                          / PSP        (Visa/NPCI)   Bank ───┘<br>                             ▲<br>                             │<br>                      Orchestrator<br>                    (routes across many)</pre><p><strong>So when you click Pay, who touches your money?</strong> Strictly speaking, only two entities ever <em>hold</em> it: your issuing bank and, eventually, the acquiring bank. Everyone in between touches the <em>message about</em> your money. That distinction is the entire subject of this article, because messages get lost and money doesn’t.</p><h3>2. Anatomy of a ₹10,000 transaction</h3><p>Six stages. Most people think it’s one.</p><pre>Customer<br>   ↓  initiation<br>Merchant<br>   ↓<br>Gateway / PSP<br>   ↓  authentication<br>Payment Network<br>   ↓<br>Acquiring Bank<br>   ↓<br>Issuing Bank<br>   ↓  authorization<br>Response  ──────────────┐<br>   ↓  capture           │  (this return path<br>Processing              │   is where things<br>   ↓                    │   go wrong)<br>Settlement  ────────────┘</pre><p><strong>Initiation.</strong> You submit payment details. The merchant’s server never sees your card number if they’re doing it right; the gateway hands the browser a token or hosted field, so raw card data goes straight to the gateway. This is not paranoia, it’s the difference between a PCI-DSS scope of one form field and a scope of your entire backend.</p><p><strong>Authentication.</strong> Proving you are you. 3D Secure for cards, which is that OTP screen redirecting you to your bank’s domain. UPI PIN for UPI. Note what’s happening here: the merchant and gateway are deliberately cut out of the loop. Your bank authenticates you directly and tells everyone else the result. Nobody in the middle ever sees your PIN.</p><p><strong>Authorization.</strong> Your issuing bank checks balance, fraud rules, velocity limits, and card status, then either approves or declines. On approval it places a <strong>hold</strong> on ₹10,000. Your available balance drops. <strong>No money has moved.</strong> This is a promise, not a transfer.</p><p><strong>Capture.</strong> The merchant claims the authorized amount. For most e-commerce this is automatic and instant. For hotels, car rentals and fuel pumps it isn’t, which is why a petrol pump holds ₹5,000 on your card and captures ₹1,847 later. Auth and capture are separate operations for a reason.</p><p><strong>Processing / Clearing.</strong> The network batches captured transactions and exchanges them between banks. Fees get calculated. Interchange gets split between issuer, acquirer and network.</p><p><strong>Settlement.</strong> Money actually leaves your account and lands in the merchant’s, in a batch, on a schedule. <strong>T+1 or T+2 for most Indian merchants</strong>, longer for higher-risk categories.</p><h3>Authorization ≠ Settlement</h3><p>This single line explains most confusion about “where is my money.”</p><p>Authorization Settlement When Instant T+1, T+2 or later What moved Nothing Actual funds Reversible by Void / auth expiry Refund Who knows Everyone, immediately A batch file, hours later</p><p>Your “instant” payment was a reservation. The transfer happens later, quietly, in a file. Hold onto that, because it’s the mechanism that eventually returns your ₹10,000.</p><h3>3. The real problem: distributed systems plus money</h3><p>Now the engineering nightmare. Here is everything that can go wrong on a single payment, and why each one is genuinely hard.</p><p><strong>The bank responds slowly.</strong> Not down, just slow. 8 seconds instead of 400ms. Your threads are all blocked waiting. Your connection pool drains. Traffic that has nothing to do with that bank starts failing too. Slowness spreads further than outages do, because an outage fails fast and slowness holds your resources hostage.</p><p><strong>The network times out.</strong> You sent the request. You got nothing back. See below, this is the big one.</p><p><strong>The API request gets duplicated.</strong> A user double-taps. A load balancer retries on a 504. A mobile client on flaky 4G resends. Your service now sees two identical payment requests and has to decide whether they’re one payment or two.</p><p><strong>The bank succeeds but the response is lost.</strong> The money moved. You don’t know. Your system says failed. The customer’s balance says otherwise.</p><p><strong>Your payment service crashes mid-flow.</strong> You wrote “authorization sent” to the database, called the bank, and the pod got OOM-killed before writing the result. On restart, what state is that payment in? You need every transaction to be in a persisted, resumable state at every step, which means writing intent <em>before</em> acting, always.</p><p><strong>The database becomes unavailable.</strong> You cannot record what happened. Do you keep accepting payments and risk having no record, or reject payments you could have processed? In money, the answer is always reject. An unrecorded payment is worse than a declined one.</p><p><strong>Two systems disagree about status.</strong> Your ledger says SUCCESS, the bank’s file says FAILED. Both are internally consistent. Somebody has to be authoritative, and it is never you.</p><h3>The Two Generals Problem</h3><p>Strip the scenario down. You send a request. The response doesn’t arrive. What happened?</p><ul><li>The bank never received it?</li><li>The bank received it, declined it, and the response was lost?</li><li>The bank received it, <strong>approved it, moved ₹10,000</strong>, and the response was lost?</li></ul><p>You cannot tell. Not with better logging, not with a faster client, not with more retries. The information physically does not exist on your side of the wire.</p><p>This is the Two Generals Problem in a suit. Two parties communicating over an unreliable channel can never both become certain the other received a message. You can stack acknowledgements forever and never close the gap. It is proven impossible, not merely difficult.</p><p>Which gives us the single most important sentence in payments engineering:</p><blockquote><strong><em>A timeout is not a failure. A timeout is an unknown.</em></strong></blockquote><p>Systems that treat timeouts as failures do the obvious thing. They retry. And that’s how people get charged twice.</p><h3>4. Idempotency: don’t charge ₹10,000 twice</h3><p>Since a timeout means “unknown,” you <em>must</em> retry to find out. And since retrying might duplicate a real charge, retries have to be safe. That property is <strong>idempotency</strong>: doing an operation N times has the same effect as doing it once.</p><h3>Idempotency keys</h3><p>The client generates a unique key <strong>once</strong>, before the first attempt, and reuses it for every retry of that same logical operation.</p><pre>Attempt 1 → key: PAY_12345 → no record → process → SUCCESS<br>                                          (response lost in transit)</pre><pre>Attempt 2 → key: PAY_12345 → record found → return stored SUCCESS<br>Attempt 3 → key: PAY_12345 → record found → return stored SUCCESS</pre><p>Three requests. One financial operation. Attempts 2 and 3 don’t re-execute anything, they replay a stored result.</p><p>The key must be generated by the <strong>client</strong>, not the server. A server-generated ID is new on every request, which defeats the entire purpose. It must also be tied to the operation’s content, so that a genuine second ₹10,000 payment to the same merchant gets a different key.</p><h3>Unique transaction IDs vs idempotency keys</h3><p>These get conflated constantly. They’re different.</p><ul><li><strong>Idempotency key</strong> is about the <em>request</em>. It answers: have I seen this attempt before?</li><li><strong>Transaction ID</strong> is about the <em>money</em>. It’s your permanent reference for the financial record, used in ledgers, reconciliation and support tickets.</li></ul><p>One idempotency key maps to exactly one transaction ID. Many retries map to one key.</p><h3>Database constraints do the real work</h3><p>Here’s the detail that separates people who’ve read about this from people who’ve shipped it.</p><p>The naive implementation is: check if the key exists, and if not, insert it. That’s two statements with a gap between them, and under concurrent retries, which happen constantly, two requests can both pass the check before either one inserts. You’ve built a race condition into your payment path.</p><p><strong>Put a </strong><strong>UNIQUE constraint on the idempotency key column and insert first.</strong> Let the database reject the duplicate and catch that error. The database is the only component in your stack that can actually serialise that decision. Application-level checking is a suggestion; a unique index is a guarantee.</p><h3>Exactly-once is a lie (mostly)</h3><p>You’ll see “exactly-once delivery” advertised. Over an unreliable network it’s impossible in the general case. What’s actually achievable is:</p><ul><li><strong>At-most-once</strong>: send it, don’t retry. You’ll lose payments. Unacceptable.</li><li><strong>At-least-once</strong>: retry until acknowledged. You’ll get duplicates. Acceptable.</li><li><strong>At-least-once delivery + idempotent processing = exactly-once <em>effect</em></strong>.</li></ul><p>That last line is how every real payment system works. You don’t prevent duplicate messages, you make duplicates harmless.</p><h3>Safe retries</h3><p>A retry is safe only when all three are true: the operation carries an idempotency key, the key is enforced at the database, and the retry policy is bounded. Miss any one and you’re building a double-charge machine with backoff.</p><h3>5. Event-driven payments</h3><p>Once a payment is authorized, a lot of things need to happen. Update the ledger. Score it for fraud. Notify the merchant. Email the customer. Feed reconciliation. Update analytics.</p><p>If you do all of that inline before responding, your payment API is only as fast and as available as your <strong>slowest dependency</strong>. The notification service goes down and payments stop. That’s an unacceptable coupling, so payments go asynchronous.</p><h3>Message queues and event buses</h3><p>A <strong>message queue</strong> is point-to-point: one producer, one consumer, message consumed and gone. Good for work distribution, like “process these refunds.”</p><p>An <strong>event bus</strong> is publish-subscribe: one producer, many independent consumers, each reading at its own pace. Kafka is the canonical example. Good for facts, like “payment PAY_12345 was authorized,” where five different services each care for different reasons.</p><p>Payments use both. Auth results go on a bus because many services care. Refund processing goes on a queue because exactly one worker should handle each one.</p><pre>Payment Authorized<br>             │<br>             ▼<br>        Event Bus (Kafka)<br>     ┌───────┼───────┬────────────┐<br>     ▼       ▼       ▼            ▼<br>  Ledger   Risk   Notification  Reconciliation<br>     │<br>     ▼<br>  (settlement pipeline)</pre><p><strong>Producers</strong> publish and move on. They don’t know or care who’s listening, which is exactly the decoupling you want. <strong>Consumers</strong> subscribe, track their own offset, and can be added later without touching the producer. That last property is underrated: six months from now you’ll add a fraud-analytics service, and you’ll add it without redeploying the payment path.</p><h3>Ordering</h3><p>You do <strong>not</strong> want global ordering across all payments. That would serialise your entire throughput onto one partition and cap you at whatever a single consumer can handle.</p><p>You want ordering <strong>per payment</strong>. Partition by payment ID. Then authorized → captured → refunded always arrives in sequence for a given transaction, while a million unrelated transactions process in parallel. Getting the partition key right is one of the highest-leverage decisions in the architecture.</p><h3>Delivery guarantees</h3><p>Kafka and friends give you <strong>at-least-once</strong> by default. Consumers <em>will</em> occasionally see the same event twice, from a rebalance, a redelivery after a crash, or a slow ack.</p><p>Which means the idempotency lesson from section 4 repeats one layer down: <strong>every consumer must be idempotent too.</strong> If your ledger service isn’t, a redelivered event double-credits a merchant. Same bug, different floor of the building.</p><h3>Dead-letter queues</h3><p>Some messages will never succeed. Malformed payload, a referenced record that doesn’t exist, a bug. If you retry them forever they block the partition and everything behind them stalls.</p><p>A <strong>dead-letter queue</strong> catches anything that fails after N attempts and parks it. The stream keeps moving. A human, or an automated repair job, deals with the DLQ later. In payments, “later” is fine. “Blocked” is not, because a blocked partition means every payment behind it is stuck too.</p><h3>6. Making banks fail gracefully</h3><p>Banks go down. Not hypothetically. Routinely, often in maintenance windows announced badly or not at all. Your job is to survive it.</p><p><strong>The central question: if Bank A is dying, how do you avoid dying with it?</strong></p><h3>Transient vs permanent failures</h3><p>Before you retry anything, classify the failure. This is the step people skip.</p><ul><li><strong>Transient</strong>: timeout, 503, connection reset, “bank temporarily unavailable.” Retry these.</li><li><strong>Permanent</strong>: insufficient funds, card expired, invalid credentials, fraud decline. <strong>Never retry these.</strong> Retrying a declined card doesn’t get you a different answer, it gets you rate-limited by the bank and flagged for suspicious behaviour.</li></ul><p>A retry policy without failure classification is a way to convert one problem into two.</p><h3>Exponential backoff and jitter</h3><p>If ten thousand requests fail and all retry after exactly one second, you’ve built a synchronised hammer that hits the recovering bank ten thousand times at once. It falls over again. That’s a <strong>thundering herd</strong>, and it turns a 30-second blip into a 30-minute outage.</p><p><strong>Exponential backoff</strong>: wait 1s, then 2s, 4s, 8s. Gives the dependency room to breathe.</p><p><strong>Jitter</strong>: add a random offset so retries spread out instead of arriving as a wave. Backoff without jitter still synchronises your clients, just at wider intervals. Jitter is not optional.</p><p><strong>Retry limits</strong>: bounded, always. Typically 3 to 5 attempts, then stop and mark the payment for reconciliation rather than retrying into the void.</p><h3>Circuit breakers</h3><p>A piece of state sitting in front of each dependency, with three modes:</p><pre>┌──────────┐  failures &gt; threshold   ┌────────┐<br>   │  CLOSED  │ ──────────────────────► │  OPEN  │<br>   │ traffic  │                         │ reject │<br>   │  flows   │ ◄────────────────────── │  fast  │<br>   └──────────┘      probe succeeds     └────────┘<br>        ▲                                    │<br>        │                                    │ after cooldown<br>        │            ┌────────────┐          │<br>        └────────────│ HALF-OPEN  │ ◄────────┘<br>                     │ let a few  │<br>                     │  through   │<br>                     └────────────┘</pre><p><strong>Closed</strong>: normal operation, failures counted in a rolling window. <strong>Open</strong>: threshold crossed. Stop calling entirely. Fail immediately, in microseconds, without waiting for a timeout. <strong>Half-open</strong>: after a cooldown, allow a handful of probe requests. Success closes the circuit. Failure trips it open again.</p><p>The counter-intuitive part is that Open state deliberately rejects requests that <em>might</em> have succeeded. That’s the trade, and it’s the right one. Failing 10,000 requests in 5ms each is far better than hanging 10,000 requests for 30 seconds each and exhausting every thread you own. The circuit breaker exists to protect <strong>you</strong>, not the bank.</p><h3>Failover and multi-bank routing</h3><p><strong>Primary and secondary</strong>: if HDFC’s acquiring endpoint is degraded, route to ICICI. Same payment, different rail.</p><p><strong>Multi-bank routing</strong> goes further and makes routing a live decision based on real-time success rates, latency, cost per transaction, and card BIN. A Kotak card might have a 96% success rate through one gateway and 89% through another at 3pm on a Friday. Routing on that data is worth real money, and it’s exactly why orchestration layers exist as a business.</p><h3>Load management</h3><p><strong>Rate limiting.</strong> Every bank imposes TPS caps. Exceed them and they throttle or block you outright. You rate-limit <em>outbound</em> traffic per bank to stay under their ceiling, and <em>inbound</em> per merchant so one client can’t consume your whole quota.</p><p><strong>Backpressure.</strong> When downstream can’t keep up, the pressure has to go somewhere. The wrong answer is to buffer infinitely until you run out of memory and lose everything in flight. The right answer is to push the signal upstream: slow your consumers, reject new work at the edge with a clear 429, and let clients back off. Backpressure is the system admitting its limits instead of pretending.</p><p><strong>Queue buffering.</strong> Absorb spikes rather than dropping them. A festival sale sends 10x normal traffic for twenty minutes. You can’t scale the bank, but you can queue and drain at a sustainable rate. Payments tolerate a few seconds of added latency far better than they tolerate failures.</p><h3>7. Reconciliation, refunds and chargebacks</h3><p>This is the financial correctness layer. Everything above tries to prevent problems. This part assumes prevention failed and fixes reality anyway.</p><h3>The mismatch</h3><pre>Our system   →  SUCCESS<br>Bank report  →  SUCCESS<br>Settlement   →  MISSING      ⚠</pre><p>Money that should have arrived, didn’t. Or arrived and shouldn’t have. Both happen daily at any real scale.</p><h3>The moving parts</h3><p><strong>Transaction ledger.</strong> Your internal, append-only record of every state change on every payment. Append-only matters: you never update a row to change history, you write a new entry. authorized → captured → refunded is four rows, not one row edited four times. When a dispute happens eight months later, you need the sequence, not the current value.</p><p><strong>Bank reports and settlement files.</strong> Every day, banks and networks send flat files listing every transaction they believe happened, with amounts, fees, and status. Often still CSV over SFTP. Unglamorous, and it is the actual source of truth.</p><p><strong>Reconciliation engine.</strong> The job that does a three-way match: your ledger, the bank’s report, and money actually received. It runs daily, sometimes hourly, and classifies every discrepancy.</p><h3>Mismatch types and their fixes</h3><p>Our ledger Bank file Reality Action SUCCESS absent no money We were wrong. Mark failed. FAILED SUCCESS money moved <strong>We lost the response. Auto-refund.</strong> SUCCESS SUCCESS not settled Chase the bank. ₹10,000 ₹9,982 fees deducted Expected. Book the fee. ₹10,000 ₹8,000 genuine mismatch Manual queue. Human review.</p><p><strong>Automated reconciliation</strong> handles the known patterns, which is 95%+ of volume. <strong>Manual reconciliation</strong> handles the rest, and every payments company has a team doing exactly this. The goal isn’t zero manual work, it’s keeping manual work bounded as volume grows.</p><p>Row two is your ₹10,000. Remember it.</p><h3>Refunds</h3><p>A refund is <strong>merchant-initiated</strong>. You ask, the merchant agrees, money flows back along the same rails.</p><pre>SUCCESS<br>   ↓  refund requested<br>PROCESSING<br>   ↓  bank confirms<br>REFUNDED</pre><p>Engineering notes that matter: a refund is its own transaction with its own idempotency key, because double-refunding is as bad as double-charging. It must be linked to the original payment ID. And you must guard against refunding more than the original amount across multiple partial refunds, which is a real bug people ship.</p><p>Refunds are slower than payments because they ride the settlement cycle. That “5–7 working days” isn’t a brush-off, it’s a batch file and a clearing cycle.</p><h3>Chargebacks</h3><p>A chargeback is <strong>customer-initiated, through their bank, against the merchant’s will.</strong> That distinction is everything.</p><p><strong>Refund ≠ Chargeback:</strong></p><p>Refund Chargeback Initiated by Merchant Customer, via issuing bank Merchant consent Yes No Cost to merchant Transaction fee Fee <strong>plus</strong> penalty, often ₹500–2,000 Timeline Days Weeks to months Reputation None Tracked; high ratios get you terminated</p><p>How a dispute propagates:</p><pre>Customer disputes with issuing bank<br>        ↓<br>Issuing bank provisionally credits customer, raises dispute<br>        ↓<br>Card network / NPCI routes it to acquiring bank<br>        ↓<br>Acquiring bank debits merchant, requests evidence<br>        ↓<br>Merchant submits proof of delivery, logs, auth records<br>        ↓<br>Network arbitrates → won or lost</pre><p>The engineering consequence: your system needs to reproduce, months later, exactly what happened during a payment. Auth codes, timestamps, IP, device fingerprint, 3DS result, delivery confirmation. If your logging has a 30-day retention and a chargeback lands on day 45, you lose by default. Not because you were wrong, but because you can’t prove you were right.</p><p>And the ratio matters. Networks track chargebacks as a percentage of transactions. Cross roughly 1% and you enter monitoring programmes. Stay there and your acquirer drops you.</p><h3>8. Self-healing and disaster recovery</h3><p>Zoom all the way out. What kills a payment system, and what keeps it alive?</p><p><strong>Database failure.</strong> Replication with automatic promotion. A primary with synchronous replicas for the ledger, because in payments you accept slower writes to guarantee no committed transaction is lost. For non-financial data, async replication is fine. Choose per dataset, not globally.</p><p><strong>Service failure.</strong> Redundancy plus <strong>health checks</strong>. Distinguish liveness (“is the process running”) from readiness (“can it actually serve traffic”). A payment service that’s up but has lost its database connection must fail readiness so the load balancer stops sending it work. Instances that fail health checks get pulled and replaced automatically.</p><p><strong>Bank outage.</strong> Circuit breakers and multi-bank routing from section 6.</p><p><strong>Network outage.</strong> Multiple availability zones, redundant paths, and the assumption that any single link will vanish without notice.</p><p><strong>Region failure.</strong> Multi-region deployment with the ability to fail over. This is where it gets genuinely hard, because financial data has residency requirements and cross-region replication has real lag. Most Indian payment companies run multi-AZ within a region and treat full region failover as a documented, rehearsed manual process rather than an automatic one.</p><p><strong>Traffic spikes.</strong> Autoscaling, queue buffering, rate limiting, and load shedding. When you can’t serve everything, degrade deliberately: keep authorizations alive and let analytics lag.</p><p><strong>Partial failures.</strong> The hardest category and the most common. Not “everything is down” but “the ledger is fine, notifications are dead, and one bank is slow.” The system must keep working in a diminished state without a human deciding what to sacrifice at 3am. That’s what circuit breakers, DLQs and backpressure are all for.</p><h3>Backups, RPO and RTO</h3><p>Two numbers define your disaster posture, and if you can’t state them you don’t have a plan.</p><p><strong>RPO — Recovery Point Objective.</strong> How much data you can afford to lose, measured in time. RPO of 5 minutes means a disaster could cost you the last 5 minutes of writes. <strong>For a payment ledger, the target is effectively zero</strong>, which is why you use synchronous replication and write-ahead logs rather than periodic snapshots. Losing five minutes of payments means losing money that customers were actually charged.</p><p><strong>RTO — Recovery Time Objective.</strong> How long you can afford to be down. Every minute of downtime is failed transactions and merchants losing revenue, so RTO is measured in minutes, not hours.</p><p>Backups still exist for a different reason: replication faithfully replicates corruption and bad deletes. A replica protects you from hardware failure. A backup protects you from a bad migration. You need both, and an untested backup is not a backup.</p><h3>Reconciliation after recovery</h3><p>The step everyone forgets. When you come back up, <strong>you do not know what happened during the outage.</strong> Payments were in flight. Some completed at the bank. Some didn’t. Your records have a hole.</p><p>The recovery sequence:</p><ol><li>Restore service, but <strong>do not</strong> blindly retry in-flight transactions.</li><li>Query the bank for the status of every payment that was pending when you went down. Idempotency keys make this safe, since you can re-query without re-charging.</li><li>Run reconciliation against the bank’s file for the outage window.</li><li>Repair the ledger to match reality.</li><li>Auto-refund anything the bank charged that you failed.</li></ol><p>Reconciliation is the mechanism that converts an outage from a permanent loss into a temporary inconsistency. This is why it’s the last line of defence and not an accounting afterthought.</p><h3>9. The final boss</h3><p>Back to where we started.</p><pre>You         →  ₹10,000 deducted<br>Your bank   →  SUCCESS<br>Gateway     →  TIMEOUT<br>Merchant    →  FAILED</pre><p>Here’s exactly what happened, in order.</p><p>Your issuing bank received the authorization request. It checked your balance, ran its fraud rules, approved it, and placed a hold on ₹10,000. From its point of view the transaction is complete and correct. It sent you an SMS because it did what it was asked.</p><p><strong>The response packet died on the way back.</strong> A dropped connection, a load balancer recycling, a two-second GC pause on the wrong node. Doesn’t matter which.</p><p>The gateway waited. Its timeout fired. It knew only one thing: no response. Not “failed”, just <em>unknown</em>. But it has to return something to the merchant within a bounded time, and the safe default when you can’t confirm money moved is to not claim it did. So it reported failure.</p><p>The merchant showed you an error, because the merchant knows only what the gateway told it.</p><p><strong>Every single component behaved correctly.</strong> Nobody had a bug. The system was briefly, structurally wrong about reality, because the fact needed to be right did not exist anywhere it could be read.</p><p>Then the machinery from sections 4 through 8 takes over. The gateway’s reconciliation job runs. Tonight’s settlement file arrives from the bank listing a successful ₹10,000 authorization. The engine matches it against a ledger entry marked FAILED. Row two of the mismatch table. It fires an automatic reversal, and the hold on your account releases.</p><p>Nobody lied to you. The system just didn’t know yet, and it was built to find out.</p><h3>What to actually take away</h3><p>A payment system’s job is <strong>not</strong> to be correct at every instant. That’s provably impossible during a network partition. Its job is to be <strong>eventually, verifiably correct</strong>, and to never lose money while getting there.</p><p>Every technique here serves that one goal:</p><ul><li><strong>Idempotency</strong> so retries don’t duplicate money.</li><li><strong>Event-driven design</strong> so one slow service can’t take down authorization.</li><li><strong>Backoff, jitter and circuit breakers</strong> so a dying bank doesn’t take you with it.</li><li><strong>Multi-bank routing</strong> so one bank isn’t a single point of failure.</li><li><strong>Append-only ledgers</strong> so you can prove what happened months later.</li><li><strong>Reconciliation</strong> as the ground truth that overrules whatever your system believed.</li></ul><p>The next time a payment fails and the money still leaves your account, you’ll know precisely what happened. A response packet died in transit, and a batch job scheduled for tomorrow morning is already going to fix it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d202ec189a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WEEK 01 — The Revolution of UPI ]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/week-01-the-revolution-of-upi-091d4a076948?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/091d4a076948</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[upi]]></category>
            <category><![CDATA[banking]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Sat, 22 Aug 2026 08:16:41 GMT</pubDate>
            <atom:updated>2026-08-22T08:16:41.458Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>(WELCOME TO DIVE INTO FINTECH WITH ARYAN </strong>😄 <strong>!!)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPBAmFMGCQJ-220faZtNfQ.png" /></figure><blockquote><strong><em>How did India go from “send me your account number and IFSC” to “just scan this QR” — and somehow make billions of transactions happen every year?</em></strong></blockquote><p>Think about how stupidly easy UPI feels today.</p><p>You scan a QR, enter ₹500, put in your PIN and — <strong>payment successful</strong>.</p><p>But underneath that tiny green tick, banks, payment apps, authentication systems and NPCI infrastructure are all talking to each other.</p><p>So let’s rewind.</p><p><strong>What was actually happening before UPI?</strong></p><h3>01 — Before UPI</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-zrWQ1h36rjwp8FCtGRpOQ.png" /></figure><p>Now let’s decode it.</p><p>Say I have an <strong>ICICI Bank</strong> account and you have an <strong>HDFC Bank</strong> account. I want to send you ₹1,000.</p><p>Before UPI, the payment experience was much more <em>bank-account-ish</em>. You would typically deal with things like the <strong>bank name, account number, IFSC code and branch details</strong>. Basically, you were telling the banking system exactly which account should receive your money.</p><p>India already had electronic payment rails for this.</p><p><strong>NEFT — National Electronic Funds Transfer</strong> handled electronic transfers between bank accounts.</p><p><strong>RTGS — Real Time Gross Settlement</strong> was built for real-time, transaction-by-transaction settlement, especially for high-value payments.</p><p>And then there was <strong>IMPS — Immediate Payment Service</strong>, which brought instant, 24×7 interbank transfers into the ecosystem and became an important foundation for UPI.</p><p>So India could already move money electronically.</p><p>The issue wasn’t really <strong>“Can banks move money?”</strong></p><p>It was:</p><blockquote><strong><em>“Why does the person sending the money have to understand so much banking infrastructure?”</em></strong></blockquote><p>And that is where things get interesting.</p><h3>02 — NPCI Spawns In 👀</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MA7fcUgZ41zdb_FEIiDzSQ.png" /></figure><p>Now we can actually start decoding what NPCI and UPI changed.</p><p><strong>NPCI — National Payments Corporation of India</strong> — was created to build and operate shared payment infrastructure for India’s retail-payment ecosystem.</p><p>Then, in 2016, NPCI launched <strong>UPI — Unified Payments Interface</strong>.</p><p>And the idea was pretty simple:</p><blockquote><strong><em>Stop making the user think like a banker.</em></strong></blockquote><p>Before this, the user was dealing with:</p><p><strong>Account number + IFSC + bank + branch</strong></p><p>UPI introduced a much friendlier abstraction:</p><p><strong>VPA.</strong></p><h3>03 — What the hell is a VPA?</h3><p>A <strong>VPA — Virtual Payment Address</strong> — is basically your UPI address.</p><p>For example:</p><p>aryan@bank</p><p>The easiest way to think about it is like an email address, except you’re sending <strong>money</strong> instead of an email.</p><p>And the important distinction is:</p><p><strong>VPA = address</strong></p><p><strong>Bank account = where the money actually lives</strong></p><p>The VPA sits on top of the underlying bank account, so you don’t have to throw your account number and IFSC at someone every time they want to pay you.</p><p>That sounds like a small UX improvement.</p><p>It really wasn’t.</p><p>It changed the way people interacted with bank accounts.</p><h3>04 — Okay, But Who Are All These People?</h3><p>Let’s decode the second image properly.</p><h3>PSP</h3><p><strong>PSP = Payment Service Provider.</strong></p><p>A PSP bank provides the banking connectivity required for a UPI application to participate in the ecosystem.</p><h3>TPAP</h3><p><strong>TPAP = Third-Party Application Provider.</strong></p><p>This is the application layer you actually use — for example, apps such as <strong>Google Pay, PhonePe and other third-party UPI applications</strong>.</p><p>And this distinction matters:</p><blockquote><strong><em>The app isn’t the bank.</em></strong></blockquote><p>You can use Google Pay as the interface while your actual bank account is still maintained by a participating bank.</p><h3>Remitter Bank</h3><p>This is simply the <strong>sender’s bank</strong>.</p><p>If I’m sending ₹1,000 from ICICI:</p><p><strong>ICICI = my remitter bank.</strong></p><p>That’s the bank holding my account and processing the debit.</p><h3>Beneficiary Bank</h3><p>This is the <strong>receiver’s bank</strong>.</p><p>If Rahul is receiving ₹1,000 into SBI:</p><p><strong>SBI = Rahul’s beneficiary bank.</strong></p><p>So whenever you see those terms:</p><p><strong>Remitter = sender</strong></p><p><strong>Beneficiary = receiver</strong></p><p>It’s really just banking terminology for the two sides of the payment.</p><h3>05 — So What Did NPCI Actually Build?</h3><p>The easiest mistake to make is thinking:</p><blockquote><em>“Google Pay sends my ₹500 to NPCI and NPCI sends it to Rahul.”</em></blockquote><p>Nope.</p><p><strong>NPCI isn’t your bank.</strong></p><p>Your money is still held by your bank.</p><p>NPCI provides the <strong>infrastructure and network connecting the participants in the UPI ecosystem</strong>. Take NPCI is like a the Secret club only the Trusted Banking partners or the verified Banks of India can acess, for the same reason NPCI Apis and Low Level Design are out of reach of the public.</p><p>UPI uses standardised interfaces and APIs so different banks and payment participants can communicate through a common system rather than every app having to build a completely different integration for every bank.</p><p>And no, this isn’t an open internet API where literally anyone can send requests to NPCI.</p><p>Participation is controlled through the banking/payment ecosystem and approved participants.</p><p>Think of it less like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*12F8AIDwqYSFyydHkkM74A.png" /></figure><p>and more like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_6UzYTJYEg0dm5XRlxrykA.png" /></figure><h3>06 — One Thing I Couldn’t Find</h3><p>This was actually one of the more interesting parts of researching UPI.</p><p>We can find a lot of information about the <strong>high-level architecture</strong>:</p><ul><li>participants</li><li>APIs</li><li>PSPs</li><li>TPAPs</li><li>VPAs</li><li>authentication</li><li>transaction flows</li><li>settlement</li><li>reconciliation</li></ul><p>But I couldn’t find a public, authoritative document showing NPCI’s complete <strong>low-level production architecture</strong>.</p><p>For example, we don’t get a complete official blueprint of every internal database, queue, microservice, load balancer, replication mechanism, failover system or security boundary.</p><p>And honestly, that makes sense.</p><p>This is critical financial infrastructure.</p><p>So when you see an online diagram claiming:</p><blockquote><strong><em>“This is the exact internal UPI architecture.”</em></strong></blockquote><p>I’d be careful.</p><p>The public material gives us the <strong>high-level design and documented interfaces</strong>. The deeper implementation has to be inferred from technical research and architecture breakdowns.</p><h3>07 — Okay… Let’s Actually Send ₹1,000</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0aF1ouyqHylIxAddbbQ1w.png" /></figure><p>Now that we’ve decoded the components, let’s follow one actual payment.</p><p><strong>Sender:</strong> Aryan<br><strong>App:</strong> Google Pay<br><strong>Sender Bank:</strong> ICICI<br><strong>Receiver:</strong> Rahul<br><strong>Receiver Bank:</strong> SBI<br><strong>Amount:</strong> ₹1,000</p><p>I scan Rahul’s QR.</p><p>The app reads the payment information, including the destination information needed to create the payment.</p><p>Then I enter my <strong>UPI PIN</strong>.</p><p>That is the authorisation step.</p><p>Basically:</p><blockquote><strong><em>“Yep. I’m actually approving this ₹1,000 debit.”</em></strong></blockquote><p>The request then moves through the UPI ecosystem, reaches the relevant bank on the sender side, and the transaction is processed toward the beneficiary side.</p><h3>08 — Wait… What Is the QR Actually Doing?</h3><p>Here’s another thing that’s easy to misunderstand.</p><h3>The QR isn’t moving your money.</h3><p>It’s simply carrying payment information so the app doesn’t make you type everything manually.</p><p>The <strong>VPA is one of the key pieces of information encoded in a UPI QR</strong>, and depending on the QR, additional information such as the merchant name, amount or transaction reference may also be included.</p><p>So think of it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G7Clbe45xs8lB_CGcNC_8A.png" /></figure><p>The QR is basically the shortcut.</p><p><strong>QR ≠ payment rail.</strong></p><p>It’s just a convenient way of feeding payment information into the payment system.</p><h3>09 — And Where Does the ₹1,000 Actually Go?</h3><p>This is the distinction that makes the whole architecture click.</p><p><strong>NPCI doesn’t own my bank balance.</strong></p><p><strong>Google Pay doesn’t own my bank balance.</strong></p><p><strong>The QR doesn’t own my bank balance.</strong></p><p>My <strong>bank</strong> does.</p><p>The sender’s bank processes the debit, the receiver’s bank processes the credit, and NPCI provides the infrastructure connecting the participating institutions.</p><p>Then you get into the less visible stuff:</p><p><strong>clearing, settlement and reconciliation.</strong></p><p>So the ₹1,000 isn’t literally sitting inside NPCI waiting to be forwarded like a parcel.</p><p>The UPI infrastructure is coordinating the transaction between the banks.</p><h3>10 — Push vs Pull Mechanism</h3><p>UPI can start a payment in two basic ways.</p><h3>Push</h3><p>I decide to pay you.</p><p>I scan your QR, enter ₹500, authenticate and send it.</p><p><strong>Sender → Receiver</strong></p><h3>Pull / Collect</h3><p>You want ₹500 from me.</p><p>You create a payment request, I receive it, approve it and authenticate it.</p><p><strong>Receiver requests → Sender approves</strong></p><p>The important part is that a collect request doesn’t mean someone can simply take money from your account. <strong>The payer still has to approve and authenticate the transaction.</strong></p><p>This is another reason UPI is more than just:</p><blockquote><strong><em>“IMPS with a nicer UI.”</em></strong></blockquote><h3>11 — Then Comes the Nightmare: Fraud 💀</h3><p>And now for the ugly side.</p><p>The easier you make payments, the easier it becomes for someone to <strong>social-engineer the user</strong>.</p><p>Fake customer support.</p><p>Fake cashback.</p><p>Fake refunds.</p><p>Fake investment schemes.</p><p>Fake QR codes.</p><p>And the classic:</p><blockquote><strong><em>“Scan this QR and enter your PIN to receive money.”</em></strong></blockquote><p>No.</p><p>Your UPI PIN authorises a transaction. You’re not entering it to receive free money.</p><p>So a lot of UPI fraud isn’t necessarily someone “breaking NPCI”.</p><p>Sometimes the attacker just convinces <strong>you</strong> to approve the transaction yourself.</p><p>At the infrastructure level, the ecosystem also uses authentication, transaction limits and risk controls to reduce fraudulent activity.</p><p>And at UPI’s scale, fraud detection obviously can’t be someone manually checking transactions one by one.</p><h3>12 — Billions. Literally Billions.</h3><p>This is probably where UPI stops looking like a payment feature and starts looking like <strong>critical financial infrastructure</strong>.</p><p>In <strong>FY 2024–25</strong>, UPI processed:</p><h3>18,586.60 crore transactions</h3><p>That’s roughly:</p><h3>185.87 billion transactions</h3><p>with a total value of:</p><h3>₹260.56 lakh crore</h3><p>or about:</p><h3>₹260.56 trillion</h3><p>And the numbers have continued climbing.</p><p>At this scale, the hard question isn’t:</p><blockquote><strong><em>“Can we send ₹500?”</em></strong></blockquote><p>It’s:</p><blockquote><strong><em>“Can we make billions of payments work when banks fail, networks timeout, users retry, requests duplicate and systems disagree?”</em></strong></blockquote><p>That’s a completely different engineering problem.</p><p><strong>Done.</strong></p><p>And underneath that tiny green tick?</p><p>An enormous financial network is having a conversation.</p><p>That’s the revolution.</p><p><strong>UPI didn’t remove the complexity.</strong></p><h3>It hid it.</h3><p>And honestly, that’s probably the most impressive part.</p><h3><strong>~ By Aryan Gupta</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=091d4a076948" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Learning in Public: The Skill That Changed How My Work Gets Noticed]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/learning-in-public-the-skill-that-changed-how-my-work-gets-noticed-2923d308d831?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2923d308d831</guid>
            <category><![CDATA[opensource-ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[webdev]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 21:39:10 GMT</pubDate>
            <atom:updated>2026-01-31T21:39:10.574Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iQqCm1QQBe9kF7VI.jpg" /></figure><p>We’re living in a strange but exciting time.</p><p>AI agents 🤖 are evolving fast.<br> MLOps ⚙️ is becoming mainstream.<br> New frameworks and tools appear every few months ⚡</p><p>Everyone is learning. Everyone is building.</p><p>And yet — <strong>standing out has never been harder</strong>.</p><p>Most people believe the solution is simple: <em>learn more</em>.<br> More technologies. More frameworks. More projects.</p><p>But here’s something I learned the hard way 👇</p><p><strong>Knowing a lot doesn’t matter if no one knows about your work.</strong></p><p>You can build impressive projects.<br> You can understand complex systems.<br> You can grind quietly for months ⏳</p><p>And still remain invisible.</p><p>That’s where <strong>Learning in Public</strong> changed everything for me 💡</p><h3>🌱 What “Learning in Public” Actually Means</h3><p><em>(Pic 2 goes here)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/0*GfmVaX8-_IfAbHsB.PNG" /></figure><p>Learning in public does <strong>not</strong> mean pretending to be an expert.<br> It does <strong>not</strong> mean posting only wins.<br> And it definitely does <strong>not</strong> mean showing off.</p><p>Learning in public simply means <strong>sharing as you grow</strong> 🌱</p><p>It’s about documenting:</p><ul><li>what you learned today 📝</li><li>what confused you yesterday 🤔</li><li>what finally clicked after struggling for days 💥</li><li>what mistake taught you something valuable 🐞</li></ul><p>Sometimes it’s a big insight.<br> Most of the time, it’s something small.</p><p>And that’s perfectly okay.</p><h3>👻 Why Silent Learning Doesn’t Work Anymore</h3><p>Talent today is everywhere.<br> <strong>Visibility isn’t.</strong></p><p>Thousands of developers:</p><ul><li>know modern tech stacks</li><li>understand system design</li><li>build projects after long workdays</li></ul><p>The difference between those who get opportunities and those who don’t is rarely skill alone.</p><p>It’s <strong>signal</strong> 📡</p><p>When you learn in public:</p><ul><li>people see consistency</li><li>peers recognize curiosity</li><li>communities remember your name</li><li>opportunities find <em>you</em></li></ul><p>People can’t value work they’ve never seen.</p><h3>🧠 What Should You Share?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LgUFpzoMu3EYq6tU.jpg" /></figure><p>Almost anything that helped <em>you</em> learn.</p><p>Examples:</p><ul><li>a new Vim shortcut ⌨️</li><li>an AI/ML concept that finally made sense 🤖</li><li>a bug that took hours to fix 🐛</li><li>a GitHub issue you raised and learned from</li><li>your first pull request 🛠️</li></ul><p>You don’t need groundbreaking ideas.<br> You need <strong>honest learning</strong>.</p><p>Small posts compound 📈</p><h3>🌍 Platforms Matter Less Than Consistency</h3><p>Each platform plays a role:</p><ul><li><strong>Medium</strong> → deep thinking, clarity, long-form ideas ✍️</li><li><strong>LinkedIn</strong> → visibility and professional storytelling 💼</li><li><strong>X (Twitter)</strong> → quick learnings and conversations 🐦</li></ul><p>You don’t need all of them at once.<br> Pick one. Start small. Stay consistent 🔁</p><p>Even <strong>one post a week</strong> is powerful.</p><h3>🔓 Open Source = Learning in Public at Its Best</h3><p>Open source forces you to:</p><ul><li>read real production code</li><li>ask better questions</li><li>accept feedback</li><li>learn with people, not alone</li></ul><p>Your learning leaves <strong>public proof</strong> — something others can trust.</p><p>That’s incredibly powerful.</p><h3>🧭 The Real Mindset Shift</h3><p>Here’s the biggest realization:</p><blockquote><em>It’s not about building a personal brand.<br> It’s about leaving learning footprints.</em></blockquote><p>You don’t need to go viral.<br> You don’t need thousands of followers.</p><p>You just need to be <strong>visible enough</strong>.</p><p>Because in the end 🌙<br> <strong>it’s not just about what you know — it’s about what people know about you.</strong></p><h3>✨ Final Thought</h3><p>Learn deeply 📚<br> Build honestly 🏗️<br> Share consistently 🌍</p><p>You never know which post:</p><ul><li>starts a conversation</li><li>leads to a collaboration</li><li>opens a door you didn’t even know existed 🚪</li></ul><p>Learning in public doesn’t slow you down.</p><p><strong>It multiplies your growth.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2923d308d831" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resumind: Rethinking Resume Analysis with AI and Cloud-First Architecture ]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/resumind-rethinking-resume-analysis-with-ai-and-cloud-first-architecture-822a47da24c4?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/822a47da24c4</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[hiring]]></category>
            <category><![CDATA[jobs]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 12:26:34 GMT</pubDate>
            <atom:updated>2026-01-07T12:26:34.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dGeCjR57fKBnHlPNCX0Yg.png" /></figure><p>Resumes are often judged in silence — parsed by ATS systems, skimmed by recruiters, and filtered long before a human conversation ever begins. Yet most resume tools still give generic advice, disconnected from the actual job being applied for.</p><p>That gap is what led me to build <strong>Resumind</strong>.</p><p><strong>Resumind</strong> is an <strong>AI-powered resume analyzer</strong> that evaluates resumes <em>in the context of specific job listings</em>. Instead of broad feedback, it provides <strong>ATS-style scores</strong> and <strong>role-aware insights</strong>, helping candidates understand how well their resume aligns with a real opportunity — and what they can improve.</p><h3>🚀 What Resumind Does</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5DuEhSCytFVBUNG1qdEyMw.png" /></figure><p>At its core, Resumind focuses on relevance.</p><p>Users can securely log in, upload their resumes, and match them against selected job listings. The system then analyzes:</p><ul><li>Skill alignment with the role</li><li>Experience relevance</li><li>Resume structure and clarity</li><li>Keyword and ATS compatibility</li></ul><p>The output isn’t just a score — it’s <strong>actionable feedback</strong>. Candidates get clear suggestions tailored to the job they’re applying for, not a one-size-fits-all checklist.</p><h3>🧠 A Different Development Experience</h3><p>One of the most interesting aspects of building Resumind was <strong>intentionally moving away from traditional architectures</strong>.</p><p>No classical backend databases.<br> No heavy API key management.<br> No complex auth servers.</p><p>Instead, I leveraged <strong>Puter.js</strong>, a cloud-first platform that handles:</p><ul><li>🔐 Authentication</li><li>☁️ Storage</li><li>🤖 AI-powered tasks</li><li>⚙️ Cloud computing logic</li></ul><p>— all directly from the browser.</p><p>This approach was refreshing. It challenged the default “backend-first” mindset and showed how modern applications can be built using <strong>client-driven, cloud-native workflows</strong> without sacrificing capability or security.</p><h3>🛠️ Tech Stack</h3><ul><li><strong>React</strong> — Component-driven UI architecture</li><li><strong>React Router</strong> — Smooth navigation and page flows</li><li><strong>Puter.js</strong> — Auth, storage, and AI tasks without traditional APIs</li><li><strong>Vercel</strong> — Fast and reliable deployment</li></ul><p>The UI was designed to be clean, minimal, and reusable — making Resumind easy to extend into a full SaaS product in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kec0Z11r96CoqV4op91_eg.png" /></figure><h3>💡 Why This Project Matters</h3><p>Hiring today is increasingly automated, yet candidates rarely get transparency into how decisions are made. Resumind aims to:</p><ul><li>Reduce guesswork in job applications</li><li>Help candidates understand ATS systems</li><li>Encourage resume improvement through clarity, not fear</li></ul><p>It’s especially useful for students and early professionals who often apply blindly, unsure why they’re getting rejected.</p><h3>🌐 Try It Yourself</h3><p>🔗 <strong>Live App:</strong><br> <a href="https://resumind-rho.vercel.app/">https://resumind-rho.vercel.app/</a></p><p>💻 <strong>Source Code:</strong><br> <a href="https://github.com/Aryan27-max/Resumind">https://github.com/Aryan27-max/Resumind</a></p><h3>🔮 What’s Next</h3><p>Resumind is just the beginning. Future ideas include:</p><ul><li>Resume version comparison</li><li>Skill-gap visualization</li><li>Recruiter-facing insights</li><li>Multi-role and multi-language analysis</li></ul><p>Building Resumind helped me rethink how AI, cloud computing, and frontend architecture can come together to solve real problems. It’s a step toward making resumes more honest, hiring more transparent, and feedback more useful.</p><p>If you’re exploring <strong>AI-first products</strong>, <strong>cloud-native development</strong>, or just curious about how ATS systems think — this project is for you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=822a47da24c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic GitHub READMEs: Turning Your Profile into a Developer Portfolio]]></title>
            <link>https://medium.com/@gupta.raj.aryan.2005/dynamic-github-readmes-turning-your-profile-into-a-developer-portfolio-8a2b34b068a1?source=rss-7afa9305cca1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a2b34b068a1</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Aryan Gupta]]></dc:creator>
            <pubDate>Fri, 26 Dec 2025 09:21:17 GMT</pubDate>
            <atom:updated>2025-12-26T09:21:17.978Z</atom:updated>
            <content:encoded><![CDATA[<h3>techDynamic GitHub READMEs: Turning Your Profile into a Developer Portfolio</h3><p>A GitHub README is the <strong>front page of a developer’s profile</strong>.<br> It represents your skills, creativity, and personality — and in many cases, it becomes the <strong>first impression</strong> for recruiters, collaborators, and fellow developers.</p><p>As the saying goes, <em>“First impressions last.”</em><br> And on GitHub, that impression is made in seconds.</p><p>Most developers underestimate the power of a well-crafted README. But spending <strong>just an hour or two</strong> refining it can dramatically enhance how your profile is perceived. I personally spent <strong>10+ hours</strong> curating templates, experimenting with layouts, and collecting resources so you don’t have to start from scratch.</p><p>The goal?<br> To transform a static README into something <strong>dynamic, expressive, and memorable</strong>.</p><h3>🔍 Why Go Dynamic?</h3><p>A dynamic README:</p><ul><li>Reflects your <strong>personality and imagination</strong></li><li>Highlights your <strong>tech stack visually</strong></li><li>Shows real-time data instead of static text</li><li>Makes your profile <strong>feel alive</strong></li></ul><p>When done right, it leaves a <strong>magical impression</strong> — especially on employers who review hundreds of GitHub profiles.</p><h3>🧩 My Curated Template</h3><p>I’ve built and refined my own dynamic GitHub README template using carefully selected tools and integrations.</p><p>👉 <strong>Have a look and be the judge yourself:</strong><br> 🔗 <a href="https://github.com/Aryan27-max">https://github.com/Aryan27-max</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjw9FovQu0RJr-1oI9Gr0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLyEu0j-n-A-0_Yf6xbgvg.png" /></figure><h3>🛠️ Resources to Build Your Own Dynamic README</h3><p>Here are some of the best tools I used while building mine:</p><h4>🎨 Dynamic Icons &amp; GIFs</h4><p>Add motion and personality to your README:<br> 🔗 <a href="https://github.com/Anmol-Baranwal/Cool-GIFs-For-GitHub">https://github.com/Anmol-Baranwal/Cool-GIFs-For-GitHub</a></p><h4>🎧 Spotify — Recently Played Tracks</h4><p>Show what you’re listening to while coding:<br> 🔗 <a href="https://github.com/novatorem/novatorem">https://github.com/novatorem/novatorem</a></p><blockquote><em>Requires forking the repo and setting up personalized Spotify API credentials.</em></blockquote><h4>📊 Dynamic GitHub Stats</h4><p>Display live stats like commits, streaks, and top languages:<br> 🔗 <a href="https://github.com/anuraghazra/github-readme-stats">https://github.com/anuraghazra/github-readme-stats</a></p><blockquote><em>Requires deployment with personalized GitHub fine-grained tokens.</em></blockquote><h3>🎯 Final Thoughts</h3><p>Your GitHub README is more than a block of Markdown — <br> it’s a <strong>living portfolio</strong>, a <strong>branding tool</strong>, and a <strong>conversation starter</strong>.</p><p>With the right tools and a bit of creativity, you can turn it into something that truly reflects <strong>who you are as a developer</strong>.</p><p>So have fun experimenting, iterate on your design, and don’t be afraid to stand out.</p><p>✨ <strong>Good luck — and happy building!<br>~Aryan Gupta</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a2b34b068a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>