#_obo_

1 messages ยท Page 1 of 1 (latest)

buoyant troutBOT
celest dagger
#

Hello! It depends on your use case. Can you link me to where you're seeing that?

wicked junco
#

my use case is pretty simple, I just want to downgrade a user at the end of their subscription billing cycle

celest dagger
#

Ah, gotcha. I honestly don't know why we recommend that there... setting start_date to whatever you want, be it a date in the past, future, or now are all equally valid use cases.

wicked junco
#

so I am using the right API endpoint for scheduling a downgrade at the end of a subscription's billing cycle, yes?

#

or is there another (better) way of doing this I should know about

celest dagger
#

You're doing the right thing, yeah. You would use a Subscription Schedule with phases that describe the changes you want made to the Subscription in the future.

wicked junco
#

Can I also do this with just a simple subscriptions.update call? ChatGPT seems to think so, but that seems somewhat off to me so i wanted to double check what it's suggesting. Let me provide the code real quick

#

async function downgradeSubscription(subscriptionId, newPlanId) {
try {
const subscription = await stripe.subscriptions.update(subscriptionId, {
items: [{
id: subscription.items.data[0].id,
price: newPlanId,
}],
prorate: false,
billing_cycle_anchor: 'now'
});

    console.log('Subscription downgraded successfully:', subscription);
} catch (error) {
    console.error('Error downgrading subscription:', error);
}

}

const currentSubscriptionId = 'sub_xxx'; // Your subscription ID here
const newPriceId = 'price_xxx'; // Your new price (plan) ID here

downgradeSubscription(currentSubscriptionId, newPriceId);

#
this stuck out specifically:

"The basic method I initially provided pertains to Stripe's direct Subscription API, where you can upgrade, downgrade, or modify an existing subscription. The method provided will change the subscription at the end of the current billing cycle. The parameters prorate and billing_cycle_anchor are used to control the billing adjustments and the timing of the change. This approach is straightforward and works for many basic use cases."
#

it seems to think that subscription schedules are for doing things like A-> B -> C -> A

#

(sorry for being a pain here, I'm sure you know more than chatGPT here)

celest dagger
#

I recommend you avoid using ChatGPT to help you with Stripe code. It usually gets things wrong, often in subtle ways that will cause you a lot of pain later.

#

We're here 24/6 and can answer your questions better than an ML chat bot can. ๐Ÿ™‚

#

To answer your question though, you can update an existing Subscription to upgrade or downgrade it without a Subscription Schedule, but the changes are immediate.

#

If you want an upgrade or downgrade to happen in the future you can either schedule the Subscription update on your end, or you can use a Subscription Schedule to schedule the change on our end.

wicked junco
#

Okay perfect, thank you for the confirmation. Just wanted to make sure I wasn't missing something obscure

celest dagger
#

Of particular note, this part: "The method provided will change the subscription at the end of the current billing cycle." That's 100% incorrect.

wicked junco
#

haha, yes that's why I specifically came to the discord chat

#

spidey sense were going off

#

thanks for your confirmation

#

so from looking at the docs you provided, and the api docs, the example you linked still does have start_date: 'now'. For my use case specifically (downgrading at the end of the month), it seems like i would want to set the "from_subscription" value to the subscription i'm looking to modify and end_behavior to "release".

However the rest of things is confusing me a bit here.

  • Would what I need to include for "phases" here since it's just one change and not multiple?

  • what would I put for the start_date? If I leave this blank what would it default to given the settings above?

celest dagger
#

The examples you're looking at show the creation of a Subscription Schedule which, in turn, creates a Subscription on the start_date specified. In many use cases people want to create both the Subscription Schedule and the Subscription at the same time, which is why you're seeing start_date set to now.

#

For your use case you would have at least two phases: the first phase would be the current state of the Subscription, before the downgrade, and the second phase would start in the future and describe the state of the Subscription after the downgrade.

#

For your last question, can you clarify if you're trying to apply a Subscription Schedule to an existing Subscription?

wicked junco
#

yes, the customer will have a current subscription, and then if they choose to downgrade their subscription, we let them use their current plan until the end of their billing cycle, at which point they will be downgraded to whatever the next plan they chose was

celest dagger
#

You create a Subscription Schedule for the existing Subscription, which will automatically create the first/current phase based on the current state of the Subscription, then you can update the Subscription Schedule with the second downgrade phase in the future.

wicked junco
#

got it, for my use case, could I just do that in a singular call? or do you have to do it in a separate API call?

celest dagger
#

It would be at least two separate API calls, one to create the Subscription Schedule for the existing Subscription, a second one to modify that Schedule with the upcoming changes you want.

wicked junco
#

interesting, okay

#

I think I'll have to play with this a bit for sure

celest dagger
#

Do you know about Test Clocks?

wicked junco
#

thank you for your help

#

I know they exist

#

haven't read too much into them yet

celest dagger
wicked junco
#

good to know. do they affect other parts of the subscription or is it pretty isolated?

#

(things like billing anchors, etc)

celest dagger
#

They impact everything contained within them. If you read that page things should become clear. ๐Ÿ™‚

wicked junco
#

perfect, yes thank you

#

should have read before asking the follow up questions

#

have a great day