Files
dbg-otherway/utils/stripe.tsx
Fergal Moran e6ccc6b8f0 Initial commit
2023-02-23 11:35:19 +00:00

17 lines
457 B
TypeScript

/**
* This is a singleton to ensure we only instantiate Stripe once.
*/
import { Stripe, loadStripe } from '@stripe/stripe-js';
let stripePromise: Promise<Stripe | null>;
const getStripe = (): Promise<Stripe | null> => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
if (!stripePromise) {
stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY || '');
}
return stripePromise;
};
export default getStripe;