mirror of https://github.com/zulip/zulip.git
billing: Show appropriate message when not on a paid plan.
This commit is contained in:
parent
dc4d88f6c9
commit
3f94195d51
|
@ -21,7 +21,8 @@ from django.utils.timezone import now as timezone_now
|
||||||
import stripe
|
import stripe
|
||||||
|
|
||||||
from zerver.lib.actions import do_deactivate_user, do_create_user, \
|
from zerver.lib.actions import do_deactivate_user, do_create_user, \
|
||||||
do_activate_user, do_reactivate_user, do_deactivate_realm
|
do_activate_user, do_reactivate_user, do_deactivate_realm, \
|
||||||
|
do_reactivate_realm
|
||||||
from zerver.lib.test_classes import ZulipTestCase
|
from zerver.lib.test_classes import ZulipTestCase
|
||||||
from zerver.lib.test_helpers import reset_emails_in_zulip_realm
|
from zerver.lib.test_helpers import reset_emails_in_zulip_realm
|
||||||
from zerver.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp
|
from zerver.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp
|
||||||
|
@ -984,7 +985,6 @@ class StripeTest(StripeTestCase):
|
||||||
@patch("corporate.lib.stripe.billing_logger.info")
|
@patch("corporate.lib.stripe.billing_logger.info")
|
||||||
def test_deactivate_realm(self, mock_: Mock) -> None:
|
def test_deactivate_realm(self, mock_: Mock) -> None:
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
self.login_user(user)
|
|
||||||
with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
|
with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
|
||||||
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, 'token')
|
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, 'token')
|
||||||
|
|
||||||
|
@ -1004,11 +1004,18 @@ class StripeTest(StripeTestCase):
|
||||||
do_deactivate_realm(get_realm("zulip"))
|
do_deactivate_realm(get_realm("zulip"))
|
||||||
|
|
||||||
plan.refresh_from_db()
|
plan.refresh_from_db()
|
||||||
|
self.assertTrue(get_realm('zulip').deactivated)
|
||||||
self.assertEqual(get_realm('zulip').plan_type, Realm.LIMITED)
|
self.assertEqual(get_realm('zulip').plan_type, Realm.LIMITED)
|
||||||
self.assertEqual(plan.status, CustomerPlan.ENDED)
|
self.assertEqual(plan.status, CustomerPlan.ENDED)
|
||||||
self.assertEqual(plan.invoiced_through, last_ledger_entry)
|
self.assertEqual(plan.invoiced_through, last_ledger_entry)
|
||||||
self.assertIsNone(plan.next_invoice_date)
|
self.assertIsNone(plan.next_invoice_date)
|
||||||
|
|
||||||
|
do_reactivate_realm(get_realm('zulip'))
|
||||||
|
|
||||||
|
self.login_user(user)
|
||||||
|
response = self.client_get("/billing/")
|
||||||
|
self.assert_in_success_response(["Your organization is on the <b>Zulip Free</b>"], response)
|
||||||
|
|
||||||
# The extra users added in the final month are not charged
|
# The extra users added in the final month are not charged
|
||||||
with patch("corporate.lib.stripe.invoice_plan") as mocked:
|
with patch("corporate.lib.stripe.invoice_plan") as mocked:
|
||||||
invoice_plans_as_needed(self.next_month)
|
invoice_plans_as_needed(self.next_month)
|
||||||
|
|
|
@ -159,15 +159,11 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
||||||
if not user.is_realm_admin and not user.is_billing_admin:
|
if not user.is_realm_admin and not user.is_billing_admin:
|
||||||
context = {'admin_access': False} # type: Dict[str, Any]
|
context = {'admin_access': False} # type: Dict[str, Any]
|
||||||
return render(request, 'corporate/billing.html', context=context)
|
return render(request, 'corporate/billing.html', context=context)
|
||||||
context = {'admin_access': True}
|
|
||||||
|
|
||||||
plan_name = "Zulip Free"
|
context = {
|
||||||
licenses = 0
|
'admin_access': True,
|
||||||
licenses_used = 0
|
'has_active_plan': False,
|
||||||
renewal_date = ''
|
}
|
||||||
renewal_cents = 0
|
|
||||||
payment_method = ''
|
|
||||||
charge_automatically = False
|
|
||||||
|
|
||||||
plan = get_current_plan_by_customer(customer)
|
plan = get_current_plan_by_customer(customer)
|
||||||
if plan is not None:
|
if plan is not None:
|
||||||
|
@ -192,6 +188,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
||||||
|
|
||||||
context.update({
|
context.update({
|
||||||
'plan_name': plan_name,
|
'plan_name': plan_name,
|
||||||
|
'has_active_plan': True,
|
||||||
'licenses': licenses,
|
'licenses': licenses,
|
||||||
'licenses_used': licenses_used,
|
'licenses_used': licenses_used,
|
||||||
'renewal_date': renewal_date,
|
'renewal_date': renewal_date,
|
||||||
|
@ -201,6 +198,7 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
||||||
'publishable_key': STRIPE_PUBLISHABLE_KEY,
|
'publishable_key': STRIPE_PUBLISHABLE_KEY,
|
||||||
'stripe_email': stripe_customer.email,
|
'stripe_email': stripe_customer.email,
|
||||||
})
|
})
|
||||||
|
|
||||||
return render(request, 'corporate/billing.html', context=context)
|
return render(request, 'corporate/billing.html', context=context)
|
||||||
|
|
||||||
@require_billing_access
|
@require_billing_access
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="alert alert-danger" id="error-message-box"></div>
|
<div class="alert alert-danger" id="error-message-box"></div>
|
||||||
<h1>{{ _("Billing") }}</h1>
|
<h1>{{ _("Billing") }}</h1>
|
||||||
{% if admin_access %}
|
{% if admin_access and has_active_plan %}
|
||||||
<ul class="nav nav-tabs" id="billing-tabs">
|
<ul class="nav nav-tabs" id="billing-tabs">
|
||||||
<li class="active"><a data-toggle="tab" href="#overview">Overview</a></li>
|
<li class="active"><a data-toggle="tab" href="#overview">Overview</a></li>
|
||||||
<li><a data-toggle="tab" href="#payment-method">Payment Method</a></li>
|
<li><a data-toggle="tab" href="#payment-method">Payment Method</a></li>
|
||||||
|
@ -69,14 +69,31 @@
|
||||||
<div class="tab-pane" id="loading">
|
<div class="tab-pane" id="loading">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="support-link">
|
<div class="support-link">
|
||||||
<p>
|
<p>
|
||||||
Contact <a href="mailto:support@zulipchat.com">support@zulipchat.com</a>
|
Contact <a href="mailto:support@zulipchat.com">support@zulipchat.com</a>
|
||||||
for billing history or to make changes to your subscription.
|
for billing history or to make changes to your subscription.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
{% elif admin_access and not has_active_plan %}
|
||||||
|
<div class="tab-content">
|
||||||
|
<center>
|
||||||
|
<p>
|
||||||
|
<h2>Your organization is on the <b>Zulip Free</b> plan.</h2>
|
||||||
|
<a href="/upgrade">
|
||||||
|
<button type="submit" class="button green">Upgrade to Standard</button>
|
||||||
|
</a>
|
||||||
|
<a href="/plans">
|
||||||
|
<button type="submit">View all plans</button>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
<div class="support-link">
|
||||||
|
<p>
|
||||||
|
Contact <a href="mailto:support@zulipchat.com">support@zulipchat.com</a> for billing history.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
You must be an organization administrator or a billing administrator to view this page.
|
You must be an organization administrator or a billing administrator to view this page.
|
||||||
|
|
Loading…
Reference in New Issue