@codesled/stripe-payments
Version:
Simple Stripe checkout integration module from CodeSled
20 lines (15 loc) • 451 B
JavaScript
// stripeInstance.js
const Stripe = require("stripe");
let stripe = null;
function initStripe(secretKey) {
stripe = new Stripe(secretKey || process.env.STRIPE_SECRET_KEY);
}
function getStripeInstance() {
if (!stripe) {
throw new Error(
"Stripe not initialized. Call initStripe(stripeSecretKey) before using createCheckoutSession."
);
}
return stripe;
}
module.exports = { initStripe, getStripeInstance };