#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/1288599248945811498
๐ 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_schedule-update, 2 hours ago, 21 messages
- sajid_api, 16 hours ago, 60 messages
- sajid_checkout-redirect, 5 days ago, 29 messages
- sajid_subscription-customprice, 6 days ago, 19 messages
Let say I have create the only one phase with 12 iterations monthly. but after two invoices. I want to add some more product for third invoice. can i do that?
Hi there! I would recommend starting with our guides that go into how to use Subscription Schedules:
https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases
https://docs.stripe.com/billing/subscriptions/subscription-schedules#updating
If you have specific questions about why what you are trying to do isn't working, we're happy to help!
like when i update the phase. it dont show me the phases i updated later in updateschedule api.
and show me same start date and end date of initial phase i retreive the schedule.
๐ taking over for my teammate
I really recommend testing this out yourself so you can familiarize yourself with how to update a phase and coming back with an example request and specific questions if you have any
can you plese check this request:
req_DlkYv9ZxofQmhE
What's unclear about the error message here? Can you share what your ultimate goal is with the Schedule update?
like when i have already added one phase with 12 iterations but after one iteration i want add new phase and start it form next iteration not after 12 iterations.
I think the issue here is that you didn't include the start_date / end_date of the current phase
I am doing it with iterations without using end date.
I'm looking at the last successful subscription schedule update request. Notice that you passed start/end values for the current phase: https://dashboard.stripe.com/test/logs/req_J04lHEM92SLOf2
These same start/end values were omitted in the request you shared: https://dashboard.stripe.com/test/logs/req_DlkYv9ZxofQmhE
const updatedSubscriptionSchedule = await stripe.subscriptionSchedules.update(scheduleId, {
end_behavior: 'release', // What happens when the schedule ends
phases: [
...currentSchedule.phases, // Keep existing phases
newPhase, // Add the new phase
],
});
when i am passing current phases with old phases. it give me error.
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."
WHERE AS I DONT WANT TO APPLY ANY COUPON OR ANYTHING. AND IT IS NULL IN PREVIOUS PHASES TOO.
Please pause and take a look at the two requests I linked above first
When you update a Schedule, you have to pass all current and future phases that you want to keep and any previously set parameters. In this case, the update call that failed did not included start_date and end_date in the first/current phase
I have compared i dont want to in certain way.
I don't understand what you mean
How can i get the date of next invoice? so if i want to include a phase from next iteration so i can provide correct start time.
Can you clarify what you mean?
Can you retrieve Schedule sub_sched_1Q2xxgF6Gkk6c638b9na1OlZ and be explicit about the changes you're trying to make to this specific Schedule?
I want to include extera item in next iteration. thats all i want to do
We'll need to be very clear with terminology to make sure we're on the same page. You wouldn't include an extra item on an iteration. Instead, you'd include an item on a phase
Yes.
So currently, if you retrieve sub_sched_1Q2xxgF6Gkk6c638b9na1OlZ, you see two phases, right? The first phase ends on August 31, 2025. The next phase starts immediately after that and continues for the next 12 months
hi there! ๐ taking over for my colleague
It has one phase and 12 iterations already. but lets say after two iterations I want to add an item for next iteration. how will i do that?
So in that case, you would add a second phase after the first, which has the same item as the first, and then another, second item.
The docs page that you will want to reference is here: https://docs.stripe.com/billing/subscriptions/subscription-schedules#updating
but first will complete its 12 iterations ?
then second start or immediatly.
I have gone through this documentation hundred times. but I dont know how I will specify times for both phases.
That depends on how you define the phases. In the example you shared, sub_sched_1Q2xxgF6Gkk6c638b9na1OlZ, you're using iterations, which is one way of defining how long the phase lasts. The documentation in the API reference gives a good example -
The other way would be to use end_date
I dont know in advance that i will change in future. but when I get i need to change particular upcoming iteration only. so i cannot set phases with start and end date in advance.
this is all i get in this documentation.
Can you share your code for creating a Subscription Schedule?
// Create the subscription schedule in Stripe
const subscriptionSchedule = await stripe.subscriptionSchedules.create({
customer : "cus_Qus7zvgJJCnmfh",
start_date: startDate, // Start date for the subscription
end_behavior: 'release', // What happens when the schedule ends (can also be 'cancel')
// test_clock: testClockId, // If you want to apply it at the subscription level
phases: [
{
items: items, // Recurring items (for the subscription)
add_invoice_items: invoiceItems, // One-time invoice items (added to the next invoice)
iterations , // Number of billing cycles for this phase
billing_cycle_anchor: 'automatic', // Automatically set the billing cycle anchor
// discounts: couponId ? [{ coupon: couponId }] : undefined, // Apply discount coupon if available
metadata: {
invoiceNo,
// Add any additional metadata here
},
collection_method: "charge_automatically",
// days_until_due: 10, // Calculate the number of days until due based on the provided due date string
},
],
});
Okay so what's the problem here? What is happening that you want to behave differently?
I am creating 12 iterations. but after 3 iterations i want to add one more item for fourth iteration.
Note: 3 iterations has passed and fouth is upcoming iteration.
what happens after the 4th iteration?
How can I add an extera item for the fourth iteration.
What happens after the 4th iteration though. This is really important and you haven't really explained it. I know it's likely clear in your head because you're deep into it but you haven't told us.
Is that extra item only for the 4th iteration and then it's back to normal? Is it for all the future iterations? Also is it a one-time Price or a recurring Price?
can be any of both one time or recurring.
so you got the idea clear now?
you answered only one of the 2 questions so not really. I'm sorry but to help you we need you to be crisp about your requirements.
Please explain in clear words who pays what when, all in one sentence.
Something such as
Customer pays $10/month for 3 months, then they pay $20/month for a month, then they are back to $10/month for 8 months
This is clear and something easy to explain to you once we understand what you are doing
Yes it is like that.
Cool so earlier you said "I have 12 iterations, but one is different"
But really you have three phases
- Phase 1: Customer pays $10/month for 3 months
- Phase 2: they pay $20/month for a month
- Phase 3: they are back to $10/month for 8 months
let me explain again. when I create a schedule I create one phase with $10 and 12 iterations. but after 3 iterations I have one more item to add for forth iteration. as i dont know in advance that i will need to edit in future.
can i add a phase at run time? or edit for specific iteration at run time.
You can use the Update SubscriptionSchedule API and modify its phases to change what you are trying to reflect yes
just give me an idea how i will do that.
how will i handle iterations for phase? will i add new phase ? if yes than how i will give end date for previous phase.
When you update the SubscriptionSchedule you pass all the phases you want. There isn't a "modify phase 5". You repass all the phases properly.
The problem is that you are quite lost and you also aren't testing. You need to pause and try this in Test mode carefully.
You have a SubscriptionSchedule, try to update it and change its phases
And to be clear, this is just... confusing. It's not your fault. It confuses me too every time, but if you go step by step and try you will understand it