Lesson 4 of 16
42. Design E-commerce Cart and Checkout (Amazon / Flipkart)

42.3 What are the doors?

3 min read+10 XP

Step 3: API and data model (10 minutes)

PUT /v1/cart/items/{sku} { "qty": 2 } → 200 cart POST /v1/cart/merge (at login: guest cart id) → 200 cart POST /v1/checkout/preview → { "items": [...], "price_changes": [...], "total": 1248, "offers": [...] } POST /v1/orders Idempotency-Key: cart-77-attempt-1 body: { "address_id": "a1", "payment_method": "upi", "expected_total": 1248 } returns: 201 { "order_id": "o42", "status": "payment_pending", "payment": { "redirect": "..." } } GET /v1/orders/{id} → { "status": "confirmed" | "payment_pending" | ... } POST /webhooks/payments (from the payment gateway, signed, Chapter 24)

expected_total lets the server refuse to charge a different amount than the shopper saw.