#bugkiller.

1 messages ยท Page 1 of 1 (latest)

lethal elkBOT
worthy kindle
#

Hi there ๐Ÿ‘‹ interesting, I'm not sure offhand if that is expected. Can you share the ID of the Subscription, and the ID of the Event that you received, so I can take a closer look at those?

buoyant robin
#

how are you?

#

sub_1NZr9gBTGnRwDyDi25MDyDgW

worthy kindle
#

I'm doing alright, hope you are as well! Thank you, I'm working on pulling that up.

#

Do you have a more recent example? The date of when that Event would have been generated is more than 30 days ago, so finding the related Event will be difficult due to the Event being outside of our retention period.

buoyant robin
#

retention is 15 days?

#

hi toby

#

sub_1NTqGvBTGnRwDyDi0hiOrodE

#

this is also old to check?

worthy kindle
#

Retention period is 30 days, the previous subscription's upcoming invoice event would have been sent on Aug 4. Taking a look at the second one.

#

Yes, that one is also too old, the invoice.upcoming Event for it would have been sent on July 18th.

buoyant robin
#

we got that call on 2 days ago

worthy kindle
buoyant robin
#

I'm not sure event id

#

we have logic to send upcoming invoice eamil inside webhook for 'invoice.upcoming' and it's fired 2 days ago

#

(that email is only used inside 'invoice.upcoming' webhook code. no any other places)

worthy kindle
#

It's going to be hard for me to get a sense of what is going on without being able to see the Events that you're concerned about. What is making you think the Event is related to this Subscription that has been cancelled for more than a month? Is it something you're seeing in the Event body?

lethal elkBOT
buoyant robin
#

ok,

#

I've added some log into our webhook code so that I can bring more information to you when I get it again

#

one other question

#

if you don't mind

distant dawn
#

๐Ÿ‘‹ stepping in here as toby needed to step away

buoyant robin
#

ok, cool

#

I'm going to ask new question so no matter

distant dawn
#

๐Ÿ‘

buoyant robin
#

we're going to send an email to user if their subscription is canceled due to payment failure

#

how to archive this?

#

this is our retry setting

distant dawn
#

You would listen for customer.subscription.deleted

buoyant robin
#

but I don't want to send an email if subscription is canceled by user

distant dawn
#

Then you want to check the latest Invoice on the Subscription and see if it has used up all of its attempst via looking at attempt_count

buoyant robin
#

what should be that number it is based on oiur 'failed payments' setting

distant dawn
#

Yep

#

Depends on however many retries you have set in your Settings

buoyant robin
#

yes, I already shared it

#

with screensho

#

t

distant dawn
#

Sure

#

So yes... in that screenshot you have 1 retry set up

#

You can also test this out quite easily!

buoyant robin
#

so what should be a number to check

#

attempt_count == ?

#

I don't know how to test it easily and quickly

distant dawn
#

That said, you would want attempt_count to be 2 in this case

#

That would mean there was an initial attempt and one retry

buoyant robin
#

ok, so it means I need to implement webhook for the event customer.subscription.deleted and inside that event I'll try to check latest invoice's attempt count

#

if that attempt_count is 2 ( based on my payment retry setting), I can consider subscription is canceled due to payment retry failure

#

Am I correct?

distant dawn
#

Yep

buoyant robin
#

how can I find whole request body for specific webhook

#

for example, what kind of data will be expected for webhook customer.subscription.deleted

distant dawn
#

It is the object that is associated with the Webhook.

buoyant robin
#

what I can see in the doc is this

distant dawn
#

So see how that says is a subscription

#

That means it is a Subscription object

buoyant robin
#

makes sense

#

then I have subscription object, then I need to retrieve the latest invoice via stripe api for this specific subscription to check my goal right?

distant dawn
#

Correct, you can actually just re-retrieve the Subscription and expand the latest_invoice when you do that

#

Are you familiar with expansion?

buoyant robin
#

yes, I'm

#

You're so kind. I'm really appreciate it

distant dawn
#

Happy to help

buoyant robin
#

Please leave this chat to be open.

#

so that I can ask you again if needed.

distant dawn
#

Sure it will stay open for a bit

#

If it does get closed you can always just post again the main channel

buoyant robin
#

hi

#

customer.subscription.deleted

#

in this webhook, subscription status will be always 'canceled' ?

#

am I correct?

distant dawn
#

Yes