#DanTheGoodman - Subscription Extensions

1 messages ยท Page 1 of 1 (latest)

robust girder
#

Hello! Let me think about this a moment...

#

Either of those approaches should work. A third option is to adjust the trial period, but that may not work if the trial period gets too big, so I think adjusting the Subscription Schedule is probably best.

cloud wharf
#

really want to avoid trials

#

@robust girder does the current_period_end reflect the index 0 item in the subscription schedule?

robust girder
#

Meaning the current_period_end on the Subscription itself? If so, that only reflects the current state of the Subscription itself, it doesn't take into account the Subscription Schedule.

cloud wharf
#

so if I made a schedule for an existing subscription, and then made a interval 6 100% of coupon period, that current_period_end would only show the end of the first interval?

robust girder
#

If you're managing the Subscription with a Subscription Schedule could you add one phase for each extension?

cloud wharf
#

yeah I guess I'd have to add before the last phase if one exists

#

so insert after index -2

robust girder
#

Separate phases might makes things cleaner and easier to reason about vs. stacking extensions on a single phase.

cloud wharf
#

when a phase ends, it is popped off the front of the list of current phases (response from the GET)?

robust girder
#

I think so, but let me see if I can confirm that...

cloud wharf
#

cool thanks

robust girder
#

Okay, so it should show all the phases, even ones in the past. However, if you update a Subscription Schedule's phases when there are older phases already in the past your update may cause those already-passed phases to drop off.

cloud wharf
#

hmm ok... seems tricky tbh

#

with chargebee it's a nice as just setting the next billing date :/, maybe there is a better way to handle this?

#

I guess I could replace with a new schedule? with the modified first and second phases if there is a first one that I need to extend

dawn inlet
#

๐Ÿ‘‹ Hopping in since @robust girder had to head out - give me a minute to catch up

cloud wharf
#

thanks

dawn inlet
#

How much have you worked with Schedules so far? This is something that you can definitely model w/ subscription schedule updates, and I wouldn't recommend going down the replace w/ a new schedule route because it's more api requests then you need

cloud wharf
#

none so far

#

so if I just replace all the phases, does that just sort of upsert it?

#

I see

Note that past phases can be omitted.

dawn inlet
#

yeah it would basically be an upsert

cloud wharf
#

ok so I can just simply call update (or create if one does not exist), and change the phases

#

and I just set the start date to now

dawn inlet
#

well let's talk through what the phases should look like a bit more

#

when you say set the start date to now, what specific start date are you talking about? The start date of the schedule? The start date of the phase that will give them an extension?

cloud wharf
#

the schedule

#

so basically there are going to be 3 cases:

  1. No schedule, first time giving 100% off coupon
  2. Current schedule, currently in 100% coupon, need to change the first phase to be the expiry + 30 days (and set schedule start to now)
  3. Current schedule, 100% is over, need to create a fresh one with 100% that starts now and ends in 30 days (and set schedule start to now)
dawn inlet
#

Now going into the three use cases:

#

Actually before I go into the three flows - is your ideal behavior that the extension kicks in AFTER the current cycle is over, or should it kick in immediately and once the extension is over it finished out the rest of the cycle it was in the middle of. It'll be much cleaner to do this with the extension kicking in after the current cycle

cloud wharf
#

i'd want it to kick in immediately

#

well I guess it could be after..

#

just want to prevent a renewal basically if the 100% off coupon is redeemed, and stack as needed

#

but what I can do to simplify the logic of how to check for if a schedule phase needs to be extended is probably just set it to start now, but make the first phase end after the current_period_end of the subscription + 30 days

dawn inlet
#

Let's say you have a monthly subscription that started on August 1st. On August 15th they get a 30 day extension. There are two different flows you can have:

  1. Start the 30 day "free period" from August 15th - September 15th. Move back into the normal, not free period from Sept 15 - Oct 1.
  2. Let the current period finish from August 1 - Sept 1. Then move into the 30 day extension period from Sept 1 - Oct 1.

Option 1 is actually more difficult to model correctly with Schedules because what your describing (adding 30 days + current_period_end) will turn that whole time period from August 15- October 1 to a "free" period.

cloud wharf
#

I can see why that is easier to start, but if we need to add a 30 day free period Nov 13th, that old schedule will show and we have to do some logic to figure out which period they are in and make a new schedule based on that, right?

dawn inlet
#

What do you mean by "that old schedule will show"? In the above example, the extension phase would be done by Oct 1, and then the schedule should move back into a normal, non-extension phase

cloud wharf
#

doesn't the schedule show old phases though?

#

if I get a schedule

dawn inlet
#

Ah, I see what you're getting at - you have concerns with having to add logic that determines what the actual current phase is, right?

cloud wharf
#

yeah

dawn inlet
cloud wharf
#

now when I sort of do this upsert, do I need to preserve the old phase array for any reason? Or can I just construct a new one?

#

For some cases I probably have to do a "start now" thing, like when extending a currently free phase

dawn inlet
#

You don't have to preserve the old phases if it makes your logic/integration easier

cloud wharf
#

How do I tell a phase to start at the end of hte current period?

#

When the subscription schedule starts. We recommend using now so that it starts the subscription immediately. You can also use a Unix timestamp to backdate the subscription so that it starts on a past date, or set a future date for the subscription to start on.

#

I guess I'd need to calculate that too anyway?

dawn inlet
#

The way it would work is that you'd have a phase that represents the current period, and then you add an additional phase after that which will start as soon as the current period ends

cloud wharf
#

ok, so start would still be now?

dawn inlet
#

and you wouldn't need to set start_date at all - like I mentioned, if you're working with subscriptions you'd use from_subscription to generate the schedules and it'll start it immediately

cloud wharf
#

right

#

and the billing anchor is preserved it seems?

dawn inlet
#

yes - when you create the schedule with from_subscription that'll create a schedule that matches exactly what the subscription looks like at the time. The current phase of that schedule will match the current billing cycle as well

#

I need to head out soon, but does that cover a lot of the basics? Really I think the best way to get familiar with sub schedules is to start trying out a bunch of things in test mode to see how it works.

cloud wharf
#

Yeah this was great, thanks

dawn inlet
#

๐Ÿ‘ If you need anything else @low dock is around to help!

low dock
#

๐Ÿ‘‹