From bd41d7fc9be01fb307cf42fcdf6e0835a03729e1 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Sun, 21 Aug 2022 08:30:34 +0200 Subject: [PATCH] fix(paymentInput): don't proceed when modal closed --- .../ChatBlock/inputs/PaymentForm/StripePaymentForm.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/PaymentForm/StripePaymentForm.tsx b/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/PaymentForm/StripePaymentForm.tsx index c3de227a0..22d31151c 100644 --- a/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/PaymentForm/StripePaymentForm.tsx +++ b/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/PaymentForm/StripePaymentForm.tsx @@ -126,10 +126,10 @@ const CheckoutForm = ({ setIsLoading(true) - const { error } = await stripe.confirmPayment({ + const { error, paymentIntent } = await stripe.confirmPayment({ elements, confirmParams: { - // Make sure to change this to your payment completion page + // TO-DO: Handle redirection correctly. return_url: viewerHost, payment_method_data: { billing_details: { @@ -151,10 +151,9 @@ const CheckoutForm = ({ }) 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) - setMessage('An unexpected error occured.') + if (!error && paymentIntent.status === 'succeeded') return onSuccess() } const showPayButton = () => {