mid-dev-44 wants to mergefix/double-charge-checkout→main
MI
mid-dev-44
1 file changed · 2 hours ago
YOUR MISSION
Users with slow internet connections occasionally report being charged twice for the same order. A mid-level dev added a `loading` state to disable the button while the API request is in flight, but duplicates are still happening.
Mid~12 min
HINTS (0/3 used)
REVIEWING AS
SR
Senior Engineer
@ Stripe · Backend Platform
src / components / Checkout.tsx+2−0
12
12
const [loading, setLoading] = useState(false);
13
13
14
14
async function handleCheckout() {
15
+
if (loading) return; // Prevent double clicks
+
16
+
setLoading(true);
+
15
17
try {
16
18
await api.chargeCard(cart);
17
19
} finally {
18
20
setLoading(false);
19
21
}
20
22
}
Click any changed line (+/−) to flag an issue · or Approve if everything looks safe