Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/pages/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,9 @@ export default function Checkout() {
navigate(data.checkout_url);
return;
}
// If backend returned a Stripe client secret, navigate to a route that can handle it
const clientSecret = data.clientSecret ?? data.client_secret;
if (clientSecret) {
// Navigate to the payment page which loads Stripe Elements and completes confirmation
navigate(`/payment?client_secret=${encodeURIComponent(clientSecret)}`);
navigate(`/payment`, { state: { clientSecret } });
return;
}
// Fallback: optionally navigate if order id provided
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ function PaymentForm() {
export default function PaymentPage() {
const loc = useLocation();
const q = useMemo(() => new URLSearchParams(loc.search), [loc.search]);
const clientSecret = q.get("client_secret");
// Prefer router state (in-memory) to avoid exposing secrets in the URL.
const state = (loc.state as { clientSecret?: string } | null) ?? null;
const clientSecret = state?.clientSecret ?? q.get("client_secret");

if (!publishableKey) {
return (
Expand Down