Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot specify billing_cycle_anchor attribute for a Subscription #814

Closed
PabloCastellano opened this issue Feb 3, 2019 · 3 comments
Closed

Comments

@PabloCastellano
Copy link
Collaborator

According to the documentation the billing_cycle_anchor attribute can be used when creating and updating a subscription.

billing_cycle_anchor (timestamp)

Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.

This is particularly useful for the use case of Combining trials with billing cycle anchor.

As I understand, djstripe supports this option:

https://github.com/dj-stripe/dj-stripe/blob/master/djstripe/models/billing.py#L939

However when using customer.subscribe() you cannot specify this parameter

https://github.com/dj-stripe/dj-stripe/blob/master/djstripe/models/core.py#L512

I am willing to contribute but need some guidance. Is adding it as a parameter to that function and then when calling Subscription._api_create enough?

@PabloCastellano
Copy link
Collaborator Author

I've got it working in my branch.

import datetime
from dateutil.relativedelta import relativedelta

next_month = datetime.date.today() + relativedelta(months=1, day=1)                                                                                                                                                                 
ts = int(next_first.strftime("%s"))

subscription = customer.subscribe(plan, billing_cycle_anchor=ts)                                                                                                                                                

I've submitted two PRs, for master and stable-1.2

@therefromhere
Copy link
Contributor

Thanks, that looks reasonable, I'll take a closer look later.

@blackboxoperations
Copy link

Be sure to note two things when leaning on the anchor like this:

  1. It isn't odd anymore for everyone to have their own distinct subscription start date/time, as opposed to forcing everyone into a first/middle/last of the month start/stop date and pro-rate yourself into an early code grace unnecessarily

  2. The billing_cycle_anchor is primarily about helping those who need to round off a cycle and pro-rate based on the remaining time, where the references above were emphasizing how you could add in a 7 day trial period and be sure that if there's any time left in the month, that it's pro-rated and invoiced specifically and accordingly.

Only reason I point this out is because the billing_cycle_anchor isn't meant to be a subscription trial period fix, so if and when a side-effect creeps up and bites anyone in the ass when using it, look in that direction first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants