Say, I use stripe subscriptions for my users with one plan which is $10 per month for 100 API requests and that's the standard price. However, if the user has used 150 API requests, I charge them $3 more on top on $10. For 200 and more requests it's total of $17.
Say, I've subscribed the user on October 9th. On November 9th they will be charged again by Stripe. When should I "freeze" the amount of the APIs the user has used during the month to calculate the overall price and start counting from zero again for the new period of November 9th - December 9th?
As far as I'm concerned, it's either on payment.success
or invoice.success
event in my stripe web hook controller. However, I think it's not reliable because:
Which one is it exactly -
payment.success
orinvoice.success
- the one I need? They occur both, as far as I know sometimespayment.success
occurs first, sometimes -invoice.success
and it's unknown which one occurs first in each particular case.Theres's the time period between these 2 events, I don't know how long exactly, probably a few minutes. But during those few minutes the user might consume at least one Invoice
I'm not sure if it's guaranteed that for each user the events
payment.success
andinvoice.success
occur only once per month. Do they really? If not it's even less reliable to use them to achieve my goal.invoice.created
event occurs 1 hour before the Invoice is closed.