#dizerss-dev_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ 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/1262211454522753078
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi
I have attempted meter events recording via cron jobs but some numbers are left with the way.
Which events do you use?
Could you share an example what you have done, so that I can take a look how your integration works?
I am using checkout.session.completed , customer.subscription.updated , payment_intent.payment_failed , customer.subscription.deleted as of now
before that, are you familiar with meter events ?
Yes, I'm familiar with meter events
cool
I have a subscription using the new meter.
we have a flat price and in the subscription I we give 50 messages with the plan but any more are going to be charged via meter events
I'll try to find a sub Id which has this on the dashboard....
but just to be clear..... the usage for my messages I want to record goes through meter events to the meter attached to the subscription...... the meter event call is being done via cron jobs right now.
which are run every day.
but messages are missed because of time variations of cron jobs running and the actual subscriptions being on different times.
but messages are missed because of time variations of cron jobs running and the actual subscriptions being on different times.
Could you share an example subscription (sub_xxx) with this issue, and the expected and actual behaviours?
ohh sorry If I am not clear english is not my first language
I am not having an issue. I just want to do things via a webhook event
but I am having trouble finding the right event for this.
mtr_test_61Qc0jwdbUaVeWly241Hn5Ll2SPft3Ka
this is one of the meters. I just want there to be an event from which I can record the usage from the webhook function to the meter instead of using cron jobs to record usage.
I hope that makes sense.
if not I'll try to be more brief.
attached to price which was in this sub sub_1PSct7Hn5Ll2SPftDo3m2Ni5
Webhook event is sent from Stripe to your server to be informed on the payments and changes on your account. It's not meant for you to submit the meter events.
Submitting record usage can only be done via meter events API
understood but the call to that api I wish to be from a webhook event.
so if there is an event which can be catched to before the subscription charges the customer.
something like this :
Am I right to understand you would like to be informed by an event that the current cycle ends, so that you can submit the usage records before the invoice is finalised and charged to customer?
event ("stripe event before user is charged"):
-
-
- fetch sub data
-
-
-
- fetch meter data
-
-
-
- call the meter events api and send usage.
-
Then in stripe that usage is recorded into that sub and charged to the user.
Yes Exactly.
I am just trying to find such an event I can catch on my side to call the meter events api to record usage..... you explained it perfectly
Thanks for confirming that! This is possible by listening to invoice.created event. An invoice will be in draft status for an hour before it gets finalised, which we call this the grace period. During this grace period, you can submit the final usage records: https://docs.stripe.com/billing/subscriptions/usage-based/pricing-models#grace-periods
Amazing. I'll check that. Thank you so much โค๏ธ
No problem! Happy to help ๐
Take care bye