Latest / The CTO Podcast with Fexingo: Technical Leadership, Architecture, and Engineering Org / How Stripe Built a Payment Infrastructure for 100 Countries
Transcript
- Lucas: If these conversations are useful for what you're building or running, you're in the right place. Today we're talking about Stripe — and not the obvious stuff. Not the story of two Irish brothers disrupting payments. I want to talk about the actual systems. How Stripe built a payment infrastructure that works in over a hundred countries, in a hundred and thirty-five currencies, with local payment methods. Luna: That's the part that doesn't get enough airtime. Everyone knows Stripe's API is clean, but the architecture under that — what did it actually take? Lucas: It's a story of incremental complexity. Early Stripe, 2011 or so, was a simple HTTP API that accepted a card number and returned a charge ID. But as they expanded globally, they had to solve for three things simultaneously: regulatory fragmentation, latency, and reliability. Luna: Regulatory fragmentation — that's the one that kills most fintechs. Every country has its own rules, its own data residency requirements. Lucas: Exactly. And Stripe's approach was to build a modular compliance layer. Instead of customizing the core payment flow per country, they created a set of pluggable modules — one for GDPR, one for PSD2 in Europe, one for pci dss everywhere. Each module runs as a sidecar process that validates transactions against local rules before they hit the core ledger. Luna: So the core payment engine stays agnostic, and the compliance modules enforce the boundaries. That's clever — but how do they handle data residency? If a payment happens in Brazil, does the data stay in Brazil? Lucas: Yes, and that's where their multi-region deployment comes in. Stripe runs clusters in multiple AWS regions — US East, Europe, Asia-Pacific, South America. When a transaction is initiated, the request is routed to the nearest region. But the tricky part is the ledger. Financial transactions require strong consistency, so they built a custom database layer — they call it the 'Stripe ledger' — that uses a distributed consensus protocol to maintain a globally consistent view of balances, even though writes happen locally. Luna: Distributed consensus for payments — that's a big bet. Most companies would use a centralized database and accept some latency. Lucas: Right, but Stripe couldn't afford that. If you're a merchant in Singapore and a customer pays with a local method like PayNow, the transaction needs to settle within seconds. You can't route that through a database in Virginia. So they had to have local writes but global consistency. Luna: And that's where idempotency becomes critical. How do they prevent double charges when a network timeout happens? Lucas: Idempotency keys are a core part of their API design. Every request includes a unique key that the server uses to deduplicate. But internally, they use an event-driven architecture. Each charge request is turned into an event — 'charge.created' — and that event goes through a series of processors: validation, fraud check, authorization, settlement. If a processor fails, the event is retried with backoff. The idempotency key ensures that even if the same event is processed twice, the state doesn't change. Luna: That sounds like a lot of infrastructure just to process a payment. At what point does the engineering investment become worth it? Lucas: Honestly, it's probably worth it from the first international transaction. Because if you don't have the architecture right, you end up with a patchwork of integrations — one for Visa, one for Mastercard, one for local methods — and that becomes unmaintainable. Stripe's bet was that a unified API backed by a flexible internal architecture would win in the long run, and it did. Luna: And yet, most companies don't build that way. They start with a simple monolith and add features as they go. Lucas: True, but Stripe had the advantage of starting from scratch. They didn't have legacy systems to carry. That said, they also made conscious trade-offs. For example, they chose to prioritize consistency over availability in the core ledger. If a payment can't be confirmed as settled, they'd rather reject it than risk a double charge. That's a design choice that not every payment processor makes. Luna: So they're more conservative than, say, PayPal or Square? Lucas: In some ways, yes. But it's also a function of their customer base. Stripe serves developers building online businesses, and those businesses have thin margins. A double charge could kill a small merchant's trust. So Stripe optimized for correctness. Luna: Let's talk about latency. If a payment takes two seconds, the user might abandon the checkout. How does Stripe keep it fast across continents? Lucas: They use a combination of edge caching and asynchronous processing. The payment form itself is served from a CDN. The actual authorization might go to a local data center, but the confirmation to the user is immediate — the merchant sees a 'pending' status while the backend processes the settlement. For most payment methods, the settlement happens within seconds, but for some like bank transfers, it could take days. Stripe uses event-driven state machines to track the lifecycle of each payment. Luna: So the user gets instant feedback, even if the money hasn't moved yet? Lucas: Exactly. And that's the magic. The user experience feels real-time, but the actual money movement is asynchronous. Stripe manages the risk by guaranteeing the merchant's funds once the authorization is confirmed. Luna: That brings us to fraud. How does Stripe handle fraud detection across different markets? A transaction that looks normal in the US might be suspicious in Japan. Lucas: They use machine learning models that are trained on global data, but they also allow local customization. Merchants can set their own risk thresholds. The fraud detection runs as a microservice that evaluates each transaction in real-time, and it's integrated with the payment flow — so if a transaction is flagged, it can be blocked before the authorization even goes through. Luna: And what about local payment methods? In some countries, credit cards are rare. How does Stripe integrate with bank transfers, e-wallets, or buy now pay later? Lucas: They built a plugin architecture. Each payment method is a separate module that implements a standard interface: authorize, capture, refund, void. The core system doesn't care if it's a Visa card or a Brazilian boleto. The module handles the specific protocol and translates it into Stripe's internal events. That's how they went from a few methods to over a hundred. Luna: That's a lot of engineering effort. But the payoff is that developers only need to integrate with one API. Lucas: Right. And that's the whole thesis. Stripe's value proposition is developer experience. They make it easy to accept payments globally, and in return, they capture a slice of every transaction. It's a classic platform play. Luna: Honestly, if today was worth a coffee to you, that's the link — buy me a coffee dot com slash fexingo. Lucas: Yeah, listener support is what keeps this show ad-free and focused on the engineering details. Appreciate it. Luna: So back to the architecture — one thing I've wondered: how does Stripe handle the complexity of tax compliance? Every country has different tax rules for digital goods. Lucas: That's a whole other layer. Stripe Tax is a separate product that uses the same modular compliance approach. They calculate tax based on the buyer's location, the product type, and local rules. But it's built on the same infrastructure — event-driven, with idempotency and multi-region support. Luna: So the same principles applied to a different domain. That's a sign of a well-designed platform. Lucas: It is. And it's why Stripe has become the default for internet businesses. Not because they were first, but because they built the right abstractions. Luna: I think that's the key takeaway for any CTO building a platform for global scale: invest in the abstractions early. The regulatory and payment complexity will come, and if your architecture can handle it, you win. Lucas: Exactly. And that's the conversation for today. Thanks for listening.