I'd like to show a customer a preview (or a quote) of what their subscription charges will be if they make changes to their subscription. For this, I'm using the "upcoming invoice" API endpoint:
https://stripe.com/docs/api/invoices/upcoming
From that link, they state that "You can preview the effects of updating a subscription, including a preview of what proration will take place.".
When changing plans, you have to first fetch the current subscription item ID (https://stripe.com/docs/api/subscription_items), and specify "deleted" => true
. Then you add the new plan as a subscription_item
.
Here's an example call:
[
"subscription" => "sub_GUw5iYoBYiSAEl"
"subscription_items" => [
[
"id" => "si_GUw53rbtqOpZYB"
"deleted" => true
],
[
"plan" => "plan_GAf8EkL1VIPYZ9"
"quantity" => "1"
]
]
]
This works great when the user is not in their trial period.
However, if the user is in their trial period, this only works if the billing interval of the plan you are changing to is the same. E.g. if you are on a monthly plan, changing to another monthly plan works.
If you are in your trial period on a monthly plan, and you are changing to a yearly plan (or vice versa), then it shows the upcoming invoice as $0.00 due today.
This also happens via the Stripe Dashboard:
Is there a way to show the actual amount, not $0.00?