The design is close: the module boundaries, thin routes, and the choice to accept a 5-minute stock cache are all sound for 200 to 2,000 orders a day. The payment steps (3 to 6) can charge a customer twice or charge them and leave no order behind, so fix those on paper before you build.

## What must change

**1. Retrying the charge on a timeout can charge the customer twice.**
A timeout does not mean the charge failed, only that you did not hear back.
- **Case:** the charge call for a $50 order succeeds at the provider, but the response takes 6 seconds. The service times out at 5 seconds and retries.
- **Result:** the customer is charged $100.
- **Expected:** one $50 charge.
- **Fix:** send an idempotency key (the order id works) with every charge attempt, so the provider treats retries as the same charge. Most providers support this.

**2. Rolling back after a failure can erase an order the customer paid for.**
The order row exists only inside an open transaction while the payment call runs.
- **Case:** all attempts time out, but one actually went through at the provider. Or the charge succeeds and the service crashes before the commit.
- **Result:** the customer is charged, the `PENDING` row is rolled back, and the database has no record that the order existed. Nobody can find it to refund it.
- **Expected:** an order row that says payment is unresolved or failed.
- **Fix:** commit the `PENDING` order first, call the provider outside any transaction, then update the order to `PAID` or `FAILED` in a second short transaction. A small periodic job asks the provider about orders stuck in `PENDING` and resolves them.

This also stops a database transaction being held open for up to 20 seconds (four attempts at 5 seconds each) while waiting on the provider.

```mermaid
flowchart TD
    A[POST /orders] --> B[Check stock in cache]
    B --> C[Insert order as PENDING and commit]
    C --> D[Charge with order id as idempotency key, retry on timeout]
    D -->|success| E[Mark PAID, commit, send email]
    D -->|declined| F[Mark FAILED, commit, return error]
    D -->|still unknown| G[Leave PENDING, periodic job checks provider]
```

**3. The test plan covers only the happy path, and the risk is in the failures.**
Add integration tests against a fake payment provider for at least:
- a timeout followed by a successful retry, asserting one charge;
- a decline;
- timeouts on every attempt;
- a crash between charge and commit.

## Decisions to write down (one line each, not blockers)

- **Overselling:** with a 5-minute cache, two customers can buy the last unit. Accepting that is reasonable at this volume, but say what happens when it does: refund, backorder, or a direct warehouse check for low-stock items only.
- **Client retries:** if the client resends `POST /orders` after a network blip, you get two orders. Accepting a client-supplied idempotency key on the request covers this and can feed the same key to the provider.
- **Email failure:** state that a failed confirmation email does not fail the order, and whether it is retried.

The three required changes are about an hour of editing to the design.

VERDICT: READY WITH CHANGES
