#sajid_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1288930134283391006
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- sajid_api, 1 hour ago, 26 messages
- sajid_api, 17 hours ago, 68 messages
- sajid_schedule-update, 1 day ago, 21 messages
- sajid_api, 1 day ago, 60 messages
- sajid_checkout-redirect, 6 days ago, 29 messages
I am encountering an issue when attempting to update subscription schedules in my application. Specifically, when I try to update the first phase (phase[0]), I receive an error indicating that some attributes are empty strings. This occurs for attributes that I did not set during the initial creation of the phase.
Additionally, when I attempt to set these attributes while updating, I receive a different error stating that I cannot update a phase that has already ended.
Could you please clarify the following for me?
Handling Empty Attributes: How should I manage attributes that were not set during the creation of a phase? Is there a way to bypass the empty string error without having to set all attributes?
Updating Ended Phases: What are the specific limitations regarding updating phases that have already ended? Is there a way to modify attributes for these phases, or should I handle this differently?
Your assistance in resolving these questions would be greatly appreciated. Thank you for your help!
You provided an account ID, not a request ID. Can you provide a request ID?
How are you creating Subscription Schedules in the first place?
It is not recommended to directly update the first phase of a subscription schedule. The point of subscription schedules is to allow you to schedule the changes for a later time.
req_u22BBQQnT0u4EP
When I do not update first phase it gives empty string errors for attributes those I did not set while creating the schedule.
I pass the phases. that why it gives empty string erros.
Subscription Scheudles update in kind of a weird way. If you pass the phases parameter it will completely overwrite, not add to, the existing data
Can you provide a request that shows these errors?
The request you provided is successful
Yes sure.
This is how I am creting the schedule.
That is an update request though. The schedule already exists
A creation request would use just this URL /v1/subscription_schedules without the ID
req_iIE68T9vUC6gog
I am passing same phases I get from retreive schedule. along with my new phase.
Can you share how you are doing that in your NodeJS code?
Here is the request that created this schedule: https://dashboard.stripe.com/test/logs/req_k9sPpxGPjHvvbc
You can see that, for the first phase, you specified collection_method: "charge_automatically",
You need to pass all these values again (not empty strings) when you attempt to add a second phase
Let me try it.
Hmmm.. it looks like you unset these values in this request: https://dashboard.stripe.com/test/logs/req_DSYgt4E2VuhRtA
This is because they were not included
Here is how I handling it.
When I try to set it says the phases that are expired can not be edited.
In which request?
It looks like this schedule is using a test clock
Yes they are using.
The frozen time for that clock is 2024-10-26 but the phase you are trying to edit ends on 2024-09-30. So that is why you are getting this error
Our docs recommend how you can update the phases of a Subscription here: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#changing-subscriptions
I recommend you review this approach to make sure you are setting all the necessary values in your code
I have currently two phases. I dont want to edit previous phase that ended that date you mentioned. I pass the first as it as it get in retreive schedule response. then it gives error of empty string for some attributes I mentioned earlier.
I have gone through docs but I did'nt get solution for me. I tried everything. Please help me to make it work.
I think you will need to start fresh with a new Subscription Schedule. There have been many confusing changes made to this current one.
In your NodeJS code, copy the entire Phases array to a variable and add the new phase you want to make to the end of it. Then pass the whole array back in the update API request.
Can I make changes in last phase in array like changing items or add_invoice_items?
Please dont close thred I am trying it now.
Hi there ๐ jumping in as my teammate needs to step away. Yes, you can make adjustments to the last phase that you provide in the phases array, but you will need to provide all phases that are currenlty in the phases array when making that update.
So if you have a Subscription Schedule with two phases after the current one, and want to only update the last one, you still need to include all three phases in the phases array in the update request.
Okay I am trying these both options. Please dont close the thread or go away.
It needs end date for previous phase. How can I edit that?
When I am adding new phase.
Pass the end_date parameter inside of your phases.
https://docs.stripe.com/api/subscription_schedules/update#update_subscription_schedule-phases-end_date
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I create schedule just now and I did't gave it coupon while creating. but when I tried to update it gave me error:
"You passed an empty string for 'phases[0][coupon]'. We assume empty values are an attempt to unset a parameter; however 'phases[0][coupon]' cannot be unset. You should remove 'phases[0][coupon]' from your request or supply a non-empty value."
Can you share the ID of that request?
req_m8gK3RyRnoDJou
const updatedPhases = currentSchedule.phases;
updatedPhases.push({
start_date: unixNextIterationStartDate, // Set new phase start date
items: items, // New items for the next phase
add_invoice_items: invoiceItems, // New one-time invoice items
iterations: 3, // Number of billing cycles for the new phase
billing_cycle_anchor: 'automatic', // Automatically set the billing cycle anchor
collection_method: 'charge_automatically', // Collection method for the new phase
metadata: {
reason: 'Added new phase starting from next iteration'
}
});
// Now update the subscription schedule with updated phases
const updatedSubscriptionSchedule = await stripe.subscriptionSchedules.update(scheduleId, {
end_behavior: 'release', // What happens when the schedule ends
phases: updatedPhases // Pass the updated phases directly
});
Your request included the phases.coupon parameter for the first phase, and passed an empty string for that parameter. You should remove that from your request.
I never included it while creation.
Unfortunately passing in the entire existing phase isn't a great approach, because that object will include empty fields.
You included it in this line it seems:
const updatedPhases = currentSchedule.phases;
by including the entire existing phase.
When I filter it says you can not edit phases that are already ended. Read the conversation in start of this thread.
The phase isn't ended, or it wouldn't be in the phases array anymore.
You mean if phases ended it will not be in phases array anymore?
Yup
Oh but it was there. was it due to test clock?
Can you elaborate?
I see two phases on that Subscription Schedule, where the first one ends on Sep 30, 2024. The test clock's time is frozen at Sep 26, 2024.
So the first phase in the phases array is the current phase, and then there is one more phase after that. When the Subscription Schedule moves to that next phase, the phases array should drop to only contain the remaining phase.
Ok I got your point. I have one more doubt. If I dont give end date for previous phase would that both run parallel?
That'll fail, because the system won't know when you want the phase to end and won't know how to order the phases you provide in the array. That should lead to the error you mentioned previously about an end_date not being provided. It's not possible to have phases run in parallel, they must be sequential.
@weary aspen did that do the trick?
still same issues i am working on them. pleas keep thread open.
Do you want to tell me what you're seeing now, do you still need help with that? I'm not inclinde to leave the thread open if there isn't an active discussion going. You're welcome to test on your own and open a new thread to discuss any questions that arise from that testing.
updatedPhases[updatedPhases.length - 1].end_date = unixNextIterationStartDate;
updatedPhases[updatedPhases.length - 1].iterations = null;
When I add end date for current phase. to start the next I set iterations to null. is it correct way to do it? it still say you can only give either end date or iterations.
Can you share the request ID throwing that error? You would omit the iterations parameter entirely if you're using start and end dates to control the length of your phases.
req_HTC8NkV1LYLnfB
onst updatedPhases = currentSchedule.phases.map(phase => {
return {
start_date: phase.start_date,
items: phase.items || [], // Use existing items or an empty array if undefined
add_invoice_items: phase.add_invoice_items || [], // Use existing add_invoice_items or an empty array
proration_behavior: phase.proration_behavior || 'create_prorations', // Default to 'create_prorations' if undefined
billing_cycle_anchor: phase.billing_cycle_anchor || 'automatic', // Default to 'automatic' if not specified
metadata: {
invoiceNo: phase.metadata.invoiceNo || invoiceNo, // Use existing invoiceNo or the new one
// Map any other metadata fields as needed
},
collection_method: phase.collection_method || "charge_automatically", // Default if not specified
};
});
I already remvoed iteration parameter .
You can also view these requests in your Stripe dashboard and see exaclty what we're receiving from your calls to our API.
https://dashboard.stripe.com/test/logs/req_HTC8NkV1LYLnfB
It's the same thing as before with coupon it looks like. You're passing iterations with an empty string, rather than avoiding passing it.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
But I removed the coupon in same way you see updatedPhases. but why its not working with iterations then.
I'm not sure, it doesn't look like you shared your full code, and I don't see anything in the code you shared that looks like it's filtering out any iterations fields.
is there any unique error code for this:
message: 'Each phase must be at minimum 1 second long. Phase 1 has the same start_date and end_date of 1727722800.',
so when this comes up. I should add items to existing phase without creating other one.
Hello! I'm taking over and catching up...
I don't think there's a unique error code for that, no. You can perform a check on your end to compare the start and end timestamps being used, though.
updatedPhases[updatedPhases.length - 1].iterations = remainingIterations || 5;
can I update iterations like this. when I updating the same phase.
still it expire after one month.
I don't know, I don't have enough context. I don't know what updatedPhases is. I don't know what .length is on it. I don't know what remainingIterations is. I recommend you try it in test mode and see if it works the way you expect.
req_PJXlPZTIJjkis8
can you check this request ID does it got proper iteratoin numbers.
That's a GET request to retrieve the Subscription Schedule. We don't log responses to GET requests, so I can't see what data you got back. Did you get the numbers you expected back?
let me figuer it out the exact problem.