#deputycheese
1 messages · Page 1 of 1 (latest)
Yep, this is expected. An initial payment attempt is made once the invoice is finalised. If the bank requests auth/3DS for that payment, an invoice.payment_failed event will fire
Okay I see. Right now we are using the payment.failed event when the subscription has ended and should be renewed but the payment fails (for example if the customer cc was stolen etc).
Is there a way to differentiate between those 2 use cases?
Because if it happens during his session on our website we dont want to cancel his subscription (this breaks our checkout atm)
But if his subscription has ended and the renewal fails, then we want to cancel his subscription
(so he can just go back to our website to renew/create a new subscription)
Should we therefore ignore invoice.payment_failed but use invoice.finalization_failed ?
You'd check the last_payment_error field on the associated PI: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-last_payment_error
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Would be autentication_required: https://stripe.com/docs/error-codes#authentication-required
Is there a way we can tell if the user is off session?
If off session -> cancel
If on session -> do nothing and wait for the finalization event
I cant find any of those properties in the logs of the event
That's the json I am getting during the payment failed event
Yeah you'll need to make an API request to expand the payment_intent field on the Invoice
Okay got it, I'll try that out
If I'm getting the payment intent, I cant find the off session / on session marker though: https://stripe.com/docs/api/payment_intents/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
there is no marker
Okay. So how can I differentiate between those 2 requests?
I want to do this:
If off session -> cancel
If on session -> do nothing and wait for the finalization event
maybe check the billing_reason on the Invoice
"billing_reason":"subscription_update"
not really the same thing but I usually see this question from the context of treating the first Invoice payment (which happens on session) differently from recurring(which happens off-session)
That's exactly what I'm trying to do
cool, then that can help
billing_reason is subscription_create on the first Invoice of a Subscription
(assuming you're not using a really old API version(https://stripe.com/docs/upgrades#2018-10-31))
That's strange because for me it's subscription_update on the first one
are you using an really old API version?
invoice ID in_xxxx?
in_1NkOD1ClDK2O5WMjxSJAhIqo
Ah wait
It says subscription_create
Let me try again, strangely for the one in the LIVE environment it said subscription_update in my logs, even though it was the first one. I will try again.
it depends where you look
your account has a default API version from 2016, so when you look at raw events in the dashboard they're rendered using that
also your livemode webhook endpoint does not have a specific API version set,(your test mode version does though), so it recieves everything rendered in the 2016 version
I thought I define that via the API/request itself ('stripe_version' => '2020-08-27')
that's the version your request uses yes
that doesn't influence what webhooks do, the webhook is sent either using your account's default version, or the API version set on the webhook endpoint (there's options in the Dashboard and API when creating the endpoint to pick "latest version or account default")
Oh okay where can I change those to the api that I'm using?
you can't change it on an existing endpoint, it can only be set when creating an endpoint
if you look at the UI in the Dashboard->Developer->Webhooks section for creating a new endpoint you should see the options
So I need to create a new one and delete the previous one?
And is there a way to see all open endpoint requests? If a request fails, it will be send again if Im not wrong. Is there an option I can see all failed ones that have not yet been requested again?
if you want to set the API version on the endpoint then I would say yes