#philiiiiiipp_api

1 messages · Page 1 of 1 (latest)

fast turtleBOT
#

👋 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.

magic stump
#

Hey there, how are you sending these events, just so i know to look at this the right way?

hardy hamlet
#

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(),
      },
    });
magic stump
#

Are you sending them individually, or using the session pattern?

#

ok, individual, thanks

hardy hamlet
#

Yes exactly

magic stump
#

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

hardy hamlet
#

weird

hardy hamlet
#

did you find something ?

magic stump
#

A bit more, yes

#

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)

fast turtleBOT
hardy hamlet
#

181 would be the correct number for the first invoice since 69 are leftover for the next invoice

magic stump
#

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

hardy hamlet
#

Ok

magic stump
#

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?

hardy hamlet
#

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,
      });
magic stump
#

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

hardy hamlet
#

So they are all send after each other, and once done probably a second will pass before the subscription updated

hardy hamlet
#

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

magic stump
#

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)?

hardy hamlet
#

Checking

magic stump
#

and please share the request ID of that call

hardy hamlet
#

no its the same

#

upcoming_in_1SGMVJHt7MWLVB7OBinjb1HS

#

req_gL03SQluvm02CS

magic stump
#

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

hardy hamlet
#

Should I trigger another invoice to be generated to see if those are then included ?

magic stump
#

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

hardy hamlet
#

Alright. What I did is the following.

  1. Create a new account cus_TCmLNXsCYc9By6
  2. Send 250 events
  3. Trigger an invoice generation in_1SGMo6Ht7MWLVB7OxFid29el (contains 113)
  4. Wait for 10 seconds
  5. Generate a new invoice in_1SGMoSHt7MWLVB7OlOHnj5KF (contains 0)
hardy hamlet
#

I tried to hack it into our system but I think something went odd so I recreated it

magic stump
#

Yea not clear why that is for 0eur

#

I would have expected the 69 events/usage there

hardy hamlet
#

Aha, that makes sense

#

But we actually do not delete the items

#

I think at least

#

Hmm that is a bug then I think

magic stump
#

You mean on your app for the delete?

hardy hamlet
#

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 ?

magic stump
#

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

hardy hamlet
#

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

magic stump
#

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

fast turtleBOT
#

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.
fast turtleBOT