#Sandro
1 messages ยท Page 1 of 1 (latest)
Hi there!
Okay I found that the customer is missing. Maybe I'll ask in a different direction. How can I create a fixture that first triggers checkout.session_completed and then mocks the event invoice.payment_failed
Currently, I am just copy&pasting from both fixtures which is wrong I think
Hi ๐๐ฝ & thanks for your help ๐
๐ taking over for my colleague. Let me catch up.
๐๐ฝ amazing thanks
I will be with you shortly
when you say invoice.payment_failed are you looking for a recurring invoice or a one-off?
I don't understand the flow to be be honest, are you creating 2 payments? one in checkout and one in the invoice?
So the intention behind that is that I am implementing subscriptions right now. And I want to block access to the subscription on my end if a payment fails. And for that I need to handle invoice.payment_failed right? If I understand the docs correctly.
I want to test the whole flow locally if it works like that
So my first Webhook listens to the event checkout.session_completed and creates some stuff on our end. After this is done I want to mock a failure.
Since I can't work with customer IDs in the fixtures (I think) I wanted to mock the whole flow.
ok but here you're not really dealing with subscriptions
which is the whole purpose of your flow
Ah okay I thought the even invoice.payment_failed is invoked if some subscription also fails?
Like described here: https://stripe.com/docs/billing/subscriptions/webhooks#payment-failures
give me a couple of minutes I will concoct a fixture for you that does the required scenario
That is amazing thank you ๐
are you creating the subscription via checkout?
Yes
this can't be tested with cards though
in checkout the session doesn't get completed unless the payment was gone through
Ah okay makes sense. So how could I test the following scenario:
- User subscribes via checkout -> payment suceeds
- User payment fails
I don't need the first one normally. But sine I cannot add a customer ID to the fixture of two I need the first one that some DB changed will be added on our side
Or which event will even be invoked if the payment fails? From the page above I thought it is invoice.payment_failed also for recurring subscriptions. But I think you said thats not the case right?
I just have no idea how to mock this event currently. I can't enter a wrong card in checkout since the checkout completed event is then not triggered. But I can also not trigger it from the CLI because I can't pass a customer ID
I think you'd be better off writing a script in your language of choice using Test Clocks to achieve this
You wouldn't use checkout for that of course, just a direct subscription api call
Okay and there is also no "easy" way of simply triggering a subscription payment failed event somehow from the UI? Because basically I just want that the webhook is invoked or even understand which webhook type exactly will be invoked
Or is the Subscription Status also invoking an webhook event?
So I am talking about recurring payment not the initial one. Just to be sure ๐
Yep, i understand its about the recurring/automatic one
This is why i suggest setting up a test script with Test Clocks:
https://stripe.com/docs/billing/testing/test-clocks
1/ Create customer, attach basic success card, create subscription
2/ advance test clock time to mid-cycle
3/ attach the "customer attach and fail payment" card 0341 and set it as the customer invoice or subscription defualt
4/ advance test clock time past the sub renewal