#pascal_lin - subscription
1 messages · Page 1 of 1 (latest)
Hi there!
Indeed in this case you should either update the subscription schedule directly, or remove the subscription from it's schedule before updating the cancel_at_period_end.
Is it any other field of subscription could not be updated while having subscription schedule...?😔
There are a lot of fields you can update on the subscription when it's managed on a schedule, but not all of them. I don't know the exact list, that's something that you would need to test.
what about upgrade subscription while following:https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment
params := &stripe.SubscriptionParams{
CancelAtPeriodEnd: stripe.Bool(false),
ProrationBehavior: stripe.String(string(stripe.SubscriptionSchedulePhaseProrationBehaviorAlwaysInvoice)), // set always_invoice to charge invoice
Items: []*stripe.SubscriptionItemsParams{
{
ID: stripe.String(sb.Items.Data[0].ID),
Price: stripe.String(priceId),
},
},
}
updated, err := subscription.Update(id, params)
if err != nil {
return err
}
I think upgrading a subscription managed by a schedule is possible. But again I would recommend to test your exact use case in test mode to see if it actually works.
My situation is that I just want to downgrade subscription in next period, and I got an answer from stripe team to using subscription schedule. But it looks like I have to change all my update subscription interaction if I create a subscription schedule....
😔
My situation is that I just want to downgrade subscription in next period
If you want to apply changes to a subscription in the future, then yes you need to use subscription schedule
But it looks like I have to change all my update subscription interaction if I create a subscription schedule....
The error you shared earlier is aboutcancel_at_period_end, and I gave you two options to solve it. If you see any other specific errors, please let me know so we can see how to solve them.
okay, fair enough, thanks for helping🙏
Happy to help 🙂
what if I cancel the scheduler before I update subscription?🤔
If you cancel the scheduler, the subscription is canceled too
so once I create a schedule from subscription, I should always update subscription schedule insead of update subscription?
But if you want to release the scheduler without canceling the subscription itself, you need to call release endpoint on the schedule:
https://stripe.com/docs/api/subscription_schedules/release
okay, I will try release action in my test, it looks much better
I am worry about release action does not happen immediately so that I still could not update subscription, but it worth to try😂
The release action does happen immediately:
https://stripe.com/docs/api/subscription_schedules/release#:~:text=Releases the subscription schedule immediately
one more question, if I release a subscription schedule, but I need to set up a schedule again, should I update the schedule that I get from subscription or create a schedule from subscription again...?
You should create a new subscription schedule using this api:
https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-from_subscription
@summer cloud thanks a lot, it works fine in my test code using release action👏
Great, glade to hear that!