Repository: dj-stripe/dj-stripe

Issue:
Cannot specify billing_cycle_anchor attribute for a Subscription
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](https://stripe.com/docs/billing/subscriptions/trials#combine-trial-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?


Discussion:

Resolving patch:
diff --git a/djstripe/models/billing.py b/djstripe/models/billing.py
--- a/djstripe/models/billing.py
+++ b/djstripe/models/billing.py
@@ -1048,6 +1048,7 @@ def update(
 		self,
 		plan=None,
 		application_fee_percent=None,
+		billing_cycle_anchor=None,
 		coupon=None,
 		prorate=djstripe_settings.PRORATION_POLICY,
 		proration_date=None,
@@ -1061,6 +1062,12 @@ def update(
 
 		:param plan: The plan to which to subscribe the customer.
 		:type plan: Plan or string (plan ID)
+		:param application_fee_percent:
+		:type application_fee_percent:
+		:param billing_cycle_anchor:
+		:type billing_cycle_anchor:
+		:param coupon:
+		:type coupon:
 		:param prorate: Whether or not to prorate when switching plans. Default is True.
 		:type prorate: boolean
 		:param proration_date:
@@ -1070,6 +1077,14 @@ def update(
 			logic, such as prorating by day instead of by second, by providing the time that you
 			wish to use for proration calculations.
 		:type proration_date: datetime
+		:param metadata:
+		:type metadata:
+		:param quantity:
+		:type quantity:
+		:param tax_percent:
+		:type tax_percent:
+		:param trial_end:
+		:type trial_end:
 
 		.. note:: The default value for ``prorate`` is the DJSTRIPE_PRORATION_POLICY setting.
 
diff --git a/djstripe/models/core.py b/djstripe/models/core.py
--- a/djstripe/models/core.py
+++ b/djstripe/models/core.py
@@ -518,6 +518,7 @@ def subscribe(
 		quantity=None,
 		metadata=None,
 		tax_percent=None,
+		billing_cycle_anchor=None,
 		trial_end=None,
 		trial_from_plan=None,
 		trial_period_days=None,
@@ -544,6 +545,11 @@ def subscribe(
 			be calculated and added as tax to the final amount each billing period.
 		:type tax_percent: Decimal. Precision is 2; anything more will be ignored. A positive decimal
 			between 1 and 100.
+		:param billing_cycle_anchor: A future timestamp to anchor the subscription’s billing cycle.
+			This is used to determine the date of the first full invoice, and,
+			for plans with month or year intervals, the day of the month for
+			subsequent invoices.
+		:type billing_cycle_anchor: datetime
 		:param trial_end: The end datetime of the trial period the customer will get before being charged for
 			the first time. If set, this will override the default trial period of the plan the
 			customer is being subscribed to. The special value ``now`` can be provided to end
@@ -579,6 +585,7 @@ def subscribe(
 			coupon=coupon,
 			quantity=quantity,
 			metadata=metadata,
+			billing_cycle_anchor=billing_cycle_anchor,
 			tax_percent=tax_percent,
 			trial_end=trial_end,
 			trial_from_plan=trial_from_plan,


Test patch: