#salonmonster_subscription-upcoming-invoice-total
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/1408203332438200371
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Here is what we see in the returned 'price' and 'plan' objects:
subscriptions price {
id: 'price_1RycjRGSFMA1QWpwPSFUUr9H',
object: 'price',
active: true,
billing_scheme: 'tiered',
created: 1755799021,
currency: 'cad',
custom_unit_amount: null,
livemode: true,
lookup_key: 'canadian_monthly',
metadata: {},
nickname: null,
product: 'prod_SuRcykLT6nZCPE',
recurring: {
aggregate_usage: null,
interval: 'month',
interval_count: 1,
meter: null,
trial_period_days: null,
usage_type: 'licensed'
},
tax_behavior: 'exclusive',
tiers_mode: 'volume',
transform_quantity: null,
type: 'recurring',
unit_amount: null,
unit_amount_decimal: null
}
subscriptions plan {
id: 'price_1RycjRGSFMA1QWpwPSFUUr9H',
object: 'plan',
active: true,
aggregate_usage: null,
amount: null,
amount_decimal: null,
billing_scheme: 'tiered',
created: 1755799021,
currency: 'cad',
interval: 'month',
interval_count: 1,
livemode: true,
metadata: {},
meter: null,
nickname: null,
product: 'prod_SuRcykLT6nZCPE',
tiers_mode: 'volume',
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
}
In both cases the amount is null
Do we need to:
- get the price id
- get the quantity
- then fetch the price from stripe api using expand
- then use the quantity to find the price tier and do the math ourselves?
Before we used the tiered option we received the amount values back
So we used that for our system
But now that we're on tiered we're not sure how to efficiently retrieve the subscription value for the customer
It seems very inefficient to have to query the price and then calculate the amount based on that
Hi Palamedes, thanks for your help
You only get unit_amount if billing_scheme is per_unit, not if it is tiered:
https://docs.stripe.com/api/prices/object#price_object-unit_amount
I think this is what you should be looking at:
https://docs.stripe.com/api/prices/object#price_object-tiers
You can try expanding price.tiers when you retrieve the Subscription and see if you can or not
Ok, so it will not give us the amount in subscription.
Instead we have to:
- fetch the subscription
- find the price id + quantity
- fetch the price for that id with expand
- then in the tier for that price id locate the price for the quantity.
or can we pass expand to the subscription list endpoint?
data.price can't be expanded on the list endpoint according to my testing
ok, very strange - we wanted to make sure we match exactly what stripe is charging for that subscription, eg taking into tiers + discount, etc.
But it seems that we have to manually calculate all of that, which introduces the potential for errors between our calculation and what Stripe charges the end user
if we retrieve a single subscription item instead of listing, does that give it?
So Subscription items do contain price info, but it is a list of items that Stripe will charge for on the Subscription, whereas it seems to me you're looking for actual calculations that will be charged or have been charged for a particular period, in which case you should likely be looking at the Invoice instead of the Subscription
Tested - single subscription item also does not include amount
I want to show a customer what they will be charged per line item on their next subscription billing
Not past
Sure, you can look at the upcoming Invoice
ok, thanks
or create a preview Invoice:
I'll take a look at that
this page isn't found: https://docs.stripe.com/api/invoices/upcoming
It may be because it doesn't exist on your default API version if you're logged in to the Stripe docs site
It should redirect you if that is the case; I've asked to have that fixed
thanks