Build One-Call Checkout

Facade pattern

Challenge 2 of Wrap & ExtendBeginner~55 minFree

Checking out an order really means three separate jobs, reserving stock, charging a card, and booking a shipment, each with its own failure mode. The Facade pattern hides that messy orchestration behind one friendly call. Build a CheckoutFacade over in-memory Inventory, Payment, and Shipping subsystems, add rollback when a step fails, return a tracking id on success, keep an order log, and finish with a one-argument quick_buy convenience method.

5 steps

  1. 1Reserve Inventory Behind One Call
  2. 2Charge Payment and Roll Back on Failure
  3. 3Schedule Shipping and Return Tracking
  4. 4Keep an Order Log
  5. 5A quick_buy Convenience Method
Start step 1