#mad - metered billing

1 messages ยท Page 1 of 1 (latest)

tropic crescent
#

Hmm what do you mean by not reset? What's happen or not happening like you expect it to?

#

Usage during a trial period is not expected to be invoiced, only usage you report in the paid billing period that follows

undone pewter
# tropic crescent Hmm what do you mean by not reset? What's happen or not happening like you expec...

to make it simple, my product generates documents, those generations are what i mean by usage.
during trial each time i generate a document it's reported and programmatically limited to a certain limit during that trial period.
when i update the subscription using "trial_end" => "now" the subscription generates an invoice and it's technically a new cycle, but that usage calculation from trial is kept

#

i'm expecting that usage calculation to be reset at that upgrade moment

undone pewter
tropic crescent
#

So what part is not expected, then?

#

I would expect the usage amount to be shown but invoiced as $0 at the end of a trial

undone pewter
#

it's not expected to have that usage (done during trial) kept when the subscription is no more in trial

tropic crescent
#

Where are you seeing this usage, exactly, that you don't expect?

undone pewter
#

i query it from Stripe Api with something like "subscription_items/#{id}/usage_record_summaries"

tropic crescent
#

OK can you share a specific request and the data you get back from that?

undone pewter
#

ok, i'm simulating a trial subscription with usage that will upgrade to a full subscription

#
%{
   data: [
     %{
       id: "sis_1KP7eyBVFeaV0FZKSqBGg5QT",
       invoice: nil,
       livemode: false,
       object: "usage_record_summary",
       period: %{end: nil, start: nil},
       subscription_item: "si_L5I4rNPUXSBZ7W",
       total_usage: 4
     }
   ],
   has_more: false,
   object: "list",
   url: "/v1/subscription_items/si_L5I4rNPUXSBZ7W/usage_record_summaries"
 }
``` here's the state during trial
#

total : 4 (for example)

tropic crescent
#

Alright, and after you end the trial?

undone pewter
#
 %{
   data: [
     %{
       id: "sis_1KP7i0BVFeaV0FZK6GLPJkJs",
       invoice: nil,
       livemode: false,
       object: "usage_record_summary",
       period: %{end: nil, start: 1643903214},
       subscription_item: "si_L5I4rNPUXSBZ7W",
       total_usage: 0
     },
     %{
       id: "sis_1KP7hoBVFeaV0FZKrmO9tPNv",
       invoice: "in_1KP7hnBVFeaV0FZKiNWzw36b",
       livemode: false,
       object: "usage_record_summary",
       period: %{end: 1643903214, start: 1643903114},
       subscription_item: "si_L5I4rNPUXSBZ7W",
       total_usage: 4
     }
   ],
   has_more: false,
   object: "list",
   url: "/v1/subscription_items/si_L5I4rNPUXSBZ7W/usage_record_summaries"
 }
#

weirdly now there are two entries ๐Ÿ˜„

tropic crescent
#

Well, what period did you request for?

#

There is an entry per billing period, that's expected

undone pewter
#

i did not specify a period

tropic crescent
#

and the closed period looks like the trial with usage

#

and your new paid billing period currently has zero usage

undone pewter
#

ok so "subscription_items/#{id}/usage_record_summaries" needs some period filter during the request ?

tropic crescent
#

Otherwise using limit=1 would get you just the current one

undone pewter
#

that limit=1 seems perfect to get the current one,

#

thank you @tropic crescent for making it clean ๐Ÿ˜‰

#

*clear

tropic crescent
#

NP!

#

happy to help