#osamabinishrat
1 messages · Page 1 of 1 (latest)
Hi there, can you share with me the code?
yeah sure,
let response = await stripe.subscriptionItems.createUsageRecord( 'si_N8sc022CdrVY0b', { quantity: 0, action: 'set', timestamp: '1680178080' } );
I tried to update the usage record on "Mar 30, 7:08 AM" using "set" action but instead of updating, it created new entry
Does you subscription has billing_thresholds ? (https://stripe.com/docs/api/subscriptions/object#subscription_object-billing_thresholds)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
No
I can create new usage-records, but it's not allowing me to update the existing ones
One of our technician accidentally added additional hours, it will impact the upcoming invoice for our client.
We don't want to loose that client due to invalid invoice and exceeded number of hours logged.
We need to adjust the invoice by updating usage record.
I see, so you want to remove that usage by setting the quantity to 0?
exactly or just update the quantity to 538
is there any way i can update that usage record to 538?
In your screenshot, there's a record of Mar 30, 7:08AM, and the usage is 0, isn't this the one that your code created?
No, our code created above one having 1355 quantity.
I tried to update that manually through REST API and also from stripe dashboard by giving the exact timestamp but it didn't update that record, instead created new usage-record with 0 quantity on that time stamp
Hmm, but the quantity that you set in the code is 0 , not 1355.
Above code example I gave you was to set the existing record to quantity 0.
Our actual code generated 1355 quantity.
https://stripe.com/docs/api/usage_records/subscription_item_summary_list#usage_record_summary_all did you use this API to list all the usage record and get the timestamp of the record of 1355 quantity?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hmm, let me try
@half flare It only gives the summaries, not the actual record
Hey @half flare
Thanks for your help. I was able to find the exact timestamp for it by inspecting stripe dashboard and looking at network call.
You pushed me in the right direction though.
My issue is resolved now.
Thanks!
It's great to hear that your problem is resolved. Let me check if there's a way to get the list of usage records and I'll get back to you when I found it.
Sure, thanks
It seems like there' no way to list the usage records through API.
Oh bad, however we can look at the network call on browser and find the exact time stamp
Btw, you can't just set quantity to 0 to correct records created previously with action:increment.
Since a single timestamp could be tied to multiple Usage Records that were added together, you should retrieve the current total usage reported for that timestamp (by using the summary listing API that I shared earlier), subtract the quantity they want to delete, and use that value as the quantity in their creation request.