#cheqo.
1 messages · Page 1 of 1 (latest)
Hi there, just to clarify, so you question is how to handle a PaymentIntent when its status is requires_action ?
When a PaymentIntent is in requires_action, you need to take your customer back to your frontend, where you can call stripe.confirmCardPayment with the client_secret (https://stripe.com/docs/js/payment_intents/confirm_card_payment) to start the 3DS authentication.
I think so, all payment failure errors will have requires_action right?
requires_action doesn't mean a payment failure, it simply indicates that the payment requires action from the customer (i.e., 3DS autuentication).
https://stripe.com/docs/payments/paymentintents/lifecycle you can visit this page to know more about PaymentIntent lifecycle.
Does the <PaymentElement/> component handle custom 3ds rendering itself, such as "confirm 6 digit code sent to your number or something like that?
<form className="p-4" onSubmit={handleSubmit}>
<PaymentElement />
<button
className="btn btn-primary w-full rounded-full mt-4"
disabled={!stripe}
>
Submit
</button>
{/* Show error message to your customers */}
{errorMessage && <div>{errorMessage}</div>}
</form>
and then onSubmit i call this strip method:
const { error } = await stripe.confirmPayment({
clientSecret: "client_secret",
confirmParams: {
return_url: "http://localhost:3000/settings",
},
elements,
});
or should I call, stripe.confirmCardPayment as you mentioned?
stripe.confirmPayment() will also start the 3DS authentication if needed.
On this page - https://stripe.com/docs/js/payment_intents/payment_method
stripe.confirmPayment is mentioned and also there are many methods that are made for specific payment methods such as stripe.confirmAfterpayClearpayPayment
So what is the difference? Can I use stripe.confirmPayment universally?
You can also use stripe.confirmPayment() with client_secret to start the 3DS authenticaiton.
The difference is the params that you passed to stripe.confirmPayment().
if you confirm the PaymentIntent from frontend, you pass in an elements to stripe.confirmPayment(), Stripe will create a payment method from the element and use it to confirm the PaymentIntent, it will also start 3DS when necessary.
If you confirm the PaymentIntent from backend and the PaymentIntent's status is requires_action, you can pass a client_secret to stripe.confirmPayment() to start the 3DS flow.
Understood, so I don't have to call stripe.confirmCardPayment I can simply call stripe.confirmPayment?
Yes, you can do that as well.
Thats great. And one more thing, if the error is due insufficient funds would <PaymentElement/> handle custom error message or is it a separate flow that I have to handle in my ui myself?
No, PaymentElement won't display an error message in this case and your application needs to handle it