#selby14-webhooks-subscriptions

1 messages · Page 1 of 1 (latest)

rough jackal
#

That's a great question. Let me check

#

I think the best way to do this would be to get the subscription's current_period_start timestamp and compare it to when you received the event.

still lintel
#

how is that date field encoded, do you know offhand?

rough jackal
#

I want to say UNIX timestamp but let me check

still lintel
#

To be sure I understand, if the current_period_start is basically the same time as the webhook is received, it would be a renewal?

rough jackal
#

It's a UNIX timestamp. And yeah, that's my first thought, but let me see if anyone has any better ideas.

still lintel
#

I'm looking at 2 events, one a renewal and one a subscription upgrade and it looks like both of the current_period_start timestamps are basically the same as the webhook

rough jackal
#

Ah, so another way to do this would be to look at the Event object source property which will be either automatic or API. If it was created automatically (e.g. an auto-renewal) then it will be automatic

#

Does that help?

still lintel
#

possibly, but I'm guessing I would have to do an api call to get the event source?

rough jackal
#

event.source should be in the payload you receive when customer.subscription.update event triggers a webhook to your endpoint