**design.md is close, but the payment step (steps 3–6) has bugs you should fix in the doc before you start building.**

## Must fix before building

1. **Retrying the charge can double-charge customers (step 4).**
   - A timeout doesn't mean the charge failed. The provider may have processed it, and a retry would charge again.
   - Send an idempotency key with every charge call. Derive it from the order id so all retries share it. Most providers support this.
   - After the final timeout, look up the charge status before you fail the order.

2. **The failure path can charge a customer and lose the order (steps 4–6).**
   - If the charge succeeds but the later `PAID` update or commit fails, you roll back. The order disappears and the money is gone.
   - If the charge times out three times but actually went through, you also roll back.
   - Use explicit order states, such as `PENDING`, `PAID`, `FAILED` and `PAYMENT_UNKNOWN`. Commit `PENDING` first, and update the state after the charge, each in its own short transaction.
   - Add a small reconciliation job that checks stuck `PENDING` and `PAYMENT_UNKNOWN` orders against the provider. Define a refund path for the case where you charged but can't fulfil the order.

3. **The database transaction stays open during the payment call (steps 3–5).**
   - With 5 s timeouts and 3 retries, a transaction can stay open for more than 15 s. That holds a connection and any locks the whole time.
   - Do not hold a transaction across the external call. This follows from the state-based approach in item 2.

4. **There is no idempotency on `POST /orders` itself.**
   - If a client retries after a network drop, it creates a second order and a second charge.
   - Require a client-supplied idempotency key, and enforce it with a unique constraint.

## Should decide now (small, but costly to retrofit)

- **Oversell policy:**
  - A 5-minute stale cache is fine at 200 orders a day, but it has no reservation or decrement.
  - Say what happens when you oversell: backorder, cancel and refund, or something else.
  - Without that, the cache decision is incomplete.
- **Pricing:** state that the server recomputes totals from its own catalog and never trusts prices in the client's cart.
- **Email:** it is sent inline after commit. If it fails, the request shouldn't fail. Send it asynchronously or from an outbox, and make it retryable.
- **Backups:**
  - Nightly backups on a single instance mean you could lose up to 24 hours of orders after a failure.
  - Those orders may already be charged at the provider.
  - At minimum, enable WAL archiving or point-in-time recovery, and rely on the reconciliation job from item 2.
- **Error contract:** the doc says "returns an error", but a client needs to tell "failed" apart from "unknown, don't retry blindly". Define distinct responses.

## Tests

The plan covers only the happy path, but the risky behaviour is in the failure paths. Add integration tests for:
- Charge timeout followed by a successful retry.
- Charge succeeded but the database write failed.
- Duplicate client requests.

The code structure section is fine as written.

VERDICT: READY WITH CHANGES
