#naveed-web3auth_code
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/1389457286740578334
๐ 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.
- naveed-web3auth_sub-schedule-release, 18 hours ago, 46 messages
- naveed-web3auth_best-practices, 20 hours ago, 45 messages
โ๏ธ Stripe developers have stepped away for a short while
Please leave your questions here, and weโll respond as soon as we're back! If you need help urgently, you can contact Stripe support for help.
Here is the code for constructing the phase items based on existing phase data
func constructSubscriptionSchedulePhaseParams(phases []*stripe.SubscriptionSchedulePhase) []*stripe.SubscriptionSchedulePhaseParams {
var subscriptionSchedulePhaseParams []*stripe.SubscriptionSchedulePhaseParams
for _, phase := range phases {
phaseItems := []*stripe.SubscriptionSchedulePhaseItemParams{}
for _, item := range phase.Items {
phaseItems = append(phaseItems, &stripe.SubscriptionSchedulePhaseItemParams{
Price: stripe.String(item.Price.ID),
})
}
subscriptionSchedulePhaseParams = append(subscriptionSchedulePhaseParams, &stripe.SubscriptionSchedulePhaseParams{
Items: phaseItems,
StartDate: stripe.Int64(phase.StartDate),
EndDate: stripe.Int64(phase.EndDate),
})
}
return subscriptionSchedulePhaseParams
}
hi there ๐ I just want to acknowledge the question I'm working on some other threads but will get to you as soon as I can!
hi @bitter kelp i will need some time to look into this, could you also share with me the subscrption ID you're scheduling phases on?
this is a newly created subscription that i just reproduced the case on
so u can have a look at the events tied to it that were triggered
basically i want to know if this is expected behaviour or not and whether or not it is based on the date falling on the exact billing cycle
so that if it is a few hours away stripe defaults to taking the next cycle instead
thanks, I'll take a look!
@bitter kelp could you point to me exactly where "the date shows up as the next month instead of the upcoming billing cycle"?
ok let me release the schedule and try invoking downgrade again
i wouldve wanted 1st july to be the date on which the downgrade occurs
basically 5 hours or so away
billing cycle is 10am UTC
or i could just accept the fact that people simply should expect downgrades to work that way if they are doing it right on the billing cycle day
Hmm...I'm sorry let's use this price for example: price_1MVp76ImFOsfVEtUJfQhEyjW (Web3Auth Growth)
If I'm understanding correctly, Web3Auth Growth is getting added to the subscription on 1 Aug (per your screenshot)
But you're expecting it to be added on 1 Jul
yeah
basically immediately in the coming billing cycle
as mentioned which is only a few hours away
So I'm looking at your subscription schedule update call: https://dashboard.stripe.com/test/logs/req_WhwsfIif2uPZ4j
- you are currently passing in three phases
- price_1MVp76ImFOsfVEtUJfQhEyjW (Web3Auth Growth) is being passed in the third phase.
- the previous phase end on 1754042400, which is why price_1MVp76ImFOsfVEtUJfQhEyjW is only kicking in on 1 Aug, the third phase
You're passing price_1P3E3hImFOsfVEtUvTdx8w0q and price_1MVp7pImFOsfVEtUbRemxXyt twice. Given Phase 0 is the current phase, Phase 2 appears to be the update you want to make. Is Phase 1 expected?
hmm let me try releasing the schedule again, but basically the way things are is that prior to this i have
newSchedule, err := subschedule.New(&stripe.SubscriptionScheduleParams{
FromSubscription: stripe.String(subscriptionStripeID),
})
I create a new schedule based off of the subscription
yes
actually i also have some logic to detect if there is an existing subscription schedule already
if there is then no need to create
I construct the phases array by using the existing subschedule.phases and appending the new downgrade phase at the end
so i dont put too much thought into the part where i am constructing phases from existing
func constructSubscriptionSchedulePhaseParams(phases []*stripe.SubscriptionSchedulePhase) []*stripe.SubscriptionSchedulePhaseParams {
var subscriptionSchedulePhaseParams []*stripe.SubscriptionSchedulePhaseParams
for _, phase := range phases {
phaseItems := []*stripe.SubscriptionSchedulePhaseItemParams{}
for _, item := range phase.Items {
phaseItems = append(phaseItems, &stripe.SubscriptionSchedulePhaseItemParams{
Price: stripe.String(item.Price.ID),
})
}
subscriptionSchedulePhaseParams = append(subscriptionSchedulePhaseParams, &stripe.SubscriptionSchedulePhaseParams{
Items: phaseItems,
StartDate: stripe.Int64(phase.StartDate),
EndDate: stripe.Int64(phase.EndDate),
})
}
return subscriptionSchedulePhaseParams
}
phases := constructSubscriptionSchedulePhaseParams(stripeSchedule.Phases)
https://dashboard.stripe.com/test/logs/req_mlr2xWaAF8pmDW i released and tried again
its indeed weird that there are 3 phases tbh
the first 2 seem to be the same thing which is scale
if u look at the subscription schedule created call that precedes it we see that it also has 2 phases from the get go hmm https://dashboard.stripe.com/test/workbench/logs/req_4Q8Nvt0hQ9T1AN
Maybe i should rethink how im updating subscription schedule and not do it in this manner
I think the issue is with the appending โ when you append the "new changes" you're essentially creating a new phase
i think what you want to do is update the exsting phase on the schedule
if you want the change to kick in on the phase that already exist
interestingly i modified the code to be this
phases := []*stripe.SubscriptionSchedulePhaseParams{
{
Items: currentPhaseItems,
},
{
Items: subscriptionSchedulePhaseDowngradeItems,
},
}
updatedStripeSchedule, err := subschedule.Update(stripeSchedule.ID, &stripe.SubscriptionScheduleParams{
Phases: phases,
})
And still shows up as 3 phases
anyways at least that helps me to simplify my code more
but u can see i now am updating with only current phase + future phase
is this the new schedule created: sub_sched_1RfwiPImFOsfVEtULbmb6taD?
yep
thats weird it still shows that i submitted with 3 phases
anyways perhaps stripe sdk is doing that behind the scenes
Could you try retrieving the existing phases on the subscription schedule, and then update the latest phase? What I meant is you don't create a new phase