#Neto300 - subscription updates

1 messages · Page 1 of 1 (latest)

waxen karmaBOT
somber crypt
#

Wait, so if you want to charge for those 10 days, why are you creating a trial?

rapid comet
#

Because that's the way I know of changing the billing_cycle_anchor...

#

Perhaps what I need , it's not to create a trial...

#

but not sure how to achieve those 2 things, changing the billing_cycle_anchor of the subscription and still charge for those days.

somber crypt
#

I would recommend reading through this section of the docs you mentioned: https://stripe.com/docs/billing/subscriptions/billing-cycle#prorations

Prorations are what will allow you to charge (or not charge) for the 10 days. I believe setting proration_behavior="create_prorations" and updating the billing_cycle_anchor without a trial is the best course of action, but you'll want to test and read those docs carefully in case the side-effects do something you don't want

Learn how to set the billing date for subscriptions.

rapid comet
#

yeah, the thing with that, it is that , for editing the billing_cycle_anchor only allow the now option there...

#
Stripe::InvalidRequestError: When updating an existing subscription, billing_cycle_anchor must be either unset, 'now', or 'unchanged'

that's the output I get when trying this.:

  new_billing_cycle_date = Time.current

  Stripe::Subscription.update(
      'test', { billing_cycle_anchor: new_billing_cycle_date.change(year: 2023, month: 3, day: 31, hour: 12).to_i, proration_behavior: 'create_prorations' }
  )
somber crypt
#

So, let's take a step back. A customer pays for their Subscription ahead of time, so they've already paid for the entire billing cycle. When you call Subscription.update() and set a trial, you are effectively saying "hey, have this customer make another payment on the next billing cycle, which will occur when this trial ends" so you have 2 options. You can either (a) set billing_cycle_anchor to now on the day that they want their billing cycle set to , or (b) you use a trial to change the billing cycle. Either way, you have to wait until the new billing cycle before making the update if you want to charge for the 10 days.

jovial marsh
#

Neto300 - subscription updates

rapid comet
#

yeah, you got the flow now.... I was afraid of that resolution. thank you.

So my solution for the option (a) was to create a single charge manually of those 10 days on the 03/18/2023 after the invoice of the end of the trial has been paid.

which bring me some questions...

is there a way to calculate the prorate of those 10 days via api ??

once we have that amount I thinking we can try somethings like:

  • Schedule a single charge( if possible)
  • Add that amount to the upcoming invoice( the first invoice after the trials ends) in this case on the 04/18/2023
  • Create a separate invoice with that amount.
jovial marsh
#

Hey apologies for the delay, still thinking through your use case a bit. You can use our upcoming invoice API to see what the proration would be before changing a subscription though I'm not sure if there would be an easy easy way to specify that you want the price from 3/10-3/18 specifically https://stripe.com/docs/api/invoices/upcoming

#

Also trying to think of if there is a simpler way to do this than using that then creating the invoice item

rapid comet
rapid comet
jovial marsh
#

Yeah, I think one way to do this with that API call would be to set the proration date to 03/08 and subscription_cancel_at to 3/18, that should essentially give you the price of that subscription for those 10 days. I'm trying to think of whether that would correctly predict what you are looking for though

#

Also to be clear, when you move the anchor like this, will it always be to extend the cycle from some amount of days from the end of the current one?

rapid comet
#

sweet, Let me try that and let you know the outcome...

#

Also to be clear, when you move the anchor like this, will it always be to extend the cycle from some amount of days from the end of the current >one?
yes,