The design is sound at its core and you can start tomorrow, but five gaps need a decision written into the doc first. One of them corrupts stock as written.

What is already right: charging outside the database transaction, the guarded stock decrement, the order id as the provider idempotency key, and the `202` plus reconciliation path for unknown results.

## Fix before building

1. **Two reconcilers can restore stock twice.** The job runs every 5 minutes, and nothing says it runs on only one of the two instances or that status changes are guarded.
   - **Failing case:** an order for 1 unit of SKU A is stuck `PENDING` with `available = 0`. Both instances pick it up, both learn it was declined, both run step 5. `available` ends at 2 instead of 1, and you oversell a unit.
   - **Fix:** make every status change conditional (`UPDATE orders SET status = 'FAILED' WHERE id = :id AND status = 'PENDING'`) and restore stock only if that changed a row. Apply the same guard to steps 4 and 5.

2. **Reconciliation has no answer for "provider has never heard of this order".** Step 6 only allows `PAID` or `FAILED`.
   - **Failing case:** the service crashes after the commit in step 2 and before the charge call in step 3. The order is `PENDING`, stock is held, and the provider returns not-found.
   - **Fix:** I recommend treating not-found as `FAILED` with stock restored. Also cancel or void the charge at the provider, so a timed-out attempt that lands late cannot charge a customer for a `FAILED` order.

3. **Orders settled by reconciliation never get a confirmation email.** Only step 4 queues the email. A customer whose charge timed out and was later settled `PAID` by the job gets nothing. Put the "mark `PAID`, then queue email" step in one function that both paths call.

4. **The doc does not say where `unit_price` and `total` come from.** There is no price table, and the cart comes from the client. If the client sends the prices, anyone can post a cart with `unit_price: 0.01`. State that the server looks prices up, and from where.

5. **Reconciliation assumes the provider can look up a charge by order id.** When a charge times out you never receive the provider's charge id, and there is no column to store one anyway. Some providers cannot look up by idempotency key, only by their own id or by metadata. Confirm this for your provider today, send the order id as a reference or metadata field, and add a `payment_reference` column to `orders`.

## Smaller changes you can make as you build

- **Deadlocks:** two carts holding the same two SKUs in opposite order can deadlock in step 2. Update stock in sorted SKU order.
- **Idempotency key scope:** make the unique constraint `(customer_id, idempotency_key)`, so one customer's key cannot return another customer's order. Decide what a repeated key with a different cart returns; I suggest `422`.
- **Retry after decline:** a declined order is terminal, so a retry with the same key returns the `FAILED` order. The client must generate a new key for a second card, which belongs in the API contract.
- **Lost email:** a crash between the `PAID` commit and the enqueue loses the email. The doc also never says what the queue is. An outbox row written in the `PAID` transaction solves both.
- **Request duration:** four attempts at 5 s plus backoff is roughly 30 s. Check that the load balancer timeout is longer, or cut the retries and let reconciliation handle it.
- **Module boundaries:** steps 2 and 5 change `orders` and `stock` in one transaction, while the doc says no module touches another's tables. Say that `OrderCheckout` owns the transaction and passes it to the inventory and orders modules.
- **Constraints:** add a primary key on `order_items`, a `CHECK (available >= 0)` on `stock`, and a `CHECK` on `status`.

## Test plan gaps

The listed tests cover single-request paths only. Add these:

- Two simultaneous buyers for the last unit.
- Two simultaneous `POST /orders` with the same key.
- Decline restores stock exactly once.
- The reconciliation job for each outcome: paid, declined, not-found, provider down.
- Two reconcilers on the same order.
- A crash between steps 2 and 3.

VERDICT: READY WITH CHANGES
