From 2b5c8369870658c069a55ff59611bf03c50d2843 Mon Sep 17 00:00:00 2001 From: ousszizou Date: Mon, 18 Mar 2024 18:10:39 +0100 Subject: [PATCH] fix(stripe): check stripe initialization before use in webhook handler --- packages/stripe/src/webhooks.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stripe/src/webhooks.ts b/packages/stripe/src/webhooks.ts index f8669852..96007340 100644 --- a/packages/stripe/src/webhooks.ts +++ b/packages/stripe/src/webhooks.ts @@ -7,6 +7,12 @@ import { stripe } from "."; import { stripePriceToSubscriptionPlan } from "./plans"; export async function handleEvent(event: Stripe.Event) { + + if (!stripe) { + console.error("Stripe is not initialized. Please check the USE_STRIPE environment variable."); + return; + } + switch (event.type) { case "checkout.session.completed": { const session = event.data.object;