Rocky_Mountain_Vending/.pnpm-store/v10/files/15/6943a985bfa4069f153f3b81d0b4d45d93d7392817196860fb0b951d846165f7a1739198b14336a75b6acfa2e885082aee31cb94853a5a44cb1b31b8e352b2
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

38 lines
1,012 B
Text

import {StripeConstructor} from '../types';
import {loadScript, initStripe, LoadStripe} from './shared';
let stripePromise: Promise<StripeConstructor | null> | null;
let loadCalled = false;
const getStripePromise: () => Promise<StripeConstructor | null> = () => {
if (stripePromise) {
return stripePromise;
}
stripePromise = loadScript(null).catch((error) => {
// clear cache on error
stripePromise = null;
return Promise.reject(error);
});
return stripePromise;
};
// Execute our own script injection after a tick to give users time to do their
// own script injection.
Promise.resolve()
.then(() => getStripePromise())
.catch((error) => {
if (!loadCalled) {
console.warn(error);
}
});
export const loadStripe: LoadStripe = (...args) => {
loadCalled = true;
const startTime = Date.now();
// if previous attempts are unsuccessful, will re-load script
return getStripePromise().then((maybeStripe) =>
initStripe(maybeStripe, args, startTime)
);
};