#osamabinishrat

1 messages · Page 1 of 1 (latest)

old torrentBOT
half flare
#

Hi there, can you share with me the code?

thin heart
#

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

half flare
thin heart
#

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.

half flare
#

I see, so you want to remove that usage by setting the quantity to 0?

thin heart
#

exactly or just update the quantity to 538

#

is there any way i can update that usage record to 538?

half flare
#

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?

thin heart
#

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

half flare
#

Hmm, but the quantity that you set in the code is 0 , not 1355.

thin heart
#

Above code example I gave you was to set the existing record to quantity 0.

Our actual code generated 1355 quantity.

half flare
thin heart
#

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!

half flare
#

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.

thin heart
#

Sure, thanks

half flare
#

It seems like there' no way to list the usage records through API.

thin heart
#

Oh bad, however we can look at the network call on browser and find the exact time stamp

half flare
#

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.