#blackbearftw_docs

1 messages ยท Page 1 of 1 (latest)

fluid valleyBOT
#

๐Ÿ‘‹ 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/1296416865446264922

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

supple dune
#

Our goal is to bill per resource the user creates, per month, so if a user creates 20 records in a month, I would like to get that value, at the start of the billing period it would go back to 0 again

ember wedge
#

hi there!

#

to get the current value of a meter, you should use MeterEventSummaryListOptions, which you seem to be already using.

#

what's the issue with the code you shared?

supple dune
#

Stripe.StripeException: start_time 1726567998 should be aligned with daily boundaries (expected 1726531200) because thevalue_grouping_windowis day.

#

I also have another question, if I create a pay as you go subscription with a monthly billing, will the user be charged at the end of each calendar month or is a charge being made relative to when the user started their subscription (e.g. user subscribes on 2 okt, will they be charged on the 2 nov)?

ember wedge
#

if I create a pay as you go subscription with a monthly billing, will the user be charged at the end of each calendar month or is a charge being made relative to when the user started their subscription
by default it's relative to their start date, but that's something you could configure: https://docs.stripe.com/billing/subscriptions/billing-cycle

supple dune
#

req_9p9JsYM3RUdCvX

supple dune
#

because now I need to figure out the start and end time relative to the customer right

#

to get their billing period synced up

noble merlin
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

#

basically the error here is kind of self-explanatory.

#

when using value_grouping_window you need to respect the start of the hour or the start of the day depending on the value_grouping_window you're choosing

#

basically if you choose to group by hour

#

the start_time needs to be set on the top of the hour (e.g. 01:00, 02:00,...,22:00, etc.)

supple dune
#

yeah I understand

noble merlin
#

the same applies for the end_time and when you're using the value_grouping_window day

supple dune
#

but in reality I don't really care about that, I just want the get the current value on this moment in time

#

yeah

noble merlin
#

then you don't need to use the grouping

#

the grouping is to aggregate by day or hour

supple dune
#

can I then only pass the customerId?

noble merlin
#

yes

#

and you can send start and end time as well

#

but just remove the value_grouping_window in that case

#

since it's not Required

supple dune
#

what do I then set the start and end time to?

noble merlin
#

whatever timeframe you want

#

it realy depends on your use-case

supple dune
#

as I said, I want to get the current value of the meter for the billing period of the customer

#

I know a meter can only go up

noble merlin
#

then from the subscription

#

and use these as the start_time and end_time

supple dune
#

but how does that work on stripes side, does this meter reset at the start of the next billing period?

noble merlin
#

no

#

technically the billing meter will keep receiving events

#

but we will use the events between the current_period_start and current_period_end to calculate the usage of this period

supple dune
#

its really annoying how I have to figure all of that out on my side

#

my entire use case is to have a customer, with a pay-as-you-go subscription, they create a resource through our API, at the end of their billing period, it checks how many resources were created that month (or whatever the billing is set to) and then just charges the user for that amount

#

but you are saying, I now need to first figure out the billing period of the current customer, which requires an api request, then I need to ask for their metered events, which is an api request, then I need to look at the first value in that collection and then at the last value and then subtract those from eachother just to get the relative value for this billing period

noble merlin
supple dune
#

how is it not?

#

because my goal is just being able to relatively update that value

noble merlin
#

you don't have to do any of that

#

since the subscription will calculate everything for you

#

and would generate the invoice on your behalf

noble merlin
supple dune
#

what I want to do in OUR api, is simply call some wrapper service, call something like StripeBuildingMeterService.AddToMeter(1) (our resource is called building)

noble merlin
#

this is for the usage record

supple dune
#

yeah

noble merlin
supple dune
#

yeah see how value is not a relative number

noble merlin
noble merlin
supple dune
#

but I want to

#

that is the whole idea

#

as soon as our create API endpoint is hit, I want the meter to do +1

noble merlin
#

it will

supple dune
#

so if I pass a value

noble merlin
#

you can either choose sum or count

supple dune
#

I have count

#

I want it to relatively add it to the current meter's value

noble merlin
#

if it's count then it will only the count the number of events

#

if you choose sum

#

each time you send an event the value is added to the previous ones

supple dune
#

then your documentation sucks because it gives 25 as an example

#

making it look like that is the current whole value of the meter

noble merlin
#

if the formula the meters uses is sum (which is generally the case)

#

this means that you're adding 25 to the previous quantities recorded

supple dune
#

okay

#

cool

noble merlin
#

the whole thing

#

so you get familiar with the different concepts

#

I'm here to answer any other question you have

#

so please let me know if you have any follow-ups

supple dune
#

okay so this sets the value

#

how can I see how much currently is being billed for

fluid valleyBOT
supple dune
#

aka how many units are created this billing period

supple dune
noble merlin
noble merlin
#

and when choosing Last, it means that each time you override the value

supple dune
#

alright

#

the difference about sum and count is still not very clear to me to be honest

#

even when reading the documentation

noble merlin
#

sum means Stripe will add all the values you passed to the different meter events you sent during the billing period

#

count means Stripe will count the number of times you sent meter events during the billing period

#

is that clearer?

supple dune
#

so sum looks at the overal value per billing period (however many events that might have taken), while count looks at the amount of events (and not at their value) send that billing period

pulsar adder
#

Correct, yes

supple dune
#

okay

#

ill will try this now

#

if possible, please leave this thread open