#mathankumar-plan
1 messages Β· Page 1 of 1 (latest)
I mean subscription plan!
You mean updating the Subscription billing cycle? I am asking because plan is a term used for Plan API vs Price API which is slightly different
No, not updating the subscription plan, its upgrading (changing plan)!
Yes then the old setup will be discarded. You can easily confirm it by the Upcoming Invoice API
discarded ?? Okay, that current will be expired?
I meant the previous setup. Not sure if I am following. Could you give a detail example? What subscription id, what change do you make? And what's the expectation?
for example, I subscribed to one plan and I need to change to another plan so In this scenerio, do I need to cancel that previous subscription plan or expire that current_period_end date from my product?
So, just upgrading would work. Stripe will calculate the proration if any
You can find detail here: https://stripe.com/docs/api/subscriptions/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
It's okay but I used usage-based billing with a flat_amount?
So it will be proration between old-new usage-based plan.
Hmm I am not sure what would be the result. Can you try in test mode?
No how can try this scenario from my product for example do I send proration_behavior with my next plan?
You simply simulate your use case, no? Create Sub with usage-based + flat fee, then advance the time into middle of billing cycle, then make the change, then observe the result
If you wish to not do proration at all, you can pass proration_behavior = none and forget all the headache
I am stepping down but my colleague @idle gazelle will take over!
π Taking over from Orakaro, catching up now
Can you share the request ID req_xxx that you update the subscription? Hereβs how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Request ID => req_oflae5GghGjiOy
From this request, you created a new subscription instead of updating one
Updating a current subscription should use Subscription Update API: https://stripe.com/docs/api/subscriptions/update
okay, but I need to change my subscription what I do in this scenario?
Here's the doc to upgrade or downgrade the subscription: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
You'll need to use \Stripe\Subscription::update(...) with the new price ID on the existing LineItem ID, and update proration_behavior accordingly
yes, it's working, that previous plan invoice will create?
it should if there's any unpaid balance
i did not understand from doc for using this code 'id' => $subscription->items->data[0]->id in subscription update, i need good explanation ?
Stripe supports multiple items (each item contains a price) in a subscription. When you update a subscription, this 'id' => $subscription->items->data[0]->id indicates which Item ID that you would like to update
okay I understood.
when a subscription is auto-renowned which contents will be changed like current_period_start,current_period_end?? and also I need to update this change to my database how can I do that?
When you update a plan, it will still be the same billing cycle and only the field you update will change
but in auto renowned?
if the customer renewed or auto-renowed what are the column changes happening (like current_period_start, current_period_end) ? and also i need to change that update in my product DB?
So you have a subscription, and you want to know which properties of the subscription will change when it is renewed?
yes that's my question,which properties i need change my local db?
The three main changes are current_period_end, current_period_start, and latest_invoice.
which properties i need change my local db?
That's completely up to you.
okay I use the "customer.subscription.update" webhook to update my local DB? how do I know it's renowned from the webhook data(its shows a general update object)?
When you receive the customer.subscription.update, you can check the status of the subscription to know if it's active, past_due, canceled, unpaid, etc.
You can learn more about this here: https://stripe.com/docs/billing/subscriptions/overview#subscription-statuses
yes good, but how can I confirm that's renowned from the update webhook (customer.subscription.update)?. is there any key to check that?
What do you mean by "renvewed"? That the customer paid, or that a new billing cycle started?
i mean "subscription renowned " that a new billing cycle started
Then you can check that any of these fields changed: current_period_end, current_period_start, and latest_invoice.
okay, that's good. if I need to change my plan i just use this code \Stripe\Subscription::update(...) but customer upgrade the plan in the Customer portal its also the same process in stripe?
okay, that's good. if I need to change my plan i just use this code \Stripe\Subscription::update(...)
Yes
but customer upgrade the plan in the Customer portal its also the same process in stripe?
what do you mean by "same process"?
what do you mean by "same process"?
updating in previous subscription and item id!
π taking over for my colleague. Let me catch up.
Okay I am tired your fourth π bro
okay, that's good. if I need to change my plan i just use this code \Stripe\Subscription::update(...) but customer upgrade the plan in the Customer portal its also the same process in stripe?
that's the good thing about discord, you get to meet all the team π
Yes its funπ
but customer upgrade the plan in the Customer portal its also the same process in stripe?
should be. but could you be more precise the question is a bit vague
when customer upgrade their subscription in the customer portal what will happen is that same API process (like... "\Stripe\Subscription::update(...)" )?
yes under the hood it is updating the subscription
Can I get these changes from webhook (customer.subscription.update) with the change of subscription ID?
yes
Okay great ! thanks
let me know if you need any more help
Not now bro...
one question !
when update subscription, can i check this keys "current_period_end, current_period_start" in "previous_attributes" => ??
Okay i am waiting..
yes they are present in the case where there's a new cycle
either through upgrade or normal cycle iteration
okay, that's great... I can easily check that to know the action
OKay bro, i will
sorry but I have to ask you to refrain from using gender-specific and familiar language such as bro it's not really appropriate for this channel