Skip to content

fix(checkout): redirect to Stripe instead of skipping to /success#397

Merged
Aamod-Dev merged 1 commit into
niharika-mente:mainfrom
swetalin-10:fix/checkout-stripe-redirect
Jun 21, 2026
Merged

fix(checkout): redirect to Stripe instead of skipping to /success#397
Aamod-Dev merged 1 commit into
niharika-mente:mainfrom
swetalin-10:fix/checkout-stripe-redirect

Conversation

@swetalin-10

Copy link
Copy Markdown
Contributor

Fixes #321

Root cause

handleCheckout() in Navbar.jsx received data.url (the Stripe-hosted checkout URL) from the backend but never used it. Instead it called navigate('/success') directly, so:

  • No Stripe payment page was shown
  • The user's card was never charged
  • checkout.session.completed webhook never fired → no stock deduction, no order record

Fix

FRONTEND/src/components/ui/Navbar.jsx — 2-line change:

- emptyCart();
  onClose();
- navigate("/success");
+ window.location.href = data.url;

window.location.href performs a full navigation to the Stripe-hosted checkout page. After the customer pays, Stripe redirects them to /success?session_id=..., which fires the webhook for fulfillment.

emptyCart() is removed from the checkout handler because SuccessPage already calls it on mount via its own useEffect — clearing the cart before payment was confirmed was also incorrect behaviour.

Flow after this fix

User clicks "Proceed to Checkout"
  → POST /api/checkout  →  Stripe session created, URL returned
  → window.location.href = data.url
  → User completes payment on Stripe
  → Stripe redirects to /success?session_id=...
  → Stripe webhook fires → stock deducted, Order document created
  → SuccessPage mounts → emptyCart()

…loses niharika-mente#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.
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

@swetalin-10 is attempting to deploy a commit to the niharika-mente's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approved!

@Aamod-Dev Aamod-Dev merged commit fb567c9 into niharika-mente:main Jun 21, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Checkout skips Stripe redirect — users reach /success without paying

2 participants