**No, it isn't ready to build tomorrow.** The charge step can bill a customer twice or bill them with no order saved. Fixing that changes the flow, so it needs a design revision first. The rest of the design is sound, and the revision is probably an hour or two of work.

## Blockers

**1. Retrying the charge can double-charge (step 4).**
- Case: the payment provider charges the card, but its response takes longer than 5 s. We time out and retry. With no idempotency key, the provider treats the retry as a new charge. The customer is billed twice for one order.
- Expected: every retry carries the same idempotency key (for example, the order id), so the provider returns the original result.

**2. A timeout followed by a rollback can charge a customer for an order that doesn't exist (steps 4 and 6).**
- Case: all 3 attempts time out, so we roll back and return an error. But the provider actually completed one of the charges. The customer is charged and we have no record of the order.
- The cause is that `PENDING` only exists inside the open transaction, so a failure leaves nothing to reconcile against.
- Expected: commit `PENDING` before calling the provider. Treat a timeout as "unknown" rather than "failed", and have a job check the provider and resolve those orders to `PAID` or `FAILED`.

**3. The database transaction stays open during the network call.**
- It holds a connection for up to about 15 s plus backoff while waiting on the provider. This follows from the same flow as blocker 2. Committing `PENDING` first fixes both.

**4. There is no protection against client retries of `POST /orders`.**
- Case: the user double-clicks, or the client retries after a network drop. That creates two orders and two charges.
- Expected: the client sends an idempotency key, and the service has a unique constraint on it.

## Changes to make while building

- **Overselling:** the stock check reads a cache that is up to 5 minutes old, and nothing reserves or decrements stock. You've accepted the staleness, but the design doesn't say what happens when you oversell. Write down the policy (backorder, cancel and refund, or something else). Without one, you'll have to make it up when it first happens.
- **Confirmation email:** if sending fails after the commit, nothing happens. Either send it from a retried outbox or state that loss is acceptable.
- **Backups:** nightly backups on a single instance mean a crash can lose up to a day of orders while the provider still holds the charges. Turn on point-in-time recovery (WAL archiving). It's cheap, and you need it to reconcile payments.
- **Module boundaries:** the flow spans the orders and payments modules inside one transaction, but modules can't read each other's tables. Say which module owns the transaction. I'd have `OrderCheckout` own it and call each module's interface.
- **Tests:** only the happy path has an integration test. Your own standards require failure paths, and here they are the risky part. Add tests for:
  - a timeout followed by a successful retry, which must not double-charge
  - all retries timing out, which must leave the order in a reconcilable state
  - a duplicate client key
  - a commit failure after a successful charge

## Suggested flow

```mermaid
flowchart TD
  A[POST /orders with idempotency key] --> B{Key seen before?}
  B -- yes --> R[Return existing order]
  B -- no --> C[Check stock against cache]
  C --> D[Insert PENDING and commit]
  D --> E[Charge with order id as provider idempotency key]
  E -- success --> F[Mark PAID, queue email]
  E -- declined --> G[Mark FAILED, return error]
  E -- timeout after retries --> H[Leave PENDING, return 202]
  H --> I[Reconciliation job asks provider, resolves to PAID or FAILED]
```

VERDICT: NOT READY
