#alexelba
1 messages ยท Page 1 of 1 (latest)
Hello! 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.
response from GET ->
Hm, still digging
Are you sure that's the right response for request req_ROYUZLsbvjGjm5?
yup ๐ฆ $totalUpcomingInvoice = \Stripe\Invoice::upcoming([
'customer' => $accountPaymentProvider->vendor_id,
'subscription' => $accountMembership->vendor_subscription_id,
'subscription_items' => $new_phases,
'subscription_proration_behavior' => 'none'
]);
var_dump($totalUpcomingInvoice);
basically call and dump
the same items, if I do 'subscription_proration_behavior' => 'create_prorations' it will change it and do calculations correctly
Interesting, okay.
should I do proration none or always_invoice if I want to get full amount
I thought none will do it, but maybe I should switch to always_invoice?
homm nope that did not work
if I do always_invoice, it should prorated value
instead of full
Before we dig into prorations and what the value should be here, let me make sure I understand what you're trying to do
540x50=27000
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Given an existing subscription that currently has a single line item (for a quantity of 100 at a price of 168) , you want to update that item to a quantity of 50 at a price of 540.
yup
Do you want to create prorations for any unused time on the old and new price?
nope, I want to show them what will be there next full invoice amount
this why trying to use upcoming invoice end point
Thank you for upgrading your full amount will be $X dollars starting N days
Prorated charge(s) for the remaining 363 days in your billing cycle.
You're changing to Enterprise. We'll charge you $10121.48 now, which is prorated for the current billing period. Starting on November 15, 2024 and until you cancel, we'll bill you once a year and your new yearly total will be $10121.48. If you cancel, previous charges won't be refunded unless it's legally required. We'll charge your credit card.
new yearly total is wrong
$10121.48. when I try to do always_invoice
and it 8400 when I do none
should I switch the line_item id
I'm looking into why the upcoming invoice response you receivd still has the old price ID (price_1OCZQuHxrjf17jEDtQ9QRsxd)
and why if I turn proration on it works
I am gonna run this two calls one with proration one without
$new_phases = array_map(function ($item) use ($membership_plan, $stripePrice, $payment_seat_count) {
'price' => $item->price->product == $membership_plan->membership_plan_id ? $stripePrice->id : $item->price->id ,
'quantity' => $item->price->product == $membership_plan->membership_plan_id ? $membership_plan->license_count : $item->quantity
];
}, $stripe_subscription->items->data);
$upcomingInvoice = \Stripe\Invoice::upcoming([
'customer' => $accountPaymentProvider->vendor_id,
'subscription' => $accountMembership->vendor_subscription_id,
'subscription_items' => $new_phases,
'subscription_proration_behavior' => 'create_prorations'
]);
vvar_dump($upcomingInvoice);
$totalUpcomingInvoice = \Stripe\Invoice::upcoming([
'customer' => $accountPaymentProvider->vendor_id,
'subscription' => $accountMembership->vendor_subscription_id,
'subscription_items' => $new_phases,
'subscription_proration_behavior' => 'always_invoice'
]);
vvar_dump($totalUpcomingInvoice);
only difference between this two calls is proration
first dump ->
2nd dump ->
this will be ''none"=>
Okay, I follow that you passed create_prorations for the first call so you should see two line items: a credit for the remaining time on $168 and a charge for the remaining time on $540
For the second call, there's also unused time for both the old and new price
1st call makes sense
2nd and 3 does not
basacally I want to show user how much will they be charged next time if they change to 50 and 540
what do you think will be best way to do so
The third call is what's stumping me
I am probably doing something wrong, but not sure
I try looping and adding line item amounts, but they are not correct either
Give me a few minutes please!
I'm trying to reproduce on my end but I'm able to retrieve an upcoming invoice with the correct new price, new quantity, without prorations
@fringe wasp Can you quickly try to
- Fetch the upcoming Invoice
- Update the Subscription for real
- Fetch the upcoming Invoice again
I want to see if at #3 you get the right Price id
ok let me do it one need to add logic for update ๐ it not implemented yet . brb in 15 minutes
Like your current code is logging the upcoming Invoice multiple times and I worry you're maybe mixing up the responses
dumps are right after the call, so should not be, I wander is it because there is subscription_schedule
attached to subscription
it makes it show wrong value
so scenario I am testing now, is this client had 100 subscription and they change seat count to 50, which is scheduled end of the term
before end of the term they come in and upgrade their account from 50 basic to 50 enterprise
ah yeah so upcoming Invoice works a bit differently with a schedule
how should I do it show the client what will be their next total bill
sorry I think we didn't realize you had a Schedule that completely changed the logic. I'm not even sure you can do this today. We're looking but will take a while
I mean I can do manually get the price and qunaitty and do math without using stripe
๐
but I am not sure if stripe will charge that amount or wrong one
๐ I'm hopping in to take a look as well - give me a minute to catch up
summary Subscription $168 -> 100, Schedule create to change to ->50 in the end of the billing period, before next billing period client comes upgrades this 50 from 168 to 540 per month. I want to get next full amount 27000
yeah sorry please pause for a sec
$168 -> 50 seats
Write a clear summary all in one message with exact dates and transition + price amount + price id and dates of the change so that we understand the full timeline
- November 2023 Subscription created: $168 yearly -> 100 seats Next Billing Period Feb 12, 2024
- November 2023 Subscription schedule created to update after Feb 12, 2024 $168 yearly -> 50 seats
- November 2023 Subscription updated is going to happen and upcoming invoice requested without proration: $540 yearly -> 50 seats (27000)
why is the next period Feb 12 if it's a yearly Price?
Okay so as far as I can tell, what you're doing is previewing the Subscription's next Invoice which would be when the second Phase starts right? Whatever you pass in subscription_items is irrelevant because you're doing no proration at all and you'd be modifying the current phase. And the Invoice we simulate is next year's Nov 15 2024 - Nov 15 2025 which is still on the Price A price_1OCZQuHxrjf17jEDtQ9QRsxd
I am trying to modify items -> $totalUpcomingInvoice = \Stripe\Invoice::upcoming([
'customer' => $accountPaymentProvider->vendor_id,
'subscription' => $accountMembership->vendor_subscription_id,
'subscription_items' => $new_phases,
'subscription_proration_behavior' => 'none'
]);
that switch would be only on the current phase though.
what are my correct steps, if I want it work?
Right now we're still unclear what you are asking unfortunately
I just want to get next total bill client will be charged if they upgrade now
My understanding is this
You have a Subscription that has 2 phases
Phase 1: Nov 15 2023 - Nov 15 2024 on Price A and quantity X
Phase 2: Nov 15 2024 - Nov 15 2025 on Price A and quantity Y
Now on Nov 16 you decide to switch their current phase to Price B and quantity Z. This only applies to the current phase Nov 15 2023 - Nov 15 2024
You are disabling proration entirely so really they would be on Price B with quantity Z moving forward without paying anything
Then at that point you're saying "show me the next Invoice" which would be on Nov 15 2024 (next year). At that point the second phase come into play and switches the customer to Price A and quantity Y
Your change isn't "propagating to future Phases" because the whole point of the SubscriptionSchedule API is to plan future sequential changes to the Subscription
So when you get "price A back" it's totally normal and not a bug
how can I pass subscription schedule to upcoming without applying it
impossible ๐
only way I see is doing math manually on my side
The Schedules API is quite complex and we unfortunately do not support the ability to pass all the phases today
My advice when debugging things like this: always use different Price ids and quantities for each parts so that it's easy to see what happens in the response
I was testing use case where quantity stays the same after downgrade ๐ but plan gets upgraded
need to talk with product person maybe there is something we can do
yeah I get that but when stuck it's best to temporarily try with completely different values so taht you can more easily reverse-engineer the situation
like when is upgrade really upgrade
yeah
Also random but function stripeDump($obj, $extraString = "") { echo "$extraString<br><pre>\n" . json_encode($obj, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES) . "\n</pre><br>"; }
I use this to pretty print Stripe objects in PHP
you can do stripeDump($invoice, "My upcoming Invoice"); and it pretty prints for you better than var-dump
thanks
for function
does stripe have any definition of upgrade , I can send to my product person
I don't really get what that question could mean unfortunately
We have https://stripe.com/docs/billing/subscriptions/upgrade-downgrade maybe that will be enough