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
|
||||
|
||||
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_helpers import reset_emails_in_zulip_realm
|
||||
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")
|
||||
def test_deactivate_realm(self, mock_: Mock) -> None:
|
||||
user = self.example_user("hamlet")
|
||||
self.login_user(user)
|
||||
with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
|
||||
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, 'token')
|
||||
|
||||
|
@ -1004,11 +1004,18 @@ class StripeTest(StripeTestCase):
|
|||
do_deactivate_realm(get_realm("zulip"))
|
||||
|
||||
plan.refresh_from_db()
|
||||
self.assertTrue(get_realm('zulip').deactivated)
|
||||
self.assertEqual(get_realm('zulip').plan_type, Realm.LIMITED)
|
||||
self.assertEqual(plan.status, CustomerPlan.ENDED)
|
||||
self.assertEqual(plan.invoiced_through, last_ledger_entry)
|
||||
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
|
||||
with patch("corporate.lib.stripe.invoice_plan") as mocked:
|
||||
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:
|
||||
context = {'admin_access': False} # type: Dict[str, Any]
|
||||
return render(request, 'corporate/billing.html', context=context)
|
||||
context = {'admin_access': True}
|
||||
|
||||
plan_name = "Zulip Free"
|
||||
licenses = 0
|
||||
licenses_used = 0
|
||||
renewal_date = ''
|
||||
renewal_cents = 0
|
||||
payment_method = ''
|
||||
charge_automatically = False
|
||||
context = {
|
||||
'admin_access': True,
|
||||
'has_active_plan': False,
|
||||
}
|
||||
|
||||
plan = get_current_plan_by_customer(customer)
|
||||
if plan is not None:
|
||||
|
@ -190,17 +186,19 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
|||
else:
|
||||
payment_method = 'Billed by invoice'
|
||||
|
||||
context.update({
|
||||
'plan_name': plan_name,
|
||||
'licenses': licenses,
|
||||
'licenses_used': licenses_used,
|
||||
'renewal_date': renewal_date,
|
||||
'renewal_amount': '{:,.2f}'.format(renewal_cents / 100.),
|
||||
'payment_method': payment_method,
|
||||
'charge_automatically': charge_automatically,
|
||||
'publishable_key': STRIPE_PUBLISHABLE_KEY,
|
||||
'stripe_email': stripe_customer.email,
|
||||
})
|
||||
context.update({
|
||||
'plan_name': plan_name,
|
||||
'has_active_plan': True,
|
||||
'licenses': licenses,
|
||||
'licenses_used': licenses_used,
|
||||
'renewal_date': renewal_date,
|
||||
'renewal_amount': '{:,.2f}'.format(renewal_cents / 100.),
|
||||
'payment_method': payment_method,
|
||||
'charge_automatically': charge_automatically,
|
||||
'publishable_key': STRIPE_PUBLISHABLE_KEY,
|
||||
'stripe_email': stripe_customer.email,
|
||||
})
|
||||
|
||||
return render(request, 'corporate/billing.html', context=context)
|
||||
|
||||
@require_billing_access
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="main">
|
||||
<div class="alert alert-danger" id="error-message-box"></div>
|
||||
<h1>{{ _("Billing") }}</h1>
|
||||
{% if admin_access %}
|
||||
{% if admin_access and has_active_plan %}
|
||||
<ul class="nav nav-tabs" id="billing-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#overview">Overview</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>
|
||||
</div>
|
||||
|
||||
<div class="support-link">
|
||||
<p>
|
||||
Contact <a href="mailto:support@zulipchat.com">support@zulipchat.com</a>
|
||||
for billing history or to make changes to your subscription.
|
||||
</p>
|
||||
</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 %}
|
||||
<p>
|
||||
You must be an organization administrator or a billing administrator to view this page.
|
||||
|
|
Loading…
Reference in New Issue