#apostolis_best-practices
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/1414516663247835147
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi! Looking in your query!
I believe you should be able to use the credit balance summary for this: https://docs.stripe.com/api/billing/credit-balance-summary/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
From my tests the balance is only updated after an invoice is issued.
Hmm, I have subscribed the user to the product as well
So my understanding is that the grant would only be applied once the invoice is issued.
I assume the alternative is to issue invoices on demand, if that would help
👋 taking over for my colleague. Let me catch up.
In future, this will also take into account any usage that hasn’t yet been invoiced for a customer.
From https://docs.stripe.com/api/billing/credit-balance-summary/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
you can actually retrieve the billing credit grants per customer https://docs.stripe.com/api/billing/credit-grant/list#list_billing_credit_grants-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
this would give you the credit grant ID
How do I get its remaining balance next?
then you would retrieve the credit balance summary for a customer and filter by credit grant https://docs.stripe.com/api/billing/credit-balance-summary/retrieve#retrieve_billing_credit_balance_summary-filter-type
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That would only give back the amount after an invoice is issued
See my comment above:
In future, this will also take into account any usage that hasn’t yet been invoiced for a customer.
until we add this, what you can do is to create a preview of the next invoice, and reduce the amount from the available_balance
you must only take the invoice items that refer to that meter of course
I'll take a look thanks
let me know if you need any more help
Is there a way to know which grant is used in the preview invoice? E.g. I created 2 grants and I can see in the preview invoice:
"pretax_credit_amounts": [
{
"amount": 24830,
"credit_balance_transaction": null,
"type": "credit_balance_transaction"
},
{
"amount": 3000,
"credit_balance_transaction": null,
"type": "credit_balance_transaction"
}
],
Is there any way to know which grant each entry is for?
I don't think you could by directly looking at the invoice itself
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!