From c90b519e9415519041125fe0678a9aee477ca38f Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Wed, 27 Aug 2025 19:07:37 -0400 Subject: [PATCH 1/3] add missing stripe key guard --- src/lib/stripe.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/stripe.ts b/src/lib/stripe.ts index 8bff8212..db38607f 100644 --- a/src/lib/stripe.ts +++ b/src/lib/stripe.ts @@ -1,7 +1,13 @@ import { loadStripe } from '@stripe/stripe-js'; export async function redirectToCheckout(sessionId: string): Promise { - const stripe = await loadStripe(import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY); + const stripeKey = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY; + + if (!stripeKey) { + throw new Error('Stripe key not found'); + } + + const stripe = await loadStripe(stripeKey); if (!stripe) { throw new Error('Stripe not loaded'); From 09a5e5487c45edf620b1f14c68d172c9b6f472e3 Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Wed, 27 Aug 2025 19:08:18 -0400 Subject: [PATCH 2/3] Update src/lib/stripe.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/lib/stripe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/stripe.ts b/src/lib/stripe.ts index db38607f..86476e8c 100644 --- a/src/lib/stripe.ts +++ b/src/lib/stripe.ts @@ -4,7 +4,7 @@ export async function redirectToCheckout(sessionId: string): Promise { const stripeKey = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY; if (!stripeKey) { - throw new Error('Stripe key not found'); + throw new Error('VITE_STRIPE_PUBLISHABLE_KEY environment variable is not configured'); } const stripe = await loadStripe(stripeKey); From 92ceedf13fc74c5c1b1756f9b5a1d16a02000f17 Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Wed, 27 Aug 2025 19:09:18 -0400 Subject: [PATCH 3/3] formatting --- src/lib/stripe.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/stripe.ts b/src/lib/stripe.ts index 86476e8c..4aca7ae9 100644 --- a/src/lib/stripe.ts +++ b/src/lib/stripe.ts @@ -4,7 +4,9 @@ export async function redirectToCheckout(sessionId: string): Promise { const stripeKey = import.meta.env.VITE_STRIPE_PUBLISHABLE_KEY; if (!stripeKey) { - throw new Error('VITE_STRIPE_PUBLISHABLE_KEY environment variable is not configured'); + throw new Error( + 'VITE_STRIPE_PUBLISHABLE_KEY environment variable is not configured', + ); } const stripe = await loadStripe(stripeKey);