#kasun_invoice-webhook-events
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/1343623291197329492
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
This webhook event is a customer.subscription.udpated type. This will fire for anything that updates the Subscription.
yeah but we get it for failed subs also...for example this customer had an issue
we got an active status with webhook...
Of course you do
It fires for any change to the Subscription, like I said
The Subscription object itself is returned though
so you can examine those details
so what we want to filter is whether customer has paid for sub...
Try listening to the invoice.paid event https://docs.stripe.com/api/events/types#event_types-invoice.paid
Or you can retrieve the current Invoice for the Subscription and check that status
customer.subscription.udpated doing it here will work right?
how can we get current invoice for the sub
The event object returns the full Subscription object and that includes the latest_invoice parameter.
You can retrieve the full Invoice object by using that ID to retrieve the Invoice via the API
https://docs.stripe.com/api/invoices/retrieve
For the event you shared, that ID is in_1QvhyvKk6Qk5jHuWrwtWaJhp
oh thanks
can we expand latest invoice as well?
so we dont have to make an additonal api call?
You cannot expand a webhook response, no
oh no i meant subscription object
we are getting that
not relying on webhook event
If you retrieve the Subscription object then yes, you can expand the latest_invoice so you can review the status of that Invoice.
You might also consider listening to the invoice.payment_failed webhook event if you want to trigger specific actions when a payment fails.
cool
in invoice there are two fields
status and paid
should we consider both?
status === paid && paid === true ?
They have different purposes
You should use the one that best fits your integration
hmm its bit confusing that status can be paid and also paid field can be true
can we have status = paid and paid = false scenario?
How is that confusing. If paid is True. the Status has to be paid
No
They serve different purposes
paid tells you if your invoice is paid or not, nothing else
status tells you what the current status of the Invoice is
so in our case i think checking paid === true will be fine
as we want to provision some resouces
for users who paid
That makes sense. that's what the paid property is for