#mad-trial-will-end-event
1 messages ยท Page 1 of 1 (latest)
Hey!
here's the request ID req_LD7vawYYVUIwnF for my request to end the trial (before the trial_end date)
and here's the webhook event id:
2021-12-17 09:25:06 --> customer.subscription.trial_will_end [evt_1K7cgXBVFeaV0FZKzZBu9aXV]
Thanks, will take a look!
Many thanks @analog zodiac ๐
Hmm. Yeah, can see the trial_end is updated in your API call, but not reflected in that event
any idea why ?
I mean why customer.subscription.trial_will_end is fired out of that 3 days to trial_end range ?
I don't I'm afraid. My guess is that it's some kind of race condition โ the event is fired before the actual Subscription object is updated. For example, this customer.subscription.updated event has the expected trial_end value: https://dashboard.stripe.com/test/events/evt_1K7cgYBVFeaV0FZKnxv2L18U
And it's sent at the same timestamp as the customer.subscription.trial_will_end (2021-12-17 09:25:05)
But we can't guarantee ordering: https://stripe.com/docs/webhooks/best-practices#event-ordering
So you probably need to code a little defensively in your webhook handler to prevent this
i get it, so maybe delaying like 2seconds, and asking back for that subscription state to see if active or trialing ?
is there a possible calculation between date to see if it's in that 3 days period
Yeah, I guess that would work
You can use the trial_end timestamp and compare it to Date.now()
And see if it's actually within the timeframe you want
yay this seems a better solution, thank you for your time ๐
stripe timestamps are UTC ?
Yep!
implemented and tested, all good ! many thanks ๐
Nice, np!