**The design is sound and you can start building tomorrow, provided you settle the first three items below before you write the code they touch.** The core decisions are right: the conditional stock update, charging outside the transaction, the order id as the provider's idempotency key, and reconciliation for unknown results. What I found are unspecified cases, not structural flaws.

## Fix before building the affected part

1. **An order can be settled twice, restoring its stock twice.** Nothing says a status change only applies if the order is still `PENDING`.
   - Case: both instances run the reconciliation job at the same minute, both see order A as `PENDING`, and both get "declined" from the provider. Both mark it `FAILED` and both add the stock back, so `available` is 1 too high and you can oversell.
   - The same happens if a slow request and the job settle the same order.
   - Fix: every settle is `UPDATE orders SET status = … WHERE id = … AND status = 'PENDING'`, and stock is restored only if that changed a row.

2. **Reconciliation has no rule for "the provider has never heard of this order".** Step 6 only covers `PAID` or `FAILED`.
   - Case: the instance crashes after the step 2 commit and before the step 3 charge call. The order is `PENDING`, stock is reserved, and the provider returns "not found". As written, the order sits until the 30-minute alert and someone fixes it by hand.
   - Fix: treat "not found" on an order older than 2 minutes as `FAILED` and restore stock; leave it `PENDING` if the provider says the charge is still processing.
   - Also state that a reconciled `FAILED` restores stock, as step 5 does.

3. **The idempotency key is unique globally, not per customer.**
   - Case: customer B sends a key that customer A already used. B gets A's order back, where B should get a new order of their own.
   - Fix: make the unique constraint `(customer_id, idempotency_key)`.

## Should specify, low effort

4. **The source of `unit_price` and `total` is not stated.** If they come from the client's cart, a customer can set their own price. Say that the server looks prices up and computes the total.
5. **There is no cart validation.** A quantity of -5 passes the stock update, raises `available` by 5 and lowers the total. Require quantity > 0 and merge duplicate SKUs.
6. **Multi-item orders can deadlock.** One order reserves SKU X then Y while another reserves Y then X; Postgres kills one and the client gets a 500. Reserve in sorted SKU order.
7. **Two simultaneous requests with the same key are not covered.** The second fails on the unique constraint rather than finding the existing order. Catch that violation, roll back and return the existing order.
8. **The test list misses the riskiest paths.** Add the reconciliation job (paid, declined, not found), two buyers racing for the last unit, simultaneous duplicate `POST /orders`, and settling an already-settled order.

## Minor

9. **A confirmation email can be lost.** A crash between the `PAID` commit and queuing the email in step 4 means it is never sent. Write an outbox row in the same transaction, or accept the loss and say so.
10. **The worst-case request time is over 20 seconds.** That is four attempts at 5 s plus backoff, which may exceed the load balancer or client timeout. Set a total budget and return `202` sooner.
11. **The data model omits keys and constraints.** Add a primary key on `stock.sku` and on `order_items (order_id, sku)`, plus checks for `available >= 0` and the allowed `status` values.
12. **No provider charge reference or failure reason is stored on the order.** Support and refunds will need both.
13. **Same key with a different cart is undefined.** Either return the original order or reject with `422`.
14. **Non-retryable provider errors other than "declined" are not mapped.** An invalid request, for example, should go to `FAILED` like a decline.
15. **A `FAILED` order keeps its key.** A client retrying after a decline must send a new one; put that in the API contract.

VERDICT: READY WITH CHANGES
