#philiiiiiipp_api
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/1425851646671323258
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hey there, how are you sending these events, just so i know to look at this the right way?
I am sending them over the API
.billing.meterEvents.create({
event_name: args.event_name,
payload: {
stripe_customer_id: args.stripeCustomerId,
value: args.value.toString(),
},
});
Are you sending them individually, or using the session pattern?
ok, individual, thanks
Yes exactly
I'm still looking at this and confirm i do see the 250 events for that meter, but honestly i'm surprised any are included in the first invoice you shared since the timestamp seems to be outside of the period for the invoice
weird
did you find something ?
A bit more, yes
So take a look at the line item (il_1SGKglHt7MWLVB7OLGPjCTw9) for that invoice for that subscription item (si_TCk9qS9JjrebPb)
in the invoice created event:
https://dashboard.stripe.com/test/events/evt_1SGKgoHt7MWLVB7OtOKln0bz
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
We can see there the period is:
period: {
end: 1760019540,
start: 1760019487
},
which only includes a subset of your events, but a different number by my count (181 vs 64)
181 would be the correct number for the first invoice since 69 are leftover for the next invoice
hmm
ok i think i'm going to need to convert this to a case so i can continue to investigate, but i have a couple more questions about some theories
Ok
I'm having trouble tying these meter events to api requests, could you loosely describe when these events would have been sent relative to the subscription update event that triggered the invoice?
immediately/seconds prior, minutes prior?
The code looks like this
for (let i = 0; i < 250; i++) {
await DHStripe.addMeterEvent({
event_name: 'biedwijzer_active_contacts',
stripeCustomerId: sub.stripeCustomerId,
value: 1,
});
}
await getApolloSDK(environment).updatePlan({
accountId,
planId: 'crocs_plan_leadGeneratorPro',
billingCycle: BillingCycle.Monthly,
});
my hypothesis is that the events were not ingested into the usage summary prior to the invoice generation, but then i would expect them to land in the following invoice instead of disappearing
So they are all send after each other, and once done probably a second will pass before the subscription updated
Exactly thats also what I would have expected
I tried adding a wait before the events and the subscription update of 10s
cus_TClxCEQf4xoxxs now I have 95 events in_1SGMQhHt7MWLVB7OZfT5SLyp
and 155 left which seems correct
If you use the create preview invoice for the original subscription, does that produce a preview with the correct amount (compared to wrong amount in dashboard)?
Checking
and please share the request ID of that call
Ok yea, the corresponding line item there has
period: {
end: 1762697940,
start: 1760019540,
},
which captures the 69 events
so it seems like the usage in the preceding period, not processed by the time you trigger the invoice, is then excluded
Should I trigger another invoice to be generated to see if those are then included ?
Yea let's do that just to have a firm invoice and eliminate any misbehaviour of various previews
Then we'll convert to a case and i'll drive investigation internally
ill be right back while you trigger that
I see in_1SGMiwHt7MWLVB7ODLYBlbjY there now
Alright. What I did is the following.
- Create a new account cus_TCmLNXsCYc9By6
- Send 250 events
- Trigger an invoice generation in_1SGMo6Ht7MWLVB7OxFid29el (contains 113)
- Wait for 10 seconds
- Generate a new invoice in_1SGMoSHt7MWLVB7OlOHnj5KF (contains 0)
Yes to be honest not sure what happened there
I tried to hack it into our system but I think something went odd so I recreated it
Yea not clear why that is for 0eur
I would have expected the 69 events/usage there
oh, i see, the relevant subscription item was deleted: https://dashboard.stripe.com/test/logs/req_i0kDrBTOufblsF
Aha, that makes sense
But we actually do not delete the items
I think at least
Hmm that is a bug then I think
You mean on your app for the delete?
Yes, it should not have deleted the line subscription item
Okay, maybe I have to check this in detail what we do there maybe this is also a reason why the preview got a bit screwed ?
right, so you'll likely need to re-exercise this path to generate a new one
The delete seems to have only happened just before you triggered the invoice again via billing cycle anchor now
It is expected that deleted items drop uninvoiced usage, that part is fine
I tried recreating it again, now it looks correct from my side at least. But the invoices are weirder.
I do 20 seconds in between invoice generations and I then advanced the time in the dashboard. Only the last invoice has items (128) in_1SGN9cHt7MWLVB7OztW8CwZV
None of the other invoices have anything
ok i'm going to have our bot message you a link to convert this to a case so i can follow up there async after more investigation on the new example
Hello @hardy hamlet, we have sent you a direct message, please check it at https://discord.com/channels/@me/1425891107878736013
- 🔗The message has instructions on how to open a direct support case with our Developer Support team, in order to help you more effectively.