#mad - metered billing
1 messages ยท Page 1 of 1 (latest)
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
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
the invoice show 0$ for the usage during trial, that's ok,
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
it's not expected to have that usage (done during trial) kept when the subscription is no more in trial
Where are you seeing this usage, exactly, that you don't expect?
i query it from Stripe Api with something like "subscription_items/#{id}/usage_record_summaries"
OK can you share a specific request and the data you get back from that?
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)
Alright, and after you end the trial?
%{
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 ๐
Well, what period did you request for?
There is an entry per billing period, that's expected
i did not specify a period
and the closed period looks like the trial with usage
and your new paid billing period currently has zero usage
ok so "subscription_items/#{id}/usage_record_summaries" needs some period filter during the request ?
Ah looks like you can only filter using the pagination from the previous records you've seen
https://stripe.com/docs/api/usage_records/subscription_item_summary_list?lang=php#usage_record_summary_all-ending_before
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Otherwise using limit=1 would get you just the current one