diff --git a/README.rst b/README.rst index 00940c54..0cf34b02 100644 --- a/README.rst +++ b/README.rst @@ -236,7 +236,8 @@ To quickly run localstripe from source, and reload when a file changed: .. code:: shell - find -name '*.py' | entr -r python3 -m localstripe --from-scratch + pip3 install -r requirements.txt + find . -name '*.py' | entr -r python3 -m localstripe --from-scratch To quickly build and run localstripe from source: diff --git a/localstripe/resources.py b/localstripe/resources.py index b81233d3..219097df 100644 --- a/localstripe/resources.py +++ b/localstripe/resources.py @@ -2734,7 +2734,7 @@ def __init__(self, customer=None, metadata=None, items=None, assert type(billing_cycle_anchor) is int assert billing_cycle_anchor > int(time.time()) if proration_behavior is not None: - assert proration_behavior in ['create_prorations', 'none'] + assert proration_behavior in ['create_prorations', 'always_invoice', 'none'] assert type(items) is list for item in items: assert type(item.get('plan')) is str @@ -2890,7 +2890,7 @@ def _update(self, metadata=None, items=None, trial_end=None, default_tax_rates=None, tax_percent=None, plan=None, quantity=None, # legacy support prorate=None, proration_date=None, cancel_at_period_end=None, - cancel_at=None, + cancel_at=None, proration_behavior=None, # Currently unimplemented, only False works as expected: enable_incomplete_payments=False): @@ -2931,6 +2931,8 @@ def _update(self, metadata=None, items=None, trial_end=None, if cancel_at is not None: assert type(cancel_at) is int assert cancel_at > 1500000000 + if proration_behavior is not None: + assert proration_behavior in ['create_prorations', 'always_invoice', 'none'] if items is not None: assert type(items) is list for item in items: @@ -3028,9 +3030,10 @@ def _update(self, metadata=None, items=None, trial_end=None, # If the subscription is updated to a more expensive plan, an invoice # is not automatically generated. To achieve that, an invoice has to # be manually created using the POST /invoices route. - create_an_invoice = self.plan.billing_scheme == 'per_unit' and ( + create_an_invoice = proration_behavior == 'always_invoice' or ( + self.plan.billing_scheme == 'per_unit' and ( self.plan.interval != old_plan.interval or - self.plan.interval_count != old_plan.interval_count) + self.plan.interval_count != old_plan.interval_count)) if create_an_invoice: self._create_invoice() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..f83345f8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +aiohttp >=2.3.2 +python-dateutil >=2.6.1