architecture decision

ADR-004: Reserve inventory before capturing payment

Checkout reserves stock before payment capture so customers are not charged for items that cannot be fulfilled.

Decision RecordMay 2, 2024AcceptedCheckout

Context

The original checkout design authorized payment before inventory was reserved. During promotions this caused paid orders to be cancelled when stock could not be allocated.

Decision

The checkout flow reserves inventory first. Payment capture only starts after InventoryService confirms a reservation for every shippable line item.

Consequences

Payment failures no longer hold stock indefinitely because reservations expire. The checkout flow needs compensation logic to release reservations when payment cannot be completed.