#zach_meters-v2
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/1300612847231045727
๐ 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.
- zach_api, 8 hours ago, 60 messages
- zach_billing-credit-specificity, 3 days ago, 8 messages
I am using a new sandbox environment
when i go to developer workbench I see
when i click that it shows 0 logs
if i put the request id: req_v2UxJKVj2zz2RFSUj into the search bar, i see no resuts.
Beyond that, my main question is what is the parameter I shouldl be sending the Value Unit for the meter in?
I see :
is the field event_payload_key? or something else
๐ this is brand new and I have never used it yet so bear with me
zach_meters-v2
@dreamy ermine Can you share your exact code as text (not pictures please)?
client = stripe.StripeClient(stripe.api_key)
for i in range(number_of_records):
client.v2.billing.meter_events.create({
"identifier": str(uuid.uuid4()),
"event_name": "page_processing",
"timestamp": "2024-10-28T12:00:00.000Z",
"payload": {"value": "page", "stripe_customer_id": customer_id },
})
this is what i am trying to do
the UOM of this meter is "page"
originally I was trying something like:
client = stripe.StripeClient(stripe.api_key)
for i in range(number_of_records):
client.v2.billing.meter_events.create({
"identifier": str(uuid.uuid4()),
"event_name": "page_processing",
"timestamp": "2024-10-28T12:00:00.000Z",
"payload": {"value": "25", "stripe_customer_id": customer_id },
})
What exact doc are you following?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
gotcha so you aren't following any real guide right now and instead just calling that API from the reference with no context?
yes, if you have a guide i am all ears ๐
yes i had read this as well
that's the main guide. But as I said it's all new (and personally I think it makes no sense either)
๐
Give me a few minutes to try and figure out why your request doesn't work though!
thank you
its very odd, it shows errors with those request ids
but those request ids are nowhere to be found
you can't really paste a request id in the search that way for v2 APIs
and yeah okay I get the same exact error locally. Let me try to figure out what part of the docs are wrong
thanks.
oh boy I am so mad right now. What a horrible error
So the problem is that you need to put a real Customer id cus_12345 in that request otherwise you get a cryptic error
I do php and here's my script that works fine ```$customer = $stripe->customers->create();
$meter = $stripe->billing->meters->create([
'display_name' => 'Meter ' . uniqid(),
'event_name' => 'Meter ' . uniqid(),
'default_aggregation' => [
'formula' => 'sum',
],
'customer_mapping' => [
'event_payload_key' => 'stripe_customer_id',
'type' => 'by_id',
],
'value_settings' => [
'event_payload_key' => 'value'
],
]);
$meterEvent = $stripe->v2->billing->meterEvents->create([
'identifier' => 'idmp_12345678',
'event_name' => $meter->event_name,
'timestamp' => '2024-10-28T12:00:00.000Z',
'payload' => [
'stripe_customer_id' => $customer->id,
'value' => '25',
],
]);```
Is it possible your code has an empty value for customer_id?
I do not think so, it should be a valid one
cus_R7GqviIgCtbI7T
stripe_customer_id
is what i am sending this as part of, inside of the paylod
Also the message "'You must submit a value reference in the payload value of page as defined in the meter.'"
means it made it all the way to that meter
because that is the value unit of that meter
Can we start from the top because you lost me a bit sadly. Do you have a clear and exact repro with the exact request you did in each order?
Because for me value is what I pass for the MeterEvent value
Sure
I have created a new sandbox environment, because v2 meter api doesnt work in test mode.
I am trying to send usage using the v2 api
Sorry please pause for a sec
Can you try and write a clear summary all in one message with the exact code example for each API you called in the right order?
That will ensure we're aligned and looking at the same thing. I have to run in a few minutes and someone else on my team is going to take over and I worry the really short sentences in succession aren't going to help since it's all so confusing already.
I want to make sure they jump in and have your clear
I did this exact code xxxx which create object AAA then I did the code yyyy which created object BBBB then I did the code zzzz which gives the error CCC
ok
I wrote the following code, trying to trigger usage to the new V2 Meters API. I am trying to send usage for a meter who has an override value unit (page): client = stripe.StripeClient(stripe.api_key)
client.v2.billing.meter_events.create({
"identifier": str(uuid.uuid4()),
"event_name": "page_processing",
"timestamp": "2024-10-28T12:00:00.000Z",
"payload": {"value": "25", "stripe_customer_id": customer_id },
})
This gives the following error: Error creating usage document: Request req_v2YaJp6v0NS9alaV5: You must submit a value reference in the payload value of `page` as defined in the meter.
๐ taking over from koopajah, gimme a while to go through what you just wrote
ok thx
I just had an idea... should "value" in the payload be "page"?
is thats whats missing
yep, payload should be page
client.v2.billing.meter_events.create({
"identifier": str(uuid.uuid4()),
"event_name": "page_processing",
"timestamp": "2024-10-28T12:00:00.000Z",
"payload": {"page": "25", "stripe_customer_id": customer_id },
})
like this correct?
yup trying now
ok this worked !
how would I send multiple events at once?
the guide didnt really show
maybe can you explain a bit more about sending multiple events at once?
there's no batch API equivalent if that's what you're asking. you need to run client.v2.billing.meter_events.create for each event you want to create/send
so what its the advantage of v2 then vs v1?
if they need to be sent 1 at a time?
like how can this throughput be achieved
like...run your code? have parallel processing / multi threading? it doesn't take an application very long to run a piece of code
but i can only send 1 usage event per customer at a time
or an error is thrown in v1
what's the error you saw? can you share the request id?
I can't unfortunatley I had actually reached out on this topic earlier today and was confirmed by one of your colleagues that this is still a limiitation of v2
zach_api, 8 hours ago, 60 messages
i'm pretty confused, you said that you can only send 1 usage event per customer at a time or an error is thrown in v1, yet you're referring to v2
in any case, i'm assuming that you've explained it in detail to my colleague, and they've already advised you accordingly
yes because v1 isnt giving us enough throughput
we thought v2 would help with this, but it seems now getting into the weeds that the same issues exist
yes they advised me, but my new impression was in 1 call to this new v2 api, i could send more than 1 usage record at a time
so rather than parallelize (which has this limitation), i could "batch"
something like :
i think our docs are pretty clear in this case, if "batching" was possible, Billing Events would have mentioned that it accepts an array of objects, but it doesn't
I guess what im asking is what is "Supports up to 1,000 events per second in livemode."
this is for users who have 1,000 different customers hitting the same meter during that second?
i thought that these 1,000 will be validated, a synchronous response sent back
then on stripe backend, these would be processed asynchronously 1 at a time, allowing this throughput from a consumer perspective, as there will be no 2 meter statements hitting the same customer at the same time
I have to hop off for a personal event, appreacitate you time, will check back to see if you have any thoughts on this.