From 1388fcad46538d4619b70b5eea2751072f69f968 Mon Sep 17 00:00:00 2001 From: swetalin-10 Date: Mon, 22 Jun 2026 00:04:07 +0530 Subject: [PATCH] fix(checkout): redirect to Stripe instead of navigating to /success (closes #321) handleCheckout() was calling navigate('/success') immediately after the backend returned a session URL, bypassing Stripe entirely. No payment was taken, the webhook never fired, stock was never deducted, and no order record was created. Replace emptyCart() + navigate('/success') with window.location.href = data.url so the user is sent to the Stripe-hosted checkout page. Stripe then redirects to /success?session_id=... on completion, which triggers the webhook for fulfillment. SuccessPage already calls emptyCart() on mount via its own useEffect, so moving it there is correct. --- FRONTEND/src/components/ui/Navbar.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FRONTEND/src/components/ui/Navbar.jsx b/FRONTEND/src/components/ui/Navbar.jsx index a4b1692..fcfda03 100644 --- a/FRONTEND/src/components/ui/Navbar.jsx +++ b/FRONTEND/src/components/ui/Navbar.jsx @@ -88,9 +88,8 @@ const Navbar = () => { }); return; } - emptyCart(); onClose(); - navigate("/success"); + window.location.href = data.url; } catch (err) { console.error("Checkout failed:", err);