mirror of https://github.com/zulip/zulip.git
stripe: Extract method to get billing page context.
This commit is contained in:
parent
0d3c68cefb
commit
fec155ea9c
|
@ -1585,20 +1585,13 @@ class BillingSession(ABC):
|
||||||
return None, None
|
return None, None
|
||||||
return None, last_ledger_entry
|
return None, last_ledger_entry
|
||||||
|
|
||||||
def get_billing_page_context(self) -> Dict[str, Any]:
|
def get_billing_context_from_plan(
|
||||||
context: Dict[str, Any] = {}
|
self,
|
||||||
now = timezone_now()
|
customer: Customer,
|
||||||
|
plan: CustomerPlan,
|
||||||
customer = self.get_customer()
|
last_ledger_entry: LicenseLedger,
|
||||||
assert customer is not None
|
now: datetime,
|
||||||
|
) -> Dict[str, Any]:
|
||||||
plan = get_current_plan_by_customer(customer)
|
|
||||||
assert plan is not None
|
|
||||||
|
|
||||||
new_plan, last_ledger_entry = self.make_end_of_cycle_updates_if_needed(plan, now)
|
|
||||||
assert last_ledger_entry is not None
|
|
||||||
plan = new_plan if new_plan is not None else plan
|
|
||||||
|
|
||||||
downgrade_at_end_of_cycle = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE
|
downgrade_at_end_of_cycle = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE
|
||||||
downgrade_at_end_of_free_trial = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_FREE_TRIAL
|
downgrade_at_end_of_free_trial = plan.status == CustomerPlan.DOWNGRADE_AT_END_OF_FREE_TRIAL
|
||||||
switch_to_annual_at_end_of_cycle = (
|
switch_to_annual_at_end_of_cycle = (
|
||||||
|
@ -1690,6 +1683,22 @@ class BillingSession(ABC):
|
||||||
}
|
}
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
def get_billing_page_context(self) -> Dict[str, Any]:
|
||||||
|
now = timezone_now()
|
||||||
|
|
||||||
|
customer = self.get_customer()
|
||||||
|
assert customer is not None
|
||||||
|
|
||||||
|
plan = get_current_plan_by_customer(customer)
|
||||||
|
assert plan is not None
|
||||||
|
|
||||||
|
new_plan, last_ledger_entry = self.make_end_of_cycle_updates_if_needed(plan, now)
|
||||||
|
assert last_ledger_entry is not None
|
||||||
|
plan = new_plan if new_plan is not None else plan
|
||||||
|
|
||||||
|
context = self.get_billing_context_from_plan(customer, plan, last_ledger_entry, now)
|
||||||
|
return context
|
||||||
|
|
||||||
def get_initial_upgrade_context(
|
def get_initial_upgrade_context(
|
||||||
self, initial_upgrade_request: InitialUpgradeRequest
|
self, initial_upgrade_request: InitialUpgradeRequest
|
||||||
) -> Tuple[Optional[str], Optional[UpgradePageContext]]:
|
) -> Tuple[Optional[str], Optional[UpgradePageContext]]:
|
||||||
|
|
Loading…
Reference in New Issue