#.buddhaha
1 messages ยท Page 1 of 1 (latest)
Hello .buddhaha, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
โข .buddhaha, 0 days ago, 17 messages
Hi ๐ do you have more specifics about your requirements and which ones of those you're having trouble matching to our flows/object structures?
For instance you mentioned:
Yearly and monthly billing cycles
Stripe supports yearly and monthly billing cycles with Subscriptions, but you can't have a single Subscription with multiple billing cycles within it. Like you can't have one Subscription that charges a customer both monthly and yearly, you can only have one.
Yes, I understand that, it's fine.
What I'm stuck on right now is displaying the prorationed price before the customer proceeds to update the subscription. For some reason the price was much higher than what I expect it to be, like as if previous upgrades had not been paid and there was an outstanding amount to be paid.
Also, the invoice generated looks a bit confusing when you update the quantity of a subscription item.
Can you provide more specifics, do you have an example Invoice you were looking at the proration calculations for that didn't align with your expectations? If so, can you share the ID of that Invoice so I can take a closer look?
What number should i be looking at on the invoice preview? Right now I use this:
invoice.lines.data.forEach((line) => {
if (line.proration) {
prorationAmount += Number(line.unit_amount_excluding_tax);
}
});
}```
Absolutely, but please help me determine which parameters on the invoice object I should be looking at. invoice.subtotal looks promising, but in Sweden we display prices excluding tax for businesses, and that number includes tax.
What are you trying to show your customer? I'll need to understand that in order to know what fields to suggest you look at.
Yes, sorry, the proratio price for the remainder of the year when trying to add "Extra seats" to the subscription. See (it's accurate in that one, but after a few upgrades earlier it stopped being accurate):
Now, after adding first 1 extra seat, and then an additional 2, it looks like this:
as you can see it says "0 kr" (kr is the sek currency sign), and the invoice object says:
subtotal: 652198,
which is also a bit weird. It looks like some kind of accumulation of previous upgrades
There's a whole lot I don't have context on there. I don't readily recognize that UI, is it a UI that you built? If so, how is it getting the data it's using? Is it throwing any errors when it's surfacing that zero amount? If that subtotal isn't what you were expecting, what were you expecting? Can you share the full output of the preview Invoice request that you made (since the output of GET requests aren't logged)?
Yes, its a UI I have built, because AFAIK Stripe does not support multiplan in the customer portal/checkout session.
How we get data:
const upcomingInvoice = await stripe.invoices.retrieveUpcoming({
customer: customerId,
subscription: subscriptionId,
subscription_items: [
{
id: subscriptionItemId,
price: priceId,
quantity: currentQuantity + 1,
},
],
subscription_proration_date: Math.floor(Date.now() / 1000), // the exact timestamp of the change
subscription_proration_behavior: "always_invoice",
});```
I expect to get the proratio of increasing the quantity by 1, which should always equal the price of 1 more quantity (since the previously should've been paid for)
Can't send the full invoice objects lol ๐
Still need it?
Yup, I still don't have specifics to see exactly what is going on here. So far the only feedback I have is that the prorations shouldn't equal the full price amount if you're making these changes in the middle of a billing period.
Yes, that's true. And accounted for! I'll send the object in batches
object: 'invoice',
account_country: 'SE',
account_name: 'Palats',
account_tax_ids: null,
amount_due: 815238,
amount_paid: 0,
amount_remaining: 815238,
amount_shipping: 0,
application: null,
application_fee_amount: null,
attempt_count: 0,
attempted: false,
automatic_tax: { enabled: true, status: 'complete' },
billing_reason: 'upcoming',
charge: null,
collection_method: 'charge_automatically',
created: 1698157482,
currency: 'sek',
custom_fields: null,
customer: 'cus_OsWJeUKBsmLR3f',
customer_address: {
city: null,
country: 'SE',
line1: null,
line2: null,
postal_code: null,
state: null
},````
customer_name: 'Felix',
customer_phone: null,
customer_shipping: null,
customer_tax_exempt: 'none',
customer_tax_ids: [],
default_payment_method: null,
default_source: null,
default_tax_rates: [],
description: null,
discount: null,
discounts: [],
due_date: null,
effective_at: null,
ending_balance: 0,
footer: null,
from_invoice: null,
last_finalization_error: null,
latest_revision: null,
lines: {
object: 'list',
data: [ [Object], [Object] ],
has_more: false,
total_count: 2,
url: '/v1/invoices/upcoming/lines?subscription=sub_1O4lKNKD1uSVDE8HIETjiqci&subscription_proration_date=1698157481&subscription_proration_behavior=always_invoice&subscription_items%5B0%5D%5Bquantity%5D=4&subscription_items%5B0%5D%5Bid%5D=si_OsWT5CIByIenoJ&subscription_items%5B0%5D%5Bprice%5D=price_1O4kFFKD1uSVDE8Hs1SdTSjt&customer=cus_OsWJeUKBsmLR3f'
},````
metadata: {},
next_payment_attempt: null,
number: null,
on_behalf_of: null,
paid: false,
paid_out_of_band: false,
payment_intent: null,
payment_settings: {
default_mandate: null,
payment_method_options: null,
payment_method_types: null
},
period_end: 1698157482,
period_start: 1698156687,
post_payment_credit_notes_amount: 0,
pre_payment_credit_notes_amount: 0,
quote: null,
receipt_number: null,
rendering: { amount_tax_display: 'exclude_tax', pdf: null },
rendering_options: { amount_tax_display: 'exclude_tax' },
shipping_cost: null,
shipping_details: null,
starting_balance: 0,
statement_descriptor: null,
status: 'draft',
status_transitions: {
finalized_at: null,
marked_uncollectible_at: null,
paid_at: null,
voided_at: null
},
subscription: 'sub_1O4lKNKD1uSVDE8HIETjiqci',
subscription_details: { metadata: {} },
subscription_proration_date: 1698157481,
subtotal: 652190,
subtotal_excluding_tax: 652190,
tax: 163048,
test_clock: null,
total: 815238,
total_discount_amounts: [],
total_excluding_tax: 652190,
total_tax_amounts: [
{
amount: 163048,
inclusive: false,
tax_rate: 'txr_1NOIZfKD1uSVDE8HwuNQlmTc',
taxability_reason: 'standard_rated',
taxable_amount: 652190
}
],
transfer_data: null,
webhooks_delivered_at: null
}````
Want to see lines too?
If you have concerns with the information in that section
It's where I'm fetching the info from ๐ but the math seems to check out right now
not sure what happened
or actually, no
its still too much
{
id: 'il_tmp_106dd2KD1uSVDE8Hcb4d10f6',
object: 'line_item',
amount: -1956538,
amount_excluding_tax: -1956538,
currency: 'sek',
description: 'Unused time on 3 ร Extra seats - new after 24 Oct 2023',
discount_amounts: [],
discountable: false,
discounts: [],
invoice_item: 'ii_1O4lfIKD1uSVDE8HvRNKStMk',
livemode: false,
metadata: {},
period: { end: 1727042400, start: 1698157984 },
plan: {
id: 'price_1O4kFFKD1uSVDE8Hs1SdTSjt',
object: 'plan',
active: true,
aggregate_usage: null,
amount: 714000,
amount_decimal: '714000',
billing_scheme: 'per_unit',
created: 1698152525,
currency: 'sek',
interval: 'year',
interval_count: 1,
livemode: false,
metadata: {},
nickname: null,
product: 'prod_OoIiHa2fBtGF05',
tiers_mode: null,
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
},````
id: 'price_1O4kFFKD1uSVDE8Hs1SdTSjt',
object: 'price',
active: true,
billing_scheme: 'per_unit',
created: 1698152525,
currency: 'sek',
custom_unit_amount: null,
livemode: false,
lookup_key: null,
metadata: {},
nickname: null,
product: 'prod_OoIiHa2fBtGF05',
recurring: [Object],
tax_behavior: 'exclusive',
tiers_mode: null,
transform_quantity: null,
type: 'recurring',
unit_amount: 714000,
unit_amount_decimal: '714000'
},
proration: true,
proration_details: { credited_items: [Object] },
quantity: 3,
subscription: 'sub_1O4lKNKD1uSVDE8HIETjiqci',
subscription_item: 'si_OsWT5CIByIenoJ',
tax_amounts: [ [Object] ],
tax_rates: [],
type: 'invoiceitem',
unit_amount_excluding_tax: '-652179'
},````
id: 'il_tmp_177c35KD1uSVDE8Hbe356804',
object: 'line_item',
amount: 2608717,
amount_excluding_tax: 2608717,
currency: 'sek',
description: 'Remaining time on 4 ร Extra seats - new after 24 Oct 2023',
discount_amounts: [],
discountable: false,
discounts: [],
invoice_item: 'ii_1O4lfIKD1uSVDE8HoSoZSWPk',
livemode: false,
metadata: {},
period: { end: 1727042400, start: 1698157984 },
plan: {
id: 'price_1O4kFFKD1uSVDE8Hs1SdTSjt',
object: 'plan',
active: true,
aggregate_usage: null,
amount: 714000,
amount_decimal: '714000',
billing_scheme: 'per_unit',
created: 1698152525,
currency: 'sek',
interval: 'year',
interval_count: 1,
livemode: false,
metadata: {},
nickname: null,
product: 'prod_OoIiHa2fBtGF05',
tiers_mode: null,
transform_usage: null,
trial_period_days: null,
usage_type: 'licensed'
},
price: {
id: 'price_1O4kFFKD1uSVDE8Hs1SdTSjt',
object: 'price',
active: true,
billing_scheme: 'per_unit',
created: 1698152525,
currency: 'sek',
custom_unit_amount: null,
livemode: false,
lookup_key: null,
metadata: {},
nickname: null,
product: 'prod_OoIiHa2fBtGF05',
recurring: [Object],
tax_behavior: 'exclusive',
tiers_mode: null,
transform_quantity: null,
type: 'recurring',
unit_amount: 714000,
unit_amount_decimal: '714000'
},
proration: true,
proration_details: { credited_items: null },
quantity: 4,
subscription: 'sub_1O4lKNKD1uSVDE8HIETjiqci',
subscription_item: 'si_OsWT5CIByIenoJ',
tax_amounts: [ [Object] ],
tax_rates: [],
type: 'invoiceitem',
unit_amount_excluding_tax: '652179'
}
]````
actually it does look correct now
is there some kind of pending time or something which could make this be offset for a while?
I don't know what that could mean
haha, i'm sorry
Haha, no worries, just trying to make sure we're aligned so I can answer correctly.
I deleted the subscription that I thought was faulty, and now it seems to work
Do you think the approach makes sense though, overall?
Where the approach is to use the Upcoming Invoice endpoint to get a preview of what the next Invoice amount for a Subscription will be after you make changes to it? Yup, that's a good, and our recommended, approach for previewing proration calculations.
Okay, great. And what about doing way with multiplan subscriptions to cover the use case of a main tier and addons?
Adding multiple Prices to a single Subscription is fine.
Not sure if that's what you meant by multiplan. If it doesn't sound like I'm grasping what you're describing, can you elaborate on your use case?
Haha yeah. So we have like a main subscription, a Team plan or Free plan. And then if that is not sufficient, you can add an addon such as Extra users that you pay a bit extra for. Say Team plan is $100/month and 1 extra user is $10/month
Yup, if they have the same billing frequency, then you can add multiple Prices to a single Subscription, and adjust the amounts for them independently. That sounds like it would be a good fit here.
Okay, happy to hear. I guess there's not much to do than to get back if I run into the problem again, since I cant seem to reproduce it ๐ข
Sounds like it, if you're able to reproduce that behavior we can definitely help look into that and either try to explain how the system is behaving or flag with the appropriate team if it's a bug.
I doubt its a bug, more likely my ignorance. Thanks so much for your help!