**Not ready as written, but the fixes are small. Settle the payment-flow changes below before you write the checkout code.**

## Must fix (steps 4–6)

1. **Retrying the charge can double-charge customers.** A 5 s timeout doesn't mean the charge failed. The provider may have processed it and just been slow. Retrying up to 3 times without an idempotency key can charge the customer several times.
   - Generate one idempotency key per order, for example the order id, and send it on every charge attempt.
   - Before giving up, look up the charge status with the provider.

2. **A charge can succeed with no record of it.** Step 5 charges the card and then commits. If the commit fails, or the process crashes between the two, the customer is charged and the rollback leaves no order. Step 6 has the same problem when a timed-out charge actually went through.
   - Commit the `PENDING` order first, outside the payment call.
   - Then charge, and update the status to `PAID` or `FAILED` in a second step.
   - A small reconciliation job can resolve orders stuck in `PENDING` by asking the provider what happened.
   - This also keeps a record of failed attempts, which the rollback currently deletes.

3. **A transaction stays open during the external call.** Three retries at 5 s each hold a database connection and locks for 15 s or more. At 2,000 orders a day this isn't urgent, but it goes away once you commit `PENDING` first.

4. **The client can create duplicate orders.** `POST /orders` has no client-supplied idempotency key, so a double-click or a network retry creates two orders and two charges. Add an `Idempotency-Key` header with a unique constraint.

## Should fix

5. **Nightly backups on one Postgres instance lose up to 24 hours of orders and payment records.** That's too much for a system that moves money. Turn on WAL archiving or point-in-time recovery. Most managed Postgres services include it.

6. **The confirmation email is sent inline after the commit, and the doc doesn't say what happens if it fails.** Don't let an email failure fail the order. Either send it asynchronously or record "email pending" and retry.

7. **Overselling isn't handled.** Accepting a 5-minute stale cache is reasonable at this volume and the trade-off is documented. But nothing decrements stock or says what happens when you sell something that's out of stock. Define that path, for example a backorder or a refund, even if it's manual at first.

8. **The test plan is too thin for the risky parts.** One happy-path integration test won't catch the failures above. Add tests for payment timeout then success, payment decline, a duplicate request, and a crash between charge and commit.

## What's fine

- The scale assumptions and the single-instance Postgres are reasonable for 2,000 orders a day and a team of four.
- Module boundaries, thin routes, the `OrderCheckout` class and structured logging with the order id are all sensible.

VERDICT: READY WITH CHANGES
