#deputycheese

1 messages ยท Page 1 of 1 (latest)

stiff cedarBOT
pine kindle
#

Could you please share with me your latest follow up question/issue ?

sacred kestrel
#

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

pine kindle
#

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 ?

sacred kestrel
#

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

pine kindle
#

I need the eventId you are referring to evt_124

sacred kestrel
#

evt_1NkPcpClDK2O5WMjkViyfkCO

#

Ah wait that's invoice.payment_failed not payment_intent.payment_failed

#

payment_intent.payment_failed is indeed correct

pine kindle
#

You don't have billing_reason in payment_intent.payment_failed event

sacred kestrel
#

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?

pine kindle
#

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.

sacred kestrel
#

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

pine kindle
#

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

sacred kestrel
#

Is that ->data->lines->total_count ?

pine kindle
#

No.

sacred kestrel
#

But if the customer pauses/cancels his subscription and then later restart it, that will lead to the same error

pine kindle
#

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 ?

sacred kestrel
#

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

pine kindle
#

Yes that's how thinks work actually.

pine kindle
#

Check the Manage failed payments section

sacred kestrel
#

But why is it working in the dev environment? There I am not getting the failed events during 3ds

#

only in live

sacred kestrel
#

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

pine kindle
#

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

elfin flicker
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

sacred kestrel
#

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

elfin flicker
#

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

sacred kestrel
#

I deleted the endpoint

#

but why cant i select
2020-08-27

elfin flicker
sacred kestrel
#

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 ๐Ÿ˜ญ

elfin flicker
sacred kestrel
#

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

elfin flicker
#

maybe your endpoint is not listening for payment_intent.payment_failed

#

what's the webhook endpoint ID? we_xxx

sacred kestrel
#

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.

elfin flicker
#

you actually received the event

sacred kestrel
#

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

elfin flicker
#

if the event wasn't triggered you'll not received it

#

but this is not related to the webhook endpoints you have

sacred kestrel
#

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

elfin flicker
#

would you mind sharing the link to the page where you got the screenshot from?

sacred kestrel
#

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?

wicked beacon
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needed to step away.

wicked beacon
# sacred kestrel

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.

sacred kestrel
#

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)

wicked beacon
#

Ah gotcha, glad to hear you're all set! Let us know if there is anything else we can help with.