#sajid_api

1 messages ยท Page 1 of 1 (latest)

atomic summitBOT
#

๐Ÿ‘‹ 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.

tropic tideBOT
carmine creek
#

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?

gaunt shell
#

If you have specific questions about why what you are trying to do isn't working, we're happy to help!

atomic summitBOT
carmine creek
#

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.

onyx acorn
#

๐Ÿ‘‹ 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

atomic summitBOT
carmine creek
#

can you plese check this request:
req_DlkYv9ZxofQmhE

onyx acorn
#

What's unclear about the error message here? Can you share what your ultimate goal is with the Schedule update?

carmine creek
#

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.

onyx acorn
#

I think the issue here is that you didn't include the start_date / end_date of the current phase

carmine creek
#

I am doing it with iterations without using end date.

onyx acorn
carmine creek
#

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.

onyx acorn
#

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

carmine creek
#

I have compared i dont want to in certain way.

onyx acorn
#

I don't understand what you mean

carmine creek
#

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.

onyx acorn
#

Can you clarify what you mean?

atomic summitBOT
onyx acorn
#

Can you retrieve Schedule sub_sched_1Q2xxgF6Gkk6c638b9na1OlZ and be explicit about the changes you're trying to make to this specific Schedule?

carmine creek
#

I want to include extera item in next iteration. thats all i want to do

onyx acorn
#

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

carmine creek
#

Yes.

onyx acorn
#

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

carmine creek
#

sub_sched_1Q337cF6Gkk6c638p7cuKA6P

#

consider for this schedule.

gaunt shell
#

hi there! ๐Ÿ‘‹ taking over for my colleague

carmine creek
#

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?

gaunt shell
#

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.

carmine creek
#

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.

gaunt shell
#

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

carmine creek
#

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.

gaunt shell
#

Can you share your code for creating a Subscription Schedule?

carmine creek
#

// 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

    },

  ],

  

});
timid heron
#

Okay so what's the problem here? What is happening that you want to behave differently?

carmine creek
#

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.

timid heron
#

what happens after the 4th iteration?

carmine creek
#

How can I add an extera item for the fourth iteration.

timid heron
#

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?

carmine creek
#

can be any of both one time or recurring.

carmine creek
timid heron
#

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

carmine creek
#

Yes it is like that.

timid heron
#

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
carmine creek
#

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.

timid heron
#

You can use the Update SubscriptionSchedule API and modify its phases to change what you are trying to reflect yes

carmine creek
#

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.

timid heron
#

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