#Robert-Ibracadabra - live webhook test

1 messages ยท Page 1 of 1 (latest)

spark wing
#

Can you rephrase that a bit? I am not sure I understand. Are you looking to resend an event to one of your live endpoints or one of your test ones?

wide beacon
#

Hello, I am testing the actual webhook responses via ngrok on my local environment triggerring webhooks in development mode (paying the subscription)

#

I can test the invoice.payment_succeeded event this way

#

and I see the real data received

#

but for the invoice.payment_failed what do I need to do?

#

I need to assign a card

#

that has no funds available for example?

spark wing
#

Ah gotcha. I think we have a card for that, let me find it

wide beacon
#

I believe there is a card for that

spark wing
wide beacon
#

but I need to change it somehow

spark wing
#

4000000000000341

#

Change it to what?

wide beacon
#

in Dashboard

#

so it does not fail first

spark wing
#

You should be able to set that number in the dashboard

#

That card will not fail at first but will fail when there is a subscription cycle

wide beacon
#

Oh so i can use that through normal flow and when I trigger it again for subscription it should fail

spark wing
#

Correct

wide beacon
#

Ok I just tried it and It triggered my handlePaymentThatRequiresCustomerAction ๐Ÿ™‚ I am using the old flow (because of customer requirements).

#

(In frontend)

spark wing
#

Nice! Is the rest of your test going smoothly so far?

wide beacon
#

Well I need to check how to handle it ๐Ÿ™‚

#

Because It should have completed

#

Well it gets blocked by handleRequiresPaymentMethod

spark wing
#

Ah I see, does failing upfront in your test not create the invoice.payment_failed event?

wide beacon
#

Yes it fails in the frontend

#

I did not check webhook

#

need to see

#

Oh

#

I got the failed event as well

#

Nice!

#

Thank you very much!

#

Another thing that I am curious about is how do i differentiate between the normal flow of a subscription and webhooks?

#

I think normally on the first payment I should not trigger the webhooks

#

Maybe I query firestore to check if it already exists

#

or something simmilar

#

If I do and I need to await it wouldn;t this affect the response time required for 200 to be sent back from the webhook :(?

spark wing
#

The first payment will trigger a webhook. You will want to check the billing_reason property on the Invoice. If you do not have a free trial, the first reason will be subscription_create and it will be subscription_cycle for all payments afterward https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason

wide beacon
#

Yes I just found it on the Webhook ๐Ÿ™‚

#

(on sent JSON)

#

Thank you very much for your help and time!