#kishoreklkr_api
1 messages · Page 1 of 1 (latest)
👋 Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1377506980608082050
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- kishoreklkr_api, 6 days ago, 49 messages
Hi there, catching up! Give me awhile
Your last sentence is incomplete " But this invoice is always quantity consumed is alway..." - could you share with me what you originally meant?
when I trigger a manual invoice in middle of billing cycle, the the "quantity" section is zero although i've consumed meter credits
this is expected
Just to set context, if you're trying to build a credit burndown subscription, this model can only be used with metered price : https://docs.stripe.com/billing/subscriptions/usage-based/pricing-models?dashboard-or-api=api#credit-burndown
i get this
Could you share with me the subscription ID you're looking at?
it should be prefixed with "sub_"
sub_1RTjbBFhxzALu9SNvBEJXYXu
according to the link you shared, should i manually add the billing credits count to the invoice if i'm generating a bill manually?
stripe invoiceitems create
--customer={{CUSTOMER_ID}}
--currency=usd
--unit-amount-decimal=10000000
from the UI I know when i try to add metered price as line-items to a invoice it doesn't let me add this price(price_1RQiSIFhxzALu9SNetHIsULL "0.02/unit")- hence doesn't add the quantity ie the amount of credits consumed via metered events.
Give me moment, i'm looking at your subscription's setup
ok
it looks like you reported usage to your event with this request (req_v2n8pF7CBZeP8VTtL), while specifying a timestamp 2025-06-03T04:06:12.000Z. At this exact timestamp, you also triggered the subscription to invoice now, as seen in this request (req_Ijx8oafmjb0KyD).
From what I can see, it looks like you are immediately invoicing a usage you just reported. I recommend adding some delay (~5 min) before issuing an invoice for the recently reported usage.
Also, you mentioned updating the price of the subscription. I did not see any price update for sub_1RTjbBFhxzALu9SNvBEJXYXu.
Is this the subscription we should look at for your original question?
i'm using the testClock to do it
yes, this is the metered subscription.
I can advance the time and trigger the invoice - would that work?... I had tried it yesterday with same test clock
i advanced the time to few hours ahead and triggered draft invoice from console
but lineItems are still empty.. the same issue i'm facing
"latest_revision":
null,
"lines": {
"object":
"list",
"data": [],
"has_more":
false,
"total_count":
0,
"url":
"/v1/invoices/in_1RTylRFhxzALu9SNjQX19LaT/lines",
"period_end":
1748955972
,
"period_start":
1748923572
,
I'm confused, are you still having issues with the original question?
I asked about the price change because you originally mentioned "I update the burnDown subscription from premium to advanced or vice versa in middle of the month, I want to trigger the invoice for metered subscription and clear the metered events & credit grants." - if the invoice is returning zero after a price change, this is expected behaviour.
When using a metered price, you can't update a subscription item’s price during a billing cycle and bill for the previous usage. Doing so will only reflect usage after the update. So the usage recorded before the update (e.g. on the premium plan) will not be considered: https://docs.stripe.com/billing/subscriptions/usage-based/manage-billing-setup#mid-cycle-updates
ok, the price change is not an issue., it is working just fine and it is for a different subscription,.
let me elaborate
- customer opens a portal to change price of sub_1RTjd6FhxzALu9SNgoGDy26u -
- on success in the "subscription.updated" event gets triggered
i process the webhook, if there is a price update i want to trigger invoice for sub_1RTjbBFhxzALu9SNvBEJXYXu which is giving zero quantity
these are two independent subscriptions.. only connected via webhook.. metered (sub_1RTjbBFhxzALu9SNvBEJXYXu)sub's pricing never changes but needs to be billed in case price change happens in sub_1RTjd6FhxzALu9SNgoGDy26u
I'm understanding as when the price changes on sub_1RTjbBFhxzALu9SNvBEJXYXu, the previous usage reported on sub_1RTjbBFhxzALu9SNvBEJXYXu should be billed on a different subscription, sub_1RTjd6FhxzALu9SNgoGDy26u?
This this is the scenario , it is not possible.
No
not like that
ignore the sub_1RTjd6FhxzALu9SNgoGDy26u subscription completely for now
sub_1RTjbBFhxzALu9SNvBEJXYXu has a metered price right..
i create subscription
i add credit grant
i add meter events
if i wait till billing date, new invoice will be created where aggregated meter events will be billing, credit grants will be consumed .. with me?
Yup
now, for some reason, in the middle of the billing cycle- i want to create a invoice- where aggregated meter events will be billing, credit grants will be consumed.. without changing the billing cycle
when i do that, my invoice has only zero quantity, although i've triggered meter events .. it also shows up correctly in my "upcoming invoice section"
can you share with me the specific invoice ID you're referring to?
let me create one right away
i'm using this command "stripe invoices create --customer=cus_SOWe4DavUbpbTK --subscription=sub_1RTjbBFhxzALu9SNvBEJXYXu"
in_1RTz4aFhxzALu9SNFJcqdAcg invoice id
here is the upcoming invoice which is correctly considering the aggregated values
upcoming_in_1RTz5OFhxzALu9SNuhWLCQYQ
Okay so you want to invoice the upcoming invoice with 3500 usage right now
yess..
once this manual invoice is paid successfully, my subscription should not consider the already billed 3500 usage when it does the billing-cycle calculation
Okay, this is not possible. A metered subscription cannot be invoice immediately. It will only be billed at the end of the billing cycle.
any work around for this?, this is needed because we revoke the credits on this invoice
So metered events cannot be present for the revoked grants in our case
The workaround here is to create a one-time invoice (not connected to the subscription) to bill for the recorded usage. You can use List billing meter event summaries [0] to know the usage that's been recorded.
[0] https://docs.stripe.com/api/billing/meter-event-summary/list
but would it clear the usage from "upcoming invoice" ?
if i create a one-time invoice with "unit_amount_decimal=3500 and price_data.price=price_1RQiSIFhxzALu9SNetHIsULL"
the upcoming invoice should show 0 consumed.. will that happen on its own?
i know listing meter,. but whats the process ( in api) to create such invoice?
No, creating the one-time invoice alone won't clear the usage in upcoming invoice. And to be clear, you can't create a one-time invoice using the same price ID you used on the subscription. This is because the price ID you used on the subscription is recurring. You need a one-time price for a one-time invoice.
There are two parts here — 1. Invoicing the already recorded usage, 2. Clearing the recorded and already invoiced usage (from Step 1)
For 1. Invoicing the already recorded usage — this means create the one-time invoice to charge for the usage appearing under "Upcoming Invoice". Example, 3500. Again, you need to create a one-time price here.
For 2. Clearing the existing usage on the subscription — let's assume your customer paid the invoice from Step 1, and you need to clear the usage of 3500. You can remove the usage by recording a negative value like -3500.
ok, if we forget the fact that somehow i creat the invoice for this recurring subscription,
When i create the invoice, can it consume the credit Grant?, can it create a credit transaction with it?