Read this story as text
Checkout, behind the Pay button: the story, written out
You tap Pay and a second later it says Order placed. Nami, a cloud architect, builds the serverless AWS setup behind that tap one piece at a time: API Gateway, Lambda, DynamoDB, Step Functions, EventBridge, SQS and SNS.
- You tap Pay. What if the card is charged, but the order is lost? Watch how that never happens.
- A lot can go wrong in one second. That is what makes it the best service to build.
- Three promises are made in there: You won't be charged twice. You won't pay for items that are out of stock. We won't lose your order.
- We go serverless, small microservices. Watch what happens when a step fails half way. Scroll.
- Someone taps Pay. One tap, four truths at once: right price, milk on the shelf, money on the card, reachable address. Any can change mid tap. Who checks?
- A name, an edge and a firewall. Same front door as search, plus AWS WAF first, because payments attract abuse. Then the real gate.
- One door, checked at the door. API Gateway checks your sign-in token before any code runs, and limits how fast you can call. No server behind it. Now, the order.
- A small service that owns one job. One Lambda, one DynamoDB table. An idle night costs almost nothing. It writes the order as pending, with a key, so a double tap is one order.
- Many steps, one workflow. An order is a chain: reserve, charge, confirm. One crash in one function leaves a mess. Step Functions remembers where each order is. Step one: the milk.
- Hold the milk. Inventory holds one packet with a single conditional write: two people never win the last one. Ten minutes, then it releases. Now, money.
- Charge the card. The payment function calls the gateway with a key on every charge, so a retry never charges twice. But banks are slow.
- The answer comes later. 'Paid' arrives seconds later by webhook. The workflow pauses for free, and wakes on a token. But what if the card is declined?
- When a step fails. Declined after we held the milk? Every step has an undo, and the workflow runs them backwards. No manual clean-up. The promise, kept.
- Say it once, tell everyone. Confirmed. Now warehouse, notifications and analytics all want to know. One event on EventBridge, and each listens on its own.
- Never make the warehouse wait. The warehouse is slow at nine pm, so a queue takes orders at its pace. Five failures move an order to a side queue so it never blocks others.
- Tell the customer. One event, and SNS sends push, SMS and email. SMS provider down? The push still lands. Orders never wait for messages.
- Watch every step. CloudWatch gathers logs, X-Ray follows one order across all functions, and an alarm fires if the dead-letter queue is not empty.
- The whole picture. That is one order, tap to push. Trace an order, or open the full diagram.
More stories on Real-world systems