#Robert-Ibracadabra - live webhook test
1 messages ยท Page 1 of 1 (latest)
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?
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?
Ah gotcha. I think we have a card for that, let me find it
I believe there is a card for that
We have a card that you can use for this that has a description of "Decline after attaching" on this page https://stripe.com/docs/testing
but I need to change it somehow
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
Oh so i can use that through normal flow and when I trigger it again for subscription it should fail
Correct
Ok I just tried it and It triggered my handlePaymentThatRequiresCustomerAction ๐ I am using the old flow (because of customer requirements).
(In frontend)
Nice! Is the rest of your test going smoothly so far?
Well I need to check how to handle it ๐
Because It should have completed
Well it gets blocked by handleRequiresPaymentMethod
Ah I see, does failing upfront in your test not create the invoice.payment_failed event?
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 :(?
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.