#manuSW
1 messages ยท Page 1 of 1 (latest)
What's the error
{ "error": { "message": "The subscription is managed by the subscription schedule sub_sched, and updating any cancelation behavior directly is not allowed. Please update the schedule instead.", "request_logurl": "https://dashboard.stripe.com/logs/req", "type": "invalid_request_error" } }```
Yep, you need to to release the subscription from the schedule first: https://stripe.com/docs/api/subscription_schedules/release
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, thansk!!!
but when i should releas the subscription from the schedule? when subscription.getSchedule() != null ??
Well you can't perform direct updates to a Subscription (like cancel it) when it's controlled by a schedule
but i can control that when stripe throws me the exception
So yes I guess you'd check to see if the schedule field is set on the Subscription: https://stripe.com/docs/api/subscriptions/object#subscription_object-schedule
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
If that field is set, then call the release endpoint and then cancel. Otherwise just cancel
super!
my code
Subscription subscription = Subscription.retrieve(stripeSubscriptionId);//--new codeif (subscription.getSchedule() !=null) { SubscriptionSchedule subscriptionSchedule = SubscriptionSchedule.retrieve( subscription.getSchedule() ); SubscriptionSchedule updatedSubscriptionSchedule = subscriptionSchedule.release();}SubscriptionUpdateParams params = SubscriptionUpdateParams.builder() .setCancelAtPeriodEnd(true) .build();subscription.update(params);
Did you try it?
np
i am new in the community
some rating points i can give you hehe or something similar?
Your kind words here are more than enough ๐
Thanks a lot!! and have a nice day!