#deputycheese
1 messages ยท Page 1 of 1 (latest)
Could you please share with me your latest follow up question/issue ?
My issue is that I want to differentiate if an invoice.payment_failed events comes from an on session or off session event.
I was told I can check "billing_reason" for this and differentiate between subscription_create and subscription_update
That worked on dev/staging so far, but now I tried the same thing on live and it gives me an "subscription_update" event although it is an on session
That worked on dev/staging so far, but now I tried the same thing on live and it gives me an "subscription_update" event although it is an on session
Could you share the EventId ?
On live the webhook is this one: we_1LTkbJClDK2O5WMjW17pW93t
To clarify: this happens during 3d secure, I get the invoice.payment_failed during the first (on session) checkout from the user
Because he has to confirm it via 3ds
I need the eventId you are referring to evt_124
evt_1NkPcpClDK2O5WMjkViyfkCO
Ah wait that's invoice.payment_failed not payment_intent.payment_failed
payment_intent.payment_failed is indeed correct
You don't have billing_reason in payment_intent.payment_failed event
Mmmh okay
I'm confused by these events
I want to cancel a subscription if an off session payment fails
Therefore I need invoice.payment_failed, correct?
Yes you can
But keep in mind that there isn't a direct way to detect if an invoice was paid on an off session or an on session way.
Thats confusing tbh
What I want is:
1.) User checks out (on session), has to confirm his payment via 3ds and completes his transaction. => Here I want to ignore the payment_intent.payment_failed event that is triggered before he confirms 3ds.
2.) After a month or a year his subscription gets renewed. If the payment cannot be made I want to listen to an event to cancel his subscription. => what event can I use for this?
How can I achieve this?
Right now the only way i see is to check if the description is "Subscription creation" but that seems rather unsafe
See pi_3NkPXdClDK2O5WMj0uWdEO1a
What you can do is to listen to the event invoice.payment_failed, check the number of invoices that customer has for that subscription. If it's the first one, then ignore the event, if it's not the first one, cancel the subscription
Is that ->data->lines->total_count ?
No.
You need to make a Search APi request:
https://stripe.com/docs/search#query-fields-for-invoices
and fetch invoices by customer and by subscription
But if the customer pauses/cancels his subscription and then later restart it, that will lead to the same error
I don't understand the link here.
Computing the number of previous invoice is just one option
But there is no direct way to acheive that and cover all use cases.
May I ask you why you want to cancel the subscription if there is a failure payment for an off session payment ?
Because the customer in that case hasnt paid yet and we dont know when or if he will pay at all, so we would like to cancel it. He then can book the subscription again on our site.
It's confusing that we get a invoice.payment_failed and payment_intent.payment_failed event in a 3dsecure case even if the invoice and payment_intent probably wont fail after 3ds confirmation
Yes that's how thinks work actually.
You can use Stripe Billing recovery, in order to send the customer email and update their payment method
Check the Manage failed payments section
But why is it working in the dev environment? There I am not getting the failed events during 3ds
only in live
We cant use stripe billing at all
We are doing all invoices and billing on our side because we have different sources for invoices and payment methods, stripe+this subscription model being only one of many
I see. Well I don't think there is a straightforward way to detect if an inoivce is on or off sesison AFAIK.
You can do only workarounds
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
It's totally confusing that dev behaves different than live
Here is what events I get when using 3ds in DEV:
Ah wait can I change the api version for a webhook?
Maybe that's the reason for the differently behaving events
you can't change the API version for an existing webhook endpoint but you can delete the existing one and create a new one
with a specified API version
for the same URL
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Got it
OMFG
It was the api version all the time ๐ฆ
The older api version gave me wrong event data
The newer api isnt firing payment_intent.payment_failed at all for 3d secure
That could have saved me a day ๐ญ
would you mind sharing the event ID?
For the 2020 api there is no event id because it is not firing the event AT ALL during 3d secure confirmation
For the older api (2016) the event was fired, but i deleted the endpoint completely in order to upgrade so i guess the event is gone
maybe your endpoint is not listening for payment_intent.payment_failed
what's the webhook endpoint ID? we_xxx
The old endpoint is gone, the new is we_1NkQTAClDK2O5WMjqTsTDlid
It is listening to payment_intent.payment_failed
Like the dev endpoint is too
But when I had the api version set to 2016, I received the payment_intent.payment_failed during 3d secure. After I have upgraded it now to 2020 that doesnt happen anymore.
you actually received the event
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I just retried it on live
Used my credit card that forces 3ds and waited a minute before I confirmed
Here are the full events:
I didnt get a payment_intent.payment_failed during 3ds
These events are all from my checkout right now
if the event wasn't triggered you'll not received it
but this is not related to the webhook endpoints you have
Yes but 3d secure was triggered
It must be though?
Before I changed from 2016 to 2020 I did in fact get it every time during 3d secure
After I switched I dont get it anymore
would you mind sharing the link to the page where you got the screenshot from?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
See all the events happening after 14:28
(before that there were still some errors on our side because I havent updated the endpoint secret so all requests failed)
Could you see it?
Hi there ๐ jumping in as my teammate needed to step away.
In the list of Events here, invoice.payment_action_required is the one that indicates 3DS must be completed for the Invoice's payment to progress.
Yes, just saying that since I upgraded the api version I am not getting the payment_intent.payment_failed event anymore during 3d secure. So for me everything works perfect now. Your colleague just said that I should get that event (but that event broke my subscription checkout basically and it must not occur)
Ah gotcha, glad to hear you're all set! Let us know if there is anything else we can help with.