#hash_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/1410300776714338387
đ 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.
- hash_api, 1 day ago, 55 messages
Looks like you didn't pass the start_date at the top level.
{
end_behavior: "release",
phases: {
0: {
items: {
0: {
price: "price_1RsYVbF8BVnhmF8JrbPZazMF",
quantity: "1",
},
},
iterations: "1",
proration_behavior: "create_prorations",
},
1: {
items: {
0: {
price: "price_1RsYVbF8BVnhmF8JrbPZazMF",
quantity: "1",
},
},
proration_behavior: "none",
},
},
}
I believe it should be like this:
{
start_date: <enter_date_here>
end_behavior: "release",
phases: {
0: {
items: {
0: {
price: "price_1RsYVbF8BVnhmF8JrbPZazMF",
quantity: "1",
},
},
iterations: "1",
proration_behavior: "create_prorations",
},
1: {
items: {
0: {
price: "price_1RsYVbF8BVnhmF8JrbPZazMF",
quantity: "1",
},
},
proration_behavior: "none",
},
},
}
As I said the ai on the doc was saying not to pass date with iteration so it is taken care of automatically
Wait I'll show you. Because I need to create schedule for what I want to achieve as I was told
I recommend testing the example I provided.
what date i put? i'm having a subscription already
scheduleParams := &stripe.SubscriptionScheduleParams{
Phases: phases,
EndBehavior: stripe.String(string(stripe.SubscriptionScheduleEndBehaviorRelease)),
}
_, err := subscriptionschedule.Update(schedule.ID, scheduleParams)
return &tempItems, err
}
// if there was no schedule we create a new one
scheduleParams := &stripe.SubscriptionScheduleParams{
FromSubscription: stripe.String(subscription.ID),
}
newSchedule, err := subscriptionschedule.New(scheduleParams)
if err != nil {
return nil, err
}
// Step 2: Now update the schedule with the phases
_, err = subscriptionschedule.Update(newSchedule.ID, &stripe.SubscriptionScheduleParams{
Phases: phases,
EndBehavior: stripe.String(string(stripe.SubscriptionScheduleEndBehaviorRelease)),
})```
the goal is to update the subscription for the end of the month
all the dates are already managed by the stripe subscription. I also had problem because i couldn't update the schedule from subscriptiopn with a phase directly
if existingItems.TotalPrice-currentMonthAmount > 300 {
prorationBehavior = stripe.String("always_invoice")
}
var phases []*stripe.SubscriptionSchedulePhaseParams
if hasNextPhase {
phases = []*stripe.SubscriptionSchedulePhaseParams{
{
Items: currentPhaseItems,
ProrationBehavior: prorationBehavior,
Iterations: stripe.Int64(1),
},
{
Items: nextPhaseItems,
ProrationBehavior: stripe.String("none"),
},
}
} else {
phases = []*stripe.SubscriptionSchedulePhaseParams{
{
Items: currentPhaseItems,
ProrationBehavior: prorationBehavior,
},
}
}```
this is the part where i'm just adding two phase or one phase depending if the user delete some subscription element
the goal is that for everything added the current subscription get immediatly updated until the end of the months and if the user delete something the element is only removed for next month
https://docs.stripe.com/api/subscription_schedules/update and if you read your doc it seems the start date is not a top level item...
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You shared the docs for updating subscription schedules not creating one.
you see my code? you can't create phases with a subscription, i got error from the api
I think we need to take a step back here.
i have to update after i create the schedule
i've been taking a lot of step back since i started implementing this xD
but basically. I have a few item for subscription.
When the user add an item it gets paid for the rest of the month with proration
when the user remove an item, it stays active until the end of the subscription and gets deleted the next month
stripe is my source of truth, i was told the only way to delete later is to use the subscription schedule
Hi, taking over as my teammate needs to step away. Let me catch up.
hello
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
i'm trying this but i'm not sure
phases[0].StartDate = &schedule.Phases[0].StartDate
scheduleParams := &stripe.SubscriptionScheduleParams{
Phases: phases,
EndBehavior: stripe.String(string(stripe.SubscriptionScheduleEndBehaviorRelease)),
}
_, err := subscriptionschedule.Update(schedule.ID, scheduleParams)
return &tempItems, err
}
// if there was no schedule we create a new one
scheduleParams := &stripe.SubscriptionScheduleParams{
FromSubscription: stripe.String(subscription.ID),
}
newSchedule, err := subscriptionschedule.New(scheduleParams)
if err != nil {
return nil, err
}
// Step 2: Now update the schedule with the phases
phases[0].StartDate = &newSchedule.Phases[0].StartDate
_, err = subscriptionschedule.Update(newSchedule.ID, &stripe.SubscriptionScheduleParams{
Phases: phases,
EndBehavior: stripe.String(string(stripe.SubscriptionScheduleEndBehaviorRelease)),
})```
Let's ignore what AI it telling you.
We document how you can properly make that call here: https://docs.stripe.com/billing/subscriptions/subscription-schedules?lang=node#changing-subscriptions
Can you follow this guide above?
but in the documentation it was also said not to use the date and let it be done automatically with the iteration
tho i do read now iteration is deprecated as well
but then from what i understand in that part of the doc i should instead put the duration on the second phase actually?
You want to add it on the first phase
Where in the document are you referring to here?
i want the first phase to have the prorated amount added with the new items. And then the next phase when the first month of the subscription ends to have the new phase item being applied to it
and it was in the subscription schedule
but right now from what i read with the doc you gave me before which isn't really aligned with what that assistant says. the iteration is actually to set date for how the phase itself will last?
if i have one phase with a start and end date does that mean that after the end date the subscription won't have the items carried out to the next cycle?
it was there "stripe recommand the usage of iteration to avoid setting start_date and end_date manually
but my question is if i make a schedule update with one phase and put a start and end date to it. Will the next month still happen with the updated objects of that phase?
Yes, the items passed on the second phase would be shown.
This gets complex really quick, and it's better if you use Test Clock, https://docs.stripe.com/billing/testing/test-clocks to advance time in test mode to see the expected behavior end to end.
yeah there are a lot of different response too. Sometime that ai part was getting correct part of the doc but sometime it does weird thing and some part of the subscription plan is using deprecated element too