#abu-zain_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1290393243044937862
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I am integrating Stripe hooks, and this is what I am expecting:
I am allowing users to subscribe to any subscription, and they can visit the customer portal to update the payment method, change the plan, or cancel the subscription. Here is what I am currently doing:
I am listening to the checkout.session.completed event, extracting details like current_period_end, current_period_start, status, customerId, and subscriptionId, and updating the user based on the email that I set while creating the checkout session.
For the above status, I handle the case when the user subscribes to a subscription, and I am listening to the invoice.paid event to set the invoice status to paid.
To handle the payment failure case, I am listening to the invoice.payment_failed event, setting the invoice status to the one provided by Stripe, and updating the subscriptionStatus.
I am also listening to the customer.subscription.updated event in case the user updates their plan, and extracting details like:
subscriptionIdplanNamecurrent_period_startcurrent_period_endstatus
Then I update the user accordingly.
Additionally, I am listening to the customer.subscription.deleted event to handle the case when the user cancels their plan.
Now, my concern is handling recurring payment failures. For this, I am listening to the invoice.payment_failed event, but I am not receiving this event. Instead, I am getting these events:
customer.subscription.updatedcustomer.subscription.updatedinvoice.createdcheckout.session.expired
Hello
It looks like the invoice.payment_failed event was delivered successfully: https://dashboard.stripe.com/test/events/evt_1Q4oEzChxZS78XGQN2G36MAq
we received a 200 response from your Stripe CLI endpoints
sorry my bad i was looking into the wrong subscription.
all good!
There is one more thing I would like to ask. I am testing the webhooks integration. Would you mind reviewing my current webhooks implementation and letting me know if I am missing something or doing anything wrong?
The best way to know if the implementation works would be to just test it out in different scenarios using different test cards and test clocks.. Much better than reading the code ๐
https://docs.stripe.com/testing
https://docs.stripe.com/billing/testing/test-clocks
Yes, I have checked all of those, but there are a few things that I couldn't find there.
For example, I am listening to the invoice.payment_failed event, and here I am updating the user data, such as subscription status and invoice status. However, this event is also triggered when the checkout fails during the initial subscription. How can I differentiate whether this event is triggered by a recurring payment failure or by the initial failure during subscription?
You can check billing_reason on the invoice object to see if its initial invoice or renewal - https://docs.stripe.com/api/invoices/object#invoice_object-billing_reason
Great thank you i solved it by adding check subscription_create
๐
One more thing: is it possible to manually update the billing cycle of a subscription by using the stripe dashobard? For example, I want to test which events will be triggered when a subscription enters a new billing period for testing purposes
@sudden canyon
Yeah you can use test clocks via dashboard