#Ravg
1 messages ยท Page 1 of 1 (latest)
Hi there!
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Why do you need a subscription schedule if you only have one phase? You could directly update the subscription itself.
I need to replace some subscription items for about 1000 subscriptions, but the changes should happen only tomorrow at midnight, not immediately. So I'm trying to schedule it
(The "start_date"="now" was just a test)
Got it! The issue in your request is this part: start_date: "now". You need to set the start_date to the existing start date of the subscription (which is not "now")
You can find it by retrieving the existing subscription schedule and using the current phases[0].start_date
Okay, thanks for the information. I will change that part.
And where can I set that the changes should be applied in the future (tomorrow at midnight)? I thought it was in the first phase's start_date of the Subscription Schedule
The very first phase is the current phase of the subscription. If you want to make a change in the future, then you will need a second phase for that (and use the appropriate start_date)
Oh I didn't know I had to use a second phase, that's what I missed then.
My doubt now is about what attributes I need to set for the first phase...
In that case, should I set an end_date to the first phase with all the current items, and then on the second phase I set the start_date and the new items?
Hey! Taking over for my colleague. Let me catch up.
All right! Thank you ๐
In that case, should I set an end_date to the first phase with all the current items, and then on the second phase I set the start_date and the new items?
Are you talking about update the subscription_schedule ? if so, yes you need to set the end_date of the first phase of the currently items, and add your next phase(s) with new items
Okay. So basically this is what I understood and will try to do to schedule changes to subscription items:
- create new subscription schedule
- update the subscription schedule and set:
2.1 first phase (current one): add subscription's original start date to "start_date," the current items, and set "end_date" to tomorrow at midnight
2.2 second phase (new): set the new items and "start_date" to tomorrow at midnight
Anything I might have missed? ๐ค
- you mean creating the subscription_schedule from an existing subscriptionId? if so, yes that's how you can do
I tried that and now I'm getting the error "Request req_SBXnpPQIflOlRU: You can not modify the start date of the current phase".
If I don't set the start_date on the first phase then I get error "Request req_mZXRbzq8ridBMe: The subscription schedule update is missing at least one phase with a start_date to anchor end dates to even tho there is a start_date in the second phase (the new one).
I'm doing like this:
subscription_schedule = stripe.SubscriptionSchedule.create(
from_subscription=current_subscription["subscription_id"]
)
stripe.SubscriptionSchedule.modify(
subscription_schedule["id"],
phases=[
{
"proration_behavior": "none",
"start_date": current_subscription["start_date"],
"end_date": 1664582400, # tomorrow
"items": current_subscription["items"],
},
{
"proration_behavior": "none",
"start_date": 1664582400, # tomorrow
"items": items,
},
],
)
Any clue what could be the issue?
Actually, the firs phase need to have the same start_date of the current active phase of the subscription,
You can get the subscription_schedule https://stripe.com/docs/api/subscription_schedules/retrieve in order to use the exact current start_date and use it with the first phase while doing the update
ohhh I see! I changed that part and it worked!
Thanks a lot!!
Glad to hear that you managed to solve your issue ๐ Don't hesitate to come back if you have any followup Questions I can help with!