#hooky
1 messages ยท Page 1 of 1 (latest)
The tier data would be on the price object itself I believe. Checking in to how to best retrieve this from there
(Maybe there's some distinction between plans and prices that I'm missing? I tested stripe.plans.retrieve and I also get no tiers info)
Can you send me the ID of the price or plan that you are working with?
Sure. Bear in mind this is a Production (live) id from my customer's customer (I am a B2B service)...
plan_E1LvpfHjHlgn9O
It looks like both prices and plans have tier info
https://stripe.com/docs/api/prices/object#price_object-tiers
https://stripe.com/docs/api/plans/object#plan_object-tiers
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Running this test code in node...
const ACCOUNT = {stripeAccount: org.stripeAccountId};
const plan = "plan_E1LvpfHjHlgn9O";
console.log('Retrieving...');
result = await stripe.plans.retrieve(plan, ACCOUNT);
Gets me this output:
{
id: 'plan_E1LvpfHjHlgn9O',
object: 'plan',
active: true,
aggregate_usage: null,
amount: null,
amount_decimal: null,
billing_scheme: 'tiered',
created: 1542897100,
currency: 'usd',
interval: 'month',
interval_count: 1,
livemode: true,
metadata: {
description: 'Everything you need to start customization capture experiences',
title: 'Plus'
},
nickname: 'Monthly',
product: 'prod_E1LuA5RkpOciv0',
tiers_mode: 'graduated',
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
}
It's strange, isn't it? no tiers details
Looks like that info isn't included unless you specify the tiers field to be expanded
To include it in the response, expand the tiers field.
https://stripe.com/docs/api/plans/object#plan_object-tiers
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Aaaahhh! And when fetching a customer, can I also expand the tiers somehow?
So try adding expand: ['tiers]' to the retrieve call
(e.g. instead of what I currently do, {expand: ['subscriptions'] })
You might but that depends on how many levels deep the tier information is
Yes, expanding tiers when retrieving the plan worked! โ
Nice! So we can check if this will work from the customer call, if not, you will likely have to make another call to get this info
I guess I should try:
{expand: ['subscriptions', 'subscriptions.plan.tiers'] }
You can try but I think that won't work unfortunately
A similar one worked!
const options = {
expand: ['subscriptions', 'subscriptions.data.plan.tiers']
}
Nice! What worked here?
(Without the "data" the error message was very helpful, it suggested I add "data")
Ah there we go, I actually thought you needed an items.data thrown in there somewhere which would have pushed this past four levels
Happy to hear that this works!
Awesome! Thanks a lot for your assistance! ๐
Oh, a quick thing:
I suppose if I run that code with a customer that has no tiered plans, no problems will occur, right?
Correct, the data will still just be null there