Files
supabase/apps/studio/components/interfaces/Billing/Payment/PaymentConfirmation.tsx
Kevin Grüneberg 680af04a06 fix: 3ds confirmation / downgrades (#36600)
- Remove captcha for downgrades to Free, it is not needed
- Properly handle 3DS if customer has multiple payment methods
- Move payment method invalidation to react-query
2025-06-23 19:03:27 +08:00

38 lines
981 B
TypeScript

import { useStripe } from '@stripe/react-stripe-js'
import { PaymentIntentResult } from '@stripe/stripe-js'
import { useEffect } from 'react'
import { LoadingLine } from 'ui'
export const PaymentConfirmation = ({
paymentIntentSecret,
onPaymentIntentConfirm,
onLoadingChange,
onError,
}: {
paymentIntentSecret: string
onPaymentIntentConfirm: (response: PaymentIntentResult) => void
onLoadingChange: (loading: boolean) => void
onError?: (error: Error) => void
}) => {
const stripe = useStripe()
useEffect(() => {
if (stripe && paymentIntentSecret) {
onLoadingChange(true)
stripe!
.confirmCardPayment(paymentIntentSecret)
.then((res) => {
onPaymentIntentConfirm(res)
onLoadingChange(false)
})
.catch((err) => {
console.error(err)
onError?.(err)
onLoadingChange(false)
})
}
}, [paymentIntentSecret, stripe])
return <LoadingLine loading={true} />
}