AI Code Review

Checkout flow review

Decision-oriented report generated by an AI agent. Keep the first screen focused on outcome, risk and recommended next action.

Findings

High

Payment retry can double-submit the order

The retry button remains enabled while the payment request is in flight. Disable the action and make the server command idempotent.

POST /orders
Idempotency-Key: missing
Diff

Decision reports can show patch evidence

Use line classes when a report includes a diff so additions, removals and hunk headers remain scannable in long code blocks.

diff --git a/src/checkout.php b/src/checkout.php
@@ -12,7 +12,8 @@ final class Checkout
     public function submit(Order $order): Response
-        return $this->gateway->charge($order);
+        $this->guard->preventDuplicateSubmit($order);
+        return $this->gateway->charge($order);
     }
Code

Code blocks can be highlighted locally

Add a language class to plain code blocks. The report kit script applies syntax colors without loading third-party assets.

async function submitOrder(order) {
  if (!order.idempotencyKey) {
    throw new Error("Missing idempotency key");
  }

  return gateway.charge(order);
}
Medium

Error copy hides the recoverable action

The current message says only that payment failed. Add clear copy for retrying or switching payment method.

OK

Validation remains client and server side

Required fields are checked before submit and repeated in the command handler.