0
0
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:
Zach Waterfield 2024-11-18 12:43:21 -05:00 committed by GitHub
parent a58ee30f95
commit ad1e69e18b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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