2
0

fix(paymentInput): don't proceed when modal closed

This commit is contained in:
Baptiste Arnaud
2022-08-21 08:30:34 +02:00
parent 1318d27c74
commit bd41d7fc9b

View File

@@ -126,10 +126,10 @@ const CheckoutForm = ({
setIsLoading(true) setIsLoading(true)
const { error } = await stripe.confirmPayment({ const { error, paymentIntent } = await stripe.confirmPayment({
elements, elements,
confirmParams: { confirmParams: {
// Make sure to change this to your payment completion page // TO-DO: Handle redirection correctly.
return_url: viewerHost, return_url: viewerHost,
payment_method_data: { payment_method_data: {
billing_details: { billing_details: {
@@ -151,10 +151,9 @@ const CheckoutForm = ({
}) })
setIsLoading(false) setIsLoading(false)
if (!error) return onSuccess() if (error?.type === 'validation_error') return
if (error.type === 'validation_error') return
if (error?.type === 'card_error') return setMessage(error.message) if (error?.type === 'card_error') return setMessage(error.message)
setMessage('An unexpected error occured.') if (!error && paymentIntent.status === 'succeeded') return onSuccess()
} }
const showPayButton = () => { const showPayButton = () => {