mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-21 13:39:22 +01:00
fix: delay the payment intent auth (#26252)
This commit is contained in:
parent
a58ee30f95
commit
ad1e69e18b
@ -71,18 +71,22 @@ export const PaymentEntryModal = ({
|
||||
const [stripePromise, setStripePromise] = useState<any>(null)
|
||||
|
||||
useEffect(() => {
|
||||
// Load Stripe.js asynchronously
|
||||
const loadStripeJs = async (): Promise<void> => {
|
||||
const { loadStripe } = await stripeJs()
|
||||
const publicKey = window.STRIPE_PUBLIC_KEY!
|
||||
setStripePromise(await loadStripe(publicKey))
|
||||
// Only load Stripe.js when the modal is opened
|
||||
if (paymentEntryModalOpen && !stripePromise) {
|
||||
const loadStripeJs = async (): Promise<void> => {
|
||||
const { loadStripe } = await stripeJs()
|
||||
const publicKey = window.STRIPE_PUBLIC_KEY!
|
||||
setStripePromise(await loadStripe(publicKey))
|
||||
}
|
||||
void loadStripeJs()
|
||||
}
|
||||
void loadStripeJs()
|
||||
}, [])
|
||||
}, [paymentEntryModalOpen, stripePromise])
|
||||
|
||||
useEffect(() => {
|
||||
initiateAuthorization(redirectPath)
|
||||
}, [initiateAuthorization, redirectPath])
|
||||
if (paymentEntryModalOpen) {
|
||||
initiateAuthorization(redirectPath)
|
||||
}
|
||||
}, [paymentEntryModalOpen, initiateAuthorization, redirectPath])
|
||||
|
||||
return (
|
||||
<LemonModal
|
||||
|
Loading…
Reference in New Issue
Block a user