**design.md is in good shape and nearly ready to build from. Fix the three gaps below first, and you can start tomorrow.**

**What's strong**
- Taking the payment call out of the database transaction is the right call.
- Sending the order id as the provider's idempotency key on every retry is the right call.
- The conditional stock `UPDATE` makes the last-unit case safe without explicit locks.
- The reconciliation job and the 30-minute alert show you've planned for the "unknown result" case.
- The scale (200 to 2,000 orders a day) fits this simple design well.

**Fix these before coding (about an hour of design work)**
1. **Reconciliation can leak stock.** Step 5 restores stock on a decline, but step 6 only says the job "settles" orders as `FAILED`.
   - Example: a charge times out and the order stays `PENDING`. The job later learns it was declined. If the job only flips the status, those units stay reserved forever.
   - Fix: say the job runs the same "mark `FAILED` and restore stock" path as step 5. Use one shared method for both.
2. **Status changes need a guard.** The request handler and the job can both touch the same order, and you run two instances, so the job also runs twice every 5 minutes.
   - Fix: make every transition `UPDATE ... WHERE id = :id AND status = 'PENDING'` and act only if one row changed.
   - Without that guard, stock could be restored twice.
   - Also say how you keep a single job running, for example a Postgres advisory lock.
3. **A crash between step 2 and step 3 isn't covered.** The order is committed as `PENDING` and the process dies before any charge is made.
   - The job will ask the provider about a charge that doesn't exist.
   - Fix: decide that "provider has no record of this order id" means `FAILED` plus a stock restore once the order is older than some threshold. Check how long the provider keeps idempotency keys.

**Smaller items**
- **Confirmation email:** in step 4, a crash after the `PAID` commit but before the email is queued loses the email silently. Write the email job as a row in the same transaction that marks the order `PAID`. That is the standard outbox pattern, and it's cheap here.
- **Duplicate `POST /orders`:** two concurrent requests with the same key will hit the unique constraint inside step 2. State that you catch that error, roll back, and return the existing order.
- **Deadlocks:** update the stock rows in sorted `sku` order so two carts with overlapping items can't deadlock.
- **Price source:** the doc doesn't say where `unit_price` and `total` come from. They should come from the server's catalog, not the client's cart.
- **Schema:** add primary keys and an index on `order_items.order_id`. Consider making the idempotency key unique per customer.
- **Tests:** add cases for the reconciliation job (settles as paid, settles as declined, restores stock once, no charge found), concurrent duplicate requests, and a crash after reserve.

None of this changes your architecture. They're gaps in the existing design, and the most likely failure is the first one (stock quietly lost).

VERDICT: READY WITH CHANGES
