#frannavarro - tiered pricing
1 messages · Page 1 of 1 (latest)
Do you see in the plan there? Is it populated at all?
Have you tried looking at the subscription items array instead?
yes, and nothing. Amount null
{
id: 'XXXXX',
object: 'subscription',
application_fee_percent: null,
automatic_tax: { enabled: false },
billing_cycle_anchor: 1645112524,
billing_thresholds: null,
cancel_at: null,
cancel_at_period_end: false,
canceled_at: null,
collection_method: 'charge_automatically',
created: 1645112524,
current_period_end: 1676648524,
current_period_start: 1645112524,
customer: 'XXXX',
days_until_due: null,
default_payment_method: 'XXXX',
default_source: null,
default_tax_rates: [],
discount: null,
ended_at: null,
items: {
object: 'list',
data: [ [Object] ],
has_more: false,
total_count: 1,
url: '/v1/subscription_items?subscription=XXXX'
},
latest_invoice: 'XXX',
livemode: false,
metadata: {},
next_pending_invoice_item_invoice: null,
pause_collection: null,
payment_settings: { payment_method_options: null, payment_method_types: null },
pending_invoice_item_interval: null,
pending_setup_intent: null,
pending_update: null,
plan: {
id: 'XXX',
object: 'plan',
active: true,
aggregate_usage: null,
amount: null,
amount_decimal: null,
billing_scheme: 'tiered',
created: 1642789512,
currency: 'usd',
interval: 'year',
interval_count: 1,
livemode: false,
metadata: {},
nickname: null,
product: 'prod_L0SimO4rCh5Qm1',
tiers_mode: 'graduated',
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
},
quantity: 6,
schedule: null,
start_date: 1645112524,
status: 'active',
transfer_data: null,
trial_end: null,
trial_start: null
}
I was trying not to put compromising information, I'm sending it to you now.
But, that seems normal right, is its dependent on the quantity, there is no fixed amount
All IDs are safe to share, no body can do anything with them
okey
just never share your API secret keys
{
id: 'sub_1KUC7MKpwWr0NBhXuUZX5TrF',
object: 'subscription',
application_fee_percent: null,
automatic_tax: { enabled: false },
billing_cycle_anchor: 1645112524,
billing_thresholds: null,
cancel_at: null,
cancel_at_period_end: false,
canceled_at: null,
collection_method: 'charge_automatically',
created: 1645112524,
current_period_end: 1676648524,
current_period_start: 1645112524,
customer: 'cus_LAWZAerWM2BbWH',
days_until_due: null,
default_payment_method: 'pm_1KUBWRKpwWr0NBhXprxuVzN5',
default_source: null,
default_tax_rates: [],
discount: null,
ended_at: null,
items: {
object: 'list',
data: [ [Object] ],
has_more: false,
total_count: 1,
url: '/v1/subscription_items?subscription=sub_1KUC7MKpwWr0NBhXuUZX5TrF'
},
latest_invoice: 'in_1KUC8qKpwWr0NBhXBhybE7An',
livemode: false,
metadata: {},
next_pending_invoice_item_invoice: null,
pause_collection: null,
payment_settings: { payment_method_options: null, payment_method_types: null },
pending_invoice_item_interval: null,
pending_setup_intent: null,
pending_update: null,
plan: {
id: 'price_1KKRnQKpwWr0NBhXZNXEsRkF',
object: 'plan',
active: true,
aggregate_usage: null,
amount: null,
amount_decimal: null,
billing_scheme: 'tiered',
created: 1642789512,
currency: 'usd',
interval: 'year',
interval_count: 1,
livemode: false,
metadata: {},
nickname: null,
product: 'prod_L0SimO4rCh5Qm1',
tiers_mode: 'graduated',
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
},
quantity: 6,
schedule: null,
start_date: 1645112524,
status: 'active',
transfer_data: null,
trial_end: null,
trial_start: null
}
Alternately you can use expansion to get the tiers of the Price
It's also suggest looking in the items instead of the plan attribute to handle the case of multiple items on a subscription
something like this?: this.stripe.subscriptions.retrieve(stripeSubscriptionId, { expand: [] }) ?
Yep!
(with that array populated with the path to the expansion target)
eg: expand: ['items.data.price.tiers']
yes!
sorry, didn´t work
items: { object: 'list', data: [ [Object] ], has_more: false, total_count: 1, url: '/v1/subscription_items?subscription=sub_1KUC7MKpwWr0NBhXuUZX5TrF' },
there are not expanding
That looks like console.log truncation of nested objects
if you console.log(subscription.items.data[0].price) i would expect you to see the tiers attribute for a tiered price
i´m gonna try!
you were right, but it still doesn't work for me 😦
I need to know the total amount to be charged to the user
OK, but that depends on the quantity, right?
To preview the amount to be charged, I'd suggest using the Upcoming Invoice endpoint to get the calculate invoice amounts for that subscription:
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I'm going to check it out, thank you very much
NP