#kasun_invoice-webhook-events

1 messages ยท Page 1 of 1 (latest)

topaz atlasBOT
#

๐Ÿ‘‹ 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.

modest galleon
#

Hi ๐Ÿ‘‹

This webhook event is a customer.subscription.udpated type. This will fire for anything that updates the Subscription.

wintry snow
#

yeah but we get it for failed subs also...for example this customer had an issue

we got an active status with webhook...

modest galleon
#

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

wintry snow
#

so what we want to filter is whether customer has paid for sub...

modest galleon
#

Or you can retrieve the current Invoice for the Subscription and check that status

wintry snow
#

customer.subscription.udpated doing it here will work right?

#

how can we get current invoice for the sub

modest galleon
#

The event object returns the full Subscription object and that includes the latest_invoice parameter.

#

For the event you shared, that ID is in_1QvhyvKk6Qk5jHuWrwtWaJhp

wintry snow
#

oh thanks

#

can we expand latest invoice as well?

#

so we dont have to make an additonal api call?

modest galleon
#

You cannot expand a webhook response, no

wintry snow
#

oh no i meant subscription object

#

we are getting that

#

not relying on webhook event

modest galleon
#

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.

wintry snow
#

cool

#

in invoice there are two fields

status and paid

#

should we consider both?

#

status === paid && paid === true ?

modest galleon
#

They have different purposes

#

You should use the one that best fits your integration

wintry snow
#

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?

modest galleon
#

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

wintry snow
#

so in our case i think checking paid === true will be fine

#

as we want to provision some resouces

#

for users who paid

modest galleon
#

That makes sense. that's what the paid property is for