Story #20 Distributed Transactions · Saga Compensation

The Order That Was Paid For but Never Shipped

"The payment captured. The fulfillment failed. Neither the customer nor the system knew what to do next"

Harbor & Pine's checkout orchestrated payment and fulfillment through separate services. When fulfillment failed with a timeout, the orchestrator marked the checkout as failed—but didn't reverse the payment. Customers were charged for orders that were never created.

What happened

Harbor & Pine’s checkout flow coordinated four independent services: order creation, inventory reservation, payment capture, and fulfillment. Each service owned its own database. The design intentionally avoided distributed transactions.

During a seasonal promotion, payment captured successfully for many orders. The next step—creating a fulfillment request—hit a regional database outage in the fulfillment service. Calls timed out. The checkout orchestrator retried several times, then marked the checkout as failed and returned an error to the customer.

The error was correct: the checkout had failed. What was incorrect was what happened to the payment. It had been captured successfully. The orchestrator never initiated a compensation step to reverse it.

Customers received error messages saying their order had failed, then saw charges on their credit cards. Some reordered, creating duplicate charges. Customer service was overwhelmed.

Root cause

The API contract for the checkout workflow didn’t define what should happen when only some steps succeed. The orchestrator had no compensation logic for partial success. The payment service was called without an idempotent order ID that would have made reversal safe. Tests covered success paths and total failures—not partial completion.

The fix

The team redesigned the checkout as a saga with explicit compensation steps. Payment capture became a two-phase operation: authorization first, capture only after fulfillment confirmation. Each step was associated with a stable order ID, making compensation idempotent. The orchestrator was updated to track workflow state durably and execute compensation on any downstream failure.

Lesson learned

Distributed workflows need explicit failure handling at the business level. An API contract for a multi-step operation must define what happens when only some steps succeed—and the implementation must be tested for every partial-failure combination.

The Order That Was Paid For but Never Shipped