Openstatus www.openstatus.dev
at 4c0f4c00a38753a5d0dfd7e7b7b7706dec6f1503 16 lines 463 B view raw
1import type { Stripe as StripeProps } from "@stripe/stripe-js"; 2import { loadStripe } from "@stripe/stripe-js"; 3 4let stripePromise: Promise<StripeProps | null>; 5 6export const getStripe = () => { 7 if (!process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY) { 8 throw new Error("NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY is not set"); 9 } 10 11 if (!stripePromise) { 12 stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY); 13 } 14 15 return stripePromise; 16};