#Sébastien
1 messages · Page 1 of 1 (latest)
Hi there 👋 what type of Event are you listening to?
Gotcha, let me double check whether you can get the information you're after from that Event type specifically.
I have a invoice payement failed when I have a payement with 3D secure... (it's normal, yes).
Usually, I send an email to my customer when there is an Invoice Payement Failed...
In my case, I don't want to send an email to my custmer when there is the 3D secure... so I need to check the method payement... ?
Ok thanks 🙂
Hm, do you have a specific example that you're looking at?
Yes, for example, in this event : pi_3O5BXaIkuBTPnlgp2rGTTaqd
I have an invoice payement failed sent (du to the 3D Verification Secure)...
In this case, my webhook will send an email to my customer because i'm listening the "invoice.payment_failed" event and sending an email to my customer when I have this event...
So if I understand well... I need to check the method payement to know if I have to send the email or not (3D secure... or not)
I dont know if I'm clear ^
Sorry, I meant a specific Invoice (in_) or Event (evt_) ID from your testing that I could take a closer look at. If you don't have one that's fine.
I don't think you want to check the Payment Method though. I think you want to check the last payment error from the Payment Intent, to see if it is an authentication required issue which indicates that the payment would have been authorized if the customer completed an authentication challenge.
Just to make sure I'm understanding correctly, you don't want to send emails about other types of payment failures, you're okay with letting those fail?
That's almost it, I want to send emails for ALL failed payments except when there is a 3D secure verification.
Here an evt : evt_1O5BXcIkuBTPnlgpMQOtWXqM
Or the invoice : in_1O5BXaIkuBTPnlgpnZckuOHU
Thanks
Gotcha, thank you for the clarification.
In that case, I would recommend retrieving the Payment Intent associated with the Invoice, and then check the state of that.
The Invoice object has a payment_intent field which contains the ID of the related Payment Intent that can be used to retrieve it:
https://stripe.com/docs/api/invoices/object?lang=python#invoice_object-payment_intent
https://stripe.com/docs/api/payment_intents/retrieve?lang=python
Once you have the Payment Intent, you can check to make sure it isn't in a requires_action state (indicates customer authentication needs to be completed, which is 3DS for card payment methods).
https://stripe.com/docs/api/payment_intents/object?lang=python#payment_intent_object-status
and that the latest_payment_error hash does not indicate the payment was declined because it required authentication:
https://stripe.com/docs/api/payment_intents/object?lang=python#payment_intent_object-last_payment_error
Ok I think I understand... And in case where my Payment Intent is in state "requires_action", I don't send email that's right ?
Correct
Ok ! But (sorry)... One last question... In my webbook, how can I see if my payment intent is in "requires action" ?
I just need to check the payment intent id and after... what field should I check ?
Thanks
You should retrieve the Payment Intent, it won't be in the Event directly. Then you'll want to check the status field on the Payment Intent.