#hooky

1 messages ยท Page 1 of 1 (latest)

zinc pulsarBOT
hazy hare
#

The tier data would be on the price object itself I believe. Checking in to how to best retrieve this from there

faint ravine
#

(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)

hazy hare
#

Can you send me the ID of the price or plan that you are working with?

faint ravine
#

Sure. Bear in mind this is a Production (live) id from my customer's customer (I am a B2B service)...

#

plan_E1LvpfHjHlgn9O

hazy hare
#
faint ravine
#

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

hazy hare
faint ravine
#

Aaaahhh! And when fetching a customer, can I also expand the tiers somehow?

hazy hare
#

So try adding expand: ['tiers]' to the retrieve call

faint ravine
#

(e.g. instead of what I currently do, {expand: ['subscriptions'] })

hazy hare
#

You might but that depends on how many levels deep the tier information is

faint ravine
#

Yes, expanding tiers when retrieving the plan worked! โœ…

hazy hare
#

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

faint ravine
#

I guess I should try:

{expand: ['subscriptions', 'subscriptions.plan.tiers'] }

hazy hare
#

You can try but I think that won't work unfortunately

faint ravine
#

A similar one worked!

#
  const options = {
    expand: ['subscriptions', 'subscriptions.data.plan.tiers']
  }
hazy hare
#

Nice! What worked here?

faint ravine
#

(Without the "data" the error message was very helpful, it suggested I add "data")

hazy hare
#

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!

faint ravine
#

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?

hazy hare
#

Correct, the data will still just be null there