#Sandro

1 messages ยท Page 1 of 1 (latest)

hearty thistleBOT
scarlet rapids
#

Hi there!

deft holly
#

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

deft holly
fathom bison
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

deft holly
fathom bison
#

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?

deft holly
#

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.

fathom bison
#

ok but here you're not really dealing with subscriptions

#

which is the whole purpose of your flow

deft holly
fathom bison
#

give me a couple of minutes I will concoct a fixture for you that does the required scenario

deft holly
#

That is amazing thank you ๐Ÿ™‚

fathom bison
#

are you creating the subscription via checkout?

deft holly
#

Yes

fathom bison
#

this can't be tested with cards though

#

in checkout the session doesn't get completed unless the payment was gone through

deft holly
#

Ah okay makes sense. So how could I test the following scenario:

  1. User subscribes via checkout -> payment suceeds
  2. 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

true osprey
#

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

deft holly
#

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 ๐Ÿ™‚

true osprey
#

Yep, i understand its about the recurring/automatic one

#

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