⚡ (engine) Improve engine overall robustness
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { GoogleAnalyticsOptions } from 'models'
|
||||
import type { GoogleAnalyticsOptions } from 'models'
|
||||
|
||||
declare const gtag: (
|
||||
type: string,
|
||||
|
13
packages/js/src/lib/stripe.ts
Normal file
13
packages/js/src/lib/stripe.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Stripe } from '@stripe/stripe-js'
|
||||
|
||||
export const loadStripe = (publishableKey: string): Promise<Stripe> =>
|
||||
new Promise<Stripe>((resolve) => {
|
||||
if (window.Stripe) return resolve(window.Stripe(publishableKey))
|
||||
const script = document.createElement('script')
|
||||
script.src = 'https://js.stripe.com/v3'
|
||||
document.body.appendChild(script)
|
||||
script.onload = () => {
|
||||
if (!window.Stripe) throw new Error('Stripe.js failed to load.')
|
||||
resolve(window.Stripe(publishableKey))
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user