#xmy_best-practices

1 messages ยท Page 1 of 1 (latest)

quaint flowerBOT
#

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

๐Ÿ“ 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.

earnest kayak
slate quiver
#

Ok during what event would I then update the subscription?

#

And backdating would be setting the start date of the monthly subscription on the yearly subscription?

earnest kayak
#

Yes to your second question.

#

Not sure I fully understand your first question, can you provide more details?

slate quiver
#

Does backdating mean it would make the yearly subscription 1/12th cheaper?

#

Not sure I fully understand your first question, can you provide more details?
I want to call the update in my api if the customer didn't cancel the monthly subscription

earnest kayak
#

Backdating is mostly to make the Subscription last 11 more months instead of the full year. Proration is what's going to credit the customer for the amount they already paid during the first month.

slate quiver
#

Would this be the customer.subscription.deleted event?

earnest kayak
#

No, that Event only fires when a Subscription is canceled. You want the opposite, right? You want to trigger the upgrade when the second Invoice for a Subscription is created?

slate quiver
#

The second invoice would be for the monthly subscription, correct?

earnest kayak
#

Yeah. Maybe I'm misunderstanding? It sounds like you want to create a monthly Subscription, then when the first month ends you want to automatically upgrade it to a yearly Subscription with 11 months left?

slate quiver
#

Yeah

earnest kayak
#

And you want to do this for every Subscription, not as a result of a user action?

slate quiver
#

Yeah so essentially it's a one-time paid 1 month trial, and this 1 month trial can be canceled otherwise it would roll over to the yearly subscription

earnest kayak
#

๐Ÿค”

slate quiver
#

Let me know if I can help you clarify. I didn't come up with the requirement ๐Ÿ˜†

#

So basically it's Customer A which is first time and Customer B which is recurring

A: 1 month paid trial -> 11 month yearly plan -> 12 month yearly plan and so on
B: 12 month yearly plan -> 12 month yearly plan and so on

earnest kayak
#

Okay, I take it back. I think your original approach with a Subscription Schedule is probably best. The first phase would be a single month with the trial Price. The second phase would be for 11 months with the 11-month Price. That second Price would have recurring.interval set to month and recurring.interval_count set to 11.

#

Then do you want it to stop or move to a regular yearly Subscription?

slate quiver
#

It's EU law, the yearly subscription should always stop after a year and then they need to re-purchase it

#

Do you think it would be easier to just do 13 months (i.e the 1 month paid trial then carry over to the yearly subscription)?

earnest kayak
#

Wait... is the desired total length of the Subscription, including the trial, 12 months or 13 months?

slate quiver
#

Yeah initially I was thinking about doing 1 month + 11 months so the total would be 12, but I am wondering if it's easier to do the monthly paid trial + the yearly subscription in the schedule

earnest kayak
#

It's not really easier or harder either way at this point.

slate quiver
#

Hm, I'm just thinking about if the monthly price * 12 is different than the yearly price setting recurring.interval_count would not work would it?

earnest kayak
#

The key is to have multiple Prices under the same Product for the different variations you want to charge at different times. A 1 month trial Price. An 11 month after Trial Price. A 1 year Price for the second+ years.

#

Your goal is to charge twice for the first year, right? You charge the trial price, then you charge once for the remaining 11 months?

slate quiver
#

Yeah one charge for the trial, then if not canceled in the first month it rolls over to the 11 month subscription with the second charge

earnest kayak
#

Yeah, so you want one Price for the one month trial period, then another 11 month Price for the total cost of those 11 months. Then a third Price for people who buy their second/third/etc. year. So, for example, if your Subscription costs $10/month, you'd have:

  • Trial Price: $10/month
  • 11 Month price: $110/11 months
  • Yearly Price: $120/year
slate quiver
#

Ok ๐Ÿ‘ , given the Trial price * 12 is the yearly price then I could also do recurring.interval_count = 11 for the second phase on the monthly trial?

#

If not settling for the 11 month price is fine too I guess

earnest kayak
#

There is no recurring.interval_count on the phases. That's a property on the Prices.

slate quiver
#

Oh alright

earnest kayak
#

In your Subscription Schedule, your first phase would use the trial Price with iterations set to 1. Your second phase would use the 11 month Price and it would also have iterations set to 1 because you only want one 11 month period.

#

Does that make sense?

slate quiver
#

So for cancelling / resuming during the monthly trial I'd just update the phase by removing / adding the 11 month price from it?

#

Yeah it makes sense ๐Ÿ‘

earnest kayak
#

It sounds like you don't want to cancel if you want them to be able to resume the trial. A canceled Subscription can't be reactivated.

slate quiver
#

Well they won't cancel the monthly trial subscription as they would still be in that phase

#

I was referring to updating whether or not the schedule has the 11 month subscription that would follow after

#

Or do I have some fundamental misunderstanding on how these schedules work

earnest kayak
#

Sorry, not sure I follow. I'm recommending that you create every new Subscription with the two phases I described above. If people cancel the Subscription before the trial ends they won't get to the second phase and won't be charged for it. If they don't cancel, they will.

slate quiver
#

Ok one example

#
const subscriptionSchedule = await stripe.subscriptionSchedules.create({
  customer: 'cus_GBHHxuvBvO26Ea',
  start_date: 'now',
  end_behavior: 'release',
  phases: [
    {
      items: [
        {
          price: '1_month_trial_price',
          quantity: 1,
        },
      ],
      iterations: 1,
    },
    {
      items: [
        {
          price: '11_month_price',
          quantity: 1,
        },
      ],
      iterations: 1,
    },
  ],
});
#

Deciding on whether or not the 11 month subscription will be charged after the 1 month trial the customer could either press Cancel/Resume before the 1 month phase ends. This would add/remove the second phase with the 11_month_price, correct?

earnest kayak
#

I think you probably want end_behavior set to cancel to the Subscription is canceled after the Schedule phases end (you mentioned earlier you wanted people to explicitly subscribe for another year earlier).

#

The phases won't be altered, but the entire thing will stop.

slate quiver
#

I think I'd want that either way because I want the customer to re-subscribe after each year

#

And when your customer cancels, you should cancel the entire Subscription Schedule:
That looks like a permanent thing to me. So there is no way to edit the phases?

earnest kayak
#

With end_behavior set to cancel that will happen automatically when the Scheudle's phases end.

#

You only need to call the cancel API explicitly when people press the cancel button on your site before the phases have ended.

quaint flowerBOT
slate quiver
#

Ok so the subscriptions always cancel automatically anyways. All I care about is the state when you are in the first phase (1 month trial) and you are up to decide if you want to resume with the 11 month price or not

earnest kayak
#

Once the Subscription is canceled, yeah, it's over. That Subscription is done forever. If they pay for another year you would create a new Subscription for them using the yearly Price.

#

And set it to cancel at the end.

slate quiver
#

And I don't want that to cancel the entire schedule, they should be able to modify it as long as they are in the first phase with the 1 month price

earnest kayak
#

That's not how it works.

#

The idea isn't to have a single Subscription Schedule that lasts forever.

#

Think of the Subscription Schedules, for your use case, as ephemeral, only lasting for a single year.

#

Customer signs up, create a Schedule, that Schedule ends one way or another within or after a year.

#

If they want another year, create a new Subscription for them for the next year.

slate quiver
#

Ok so if the customer doesn't want the 11 month subscription within the first month, what are my options

#

Seems there is no way I can then alter the schedule and remove it?

earnest kayak
#

You don't need to alter it, you just need to cancel the Subscription Schedule.

#

So, for example, if you created a Subscription Schedule for me today with the 1 month trial phase and the 11 month rest-of-year phase, then tomorrow I wanted to cancel, you would call the cancel API for that Schedule. That would cancel both the Schedule and the Subscription, meaning both could no longer be used, and I would not be charged again, because it won't proceed to the next phase.

#

The phases are still there, but they're associated with a canceled Subscription Schedule that's no longer active and which will no longer advance.

slate quiver
#

Ok so the first phase would still run or would that also cancel immediately?

earnest kayak
#

It would cancel immediately.

slate quiver
#

Yeah that's not what I want, they already paid for the first month so it should stay

earnest kayak
#

You don't have to turn off their access to whatever on your end. You can note what they paid for and leave their access open until the end date.

#

The end date of the trial I mean.

slate quiver
#

Ok fair point

#

Maybe I'm overthinking about the case where someone changes their mind, but it's probably not that big of a deal

earnest kayak
#

That's a bit more work, but it might be closer to what you want.

slate quiver
#

Ah yeah I think this is what I want

earnest kayak
#

In any case, I think you've got what you need to try some of these scenarios in test mode and figure out what works best for your specific needs. You can use test clocks to advance time in test mode to test longer-running scenarios: https://docs.stripe.com/billing/testing/test-clocks

#

I think seeing this stuff in action, especially over time, will be just what you need at this point to bring everything together.

slate quiver
#

Yeah sure enough, uff that's gonna take a bit of work haha

#

Thank you so much for staying patient with me ๐Ÿ™

earnest kayak
#

Absolutely! Always happy to help!

slate quiver
#

Thanks Rubeus, have a nice day