#Ben Clum - usage record

1 messages · Page 1 of 1 (latest)

gentle sedge
#

Hi there!

#

You cannot reverse a usage record, or create a negative one. Instead you can create a new usage record with action: set with the correct total value directly.

timid anchor
#

ah perfect. that makes sense! Thanks!

#

actually the set action seems to be incrementing instead of setting the usage value. I'm updating like: record = Stripe::SubscriptionItem.create_usage_record("si_MBsQaoVZ0uT5by", { quantity: 40, action: 'set', timestamp: Time.now.to_i })

#

the record ID is mbur_0LUUBS250JCmBXjUZkaoV5rg

#

and also the usage record summary also is not 40: irb(main):082:0> Stripe::SubscriptionItem.list_usage_record_summaries("si_MBsQaoVZ0uT5by", { limit: 1 }) => #<Stripe::ListObject:0xee278> JSON: { "object": "list", "data": [ {"id":"sis_0LUUDr250JCmBXjUheulLtHg","object":"usage_record_summary","invoice":null,"livemode":false,"period":{"end":null,"start":null},"subscription_item":"si_MBsQaoVZ0uT5by","total_usage":161} ], "has_more": false, "url": "/v1/subscription_items/si_MBsQaoVZ0uT5by/usage_record_summaries" }

gentle sedge
#

here is a recording of me also creating a usage record via the stripe dashboard with unexpected behavior
That looks odd. Investigating...

timid anchor
#

I tried it on a different subscription item that had never had usage reported before and set works as expected. I think maybe if increment has been used already on that subscription item, then using set doesn't work.

gentle sedge
#

Well I managed to reproduce, so that's a bug!

#

I'll open an investigation internally, and we will fix that soon.

gentle sedge
#

So it's not a bug.

timid anchor
#

ah got it. so sum ignores set and increment. which sort of makes sense, but that wasn't super clear when I read the documentation on aggregate_usage

gentle sedge
#

Agreed, I'll send that feedback to the team. Thanks!