#mckeemi_api

1 messages · Page 1 of 1 (latest)

minor totemBOT
#

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

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

haughty dew
#

👋 happy to help

rich lodge
#

thank you 🙂

haughty dew
#

let me look at the subscription and get back to you

rich lodge
#

no problem thanks

haughty dew
#

I think you're not using the right price in the update

rich lodge
#

£20 per month?

haughty dew
#

look at the request I shared with you

#

you haven't passed a new price ID to the subscription item to change it

rich lodge
#

I thought it was maybe to do with first phase not ending straight away (because we can't have gaps between phases in the schedule) and I would have to put a trial or something in the second phase

haughty dew
#

oh sorry didn't see that this is a subscription schedule

#

my bad

#

the first phase's end_date is 2026-05-26

#

which means that until then the current price would still be invoiced

rich lodge
#

no worries, yeah I think that's theissue

haughty dew
#

if you want to start the new phase now you need to change the end_date of that phase

rich lodge
#

Is there a way I can end it today but not start invoicing until the 26th May 2026

#

It's just when I updated in test to start a new phase today it invoices today .... where as I don't wantit to invoice until the date specified

haughty dew
#

you can pass in proration_behavior: 'none'

rich lodge
#

I tried that but it still invoices today

haughty dew
#

where did you put the proration_behavior: 'none'?

#

would you mind sharing the request ID?

rich lodge
#

var newPlanPhase = new SubscriptionSchedulePhaseOptions
{
StartDate = (DateTime)newPlanStartDate,
BillingCycleAnchor = "phase_start",
Items = new List<SubscriptionSchedulePhaseItemOptions>
{
new SubscriptionSchedulePhaseItemOptions
{
Price = newRecurringPrice.Id,
Metadata = metadata,
Quantity=1
},
},
Iterations = (newPlan.NumberOfPayments > 0) ? newPlan.NumberOfPayments : 1, // if recurring payment make one scheduled payment & then the subcription will be released & ongoing
Metadata = metadata,
ProrationBehavior = "none",
};

#

Also on the current phase// Rebuild current phase with updated EndDate
var updatedCurrentPhase = new SubscriptionSchedulePhaseOptions
{
StartDate = currentPhase.StartDate,
EndDate = (DateTime)newPlanStartDate, // shorten phase to the start of the new phase,
TrialEnd = currentPhase.TrialEnd,
Metadata = currentPhase.Metadata,
Items = currentPhase.Items.Select(i => new SubscriptionSchedulePhaseItemOptions
{
Price = i.PriceId,
Quantity = i.Quantity,
Metadata = i.Metadata
}).ToList(),
ProrationBehavior = "none",
};
options.Phases.Add(updatedCurrentPhase);

haughty dew
#

the proration_behavior should be set on the old plan not the new

rich lodge
#

I've it on both

haughty dew
#

and add it to the top level of the SubscriptionSchedule

rich lodge
#

Do you mean here // Modify the phases to apply the new plan
var options = new SubscriptionScheduleUpdateOptions
{
Metadata = metadata,
Phases = new List<SubscriptionSchedulePhaseOptions>(),
ProrationBehavior = "none",
EndBehavior = (newPlan.NumberOfPayments > 0) ? "cancel" : "release", // 'release' for ongoing recurring payments, means the subscription will continue on with whatever was set in the last schedule
};

#

I have it there as well

#

Then I call options.Phases.Add(updatedCurrentPhase); options.Phases.Add(newPlanPhase);

#

var updatedSchedule = await scheduleService.UpdateAsync(schedule.Id, options, requestOptions);

minor totemBOT
rich lodge
#

I will re run it in test, but update the end date of the currentphase today and start the new phase today with proration_behavior set to none, just to see if the invoice will come out today, but as far as I remember it invoices at the start of the new phase which is today

strange flower
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!

rich lodge
#

Do you know how to resolve the issue, I want to be able to end the current phase and start the new phase but not take a payment straight away

strange flower
#

I think my colleague just answered you on this part, right ?

#

You need to set proration_behavior to none and update the end date of the current phase to now

rich lodge
#

Ah ok, that's what Im running through test, I need to set the new phase start date to today also don't i? As you can't have gaps, but then how will it know that the next invoice is due on 26/05/2026 i.e. 10 months since last invoice

strange flower
#

The ending date of a given phase needs to be the start of the next phase

rich lodge
#

Hi I have just run a test, I had to set the end date of the current phase to tomorrow as it has to be in the future. The test account I used was acct_1Rxmw5GzqfG4XYbW and the subscription Id is sub_1S18dYGzqfG4XYbW8lrpWdJ7

#

I ended the current phase tomorrow and started the new phase at the same time tomorrow, which has resulted in the next invoice coming out tomorrow. This is not the behaviour I need, in this example the original payment plan was weekly, this weeks has been paid and I want the next invoice to come out in a months time (as we're changing to monthly), setting proration_behaviour to none on the phases and on the SubscriptionScheduleUpdateOptions still results in the next invoice being tomorrow

#

Is there a way I can end the current phase and set a trial phase until the next invoice is due? Or is there anyway I can update the subscription so that the next invoice comes out on a specific date ?

strange flower
#

this weeks has been paid and I want the next invoice to come out in a months time
The month phase, will start tomorrow right? So tomorrow the customer needs to pay for the upcoming month?

#

Or you want to the customer to pay at the period end ?

rich lodge
#

they have already paid this week so a month from their last payment

#

However was thinking would I be better to update the subscription directly and not use schedules and that way I can apply a trial to specify when the next payment is due?

strange flower
rich lodge
#

The production issue was the customer paid for a subscription that was incorrectly configured to be weekly instead of monthly so the subscription they had set up was for £20 every 10 weeks and it should have been £20 every 10 months Connected Account: acct_1NrMgUIl6FCwX8px, SubscriptionId: sub_1S0IdqIl6FCwX8pxxvsVqxJu

#

They paid £20 26/08/2025 & there next invoice in 10 weeks is set for 04/11/2025

strange flower
#

Ah ok, you are trying to covering a production failure

rich lodge
#

However it should be in 10 months on 26/05/2026

strange flower
#

You can use trial/free prices then until the count matches

rich lodge
#

yes details are at the top of this thread, so I ran code that created the new price and new phase which would start on the 26/052026 but the current phase is still running so the next invoice will still come out on 04/11/2025, I need it to switch to the new monthly plan and the next invoice to come out on 26/05/2026

#

How would I use trial/free prices, would I need to update the subscription directly or do I continue using schedules?

minor totemBOT
strange flower
#

I need it to switch to the new monthly plan and the next invoice to come out on 26/05/2026
I think the straightforward workaround here, is to add a phase with a free price between the current phase and the monthly phase which start on 26/05/2026

rich lodge
#

That sounds good does that mean there will be a zero invoice though?

vernal flame
#

An invoice should only be generated at the end of a billing cycle. But I'm not completely sure whether a new billing cycle would be started when the free trial phase starts.

rich lodge
#

I've seen the test clocks, maybe the safest option is to contact the customer and cancel the subscription and get them to purchase again using the correct configuration, doing it programmatically via the api might not be the best approach