Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

support: Add link to stripe customer dashboard.

Lauryn Menard37afad038c3a
diff --git a/corporate/lib/support.py b/corporate/lib/support.py
index f45d6d61b56..ac04c30ab7f 100644
--- a/corporate/lib/support.py
+++ b/corporate/lib/support.py
@@ -84,6 +84,7 @@ class PlanData:
is_legacy_plan: bool = False
has_fixed_price: bool = False
is_current_plan_billable: bool = False
+ stripe_customer_url: Optional[str] = None
warning: Optional[str] = None
annual_recurring_revenue: Optional[int] = None
estimated_next_plan_revenue: Optional[int] = None
@@ -114,6 +115,10 @@ class CloudSupportData:
sponsorship_data: SponsorshipData
+def get_stripe_customer_url(stripe_id: str) -> str:
+ return f"https://dashboard.stripe.com/customers/{stripe_id}" # nocoverage
+
+
def get_realm_support_url(realm: Realm) -> str:
support_realm_url = get_realm(settings.STAFF_SUBDOMAIN).url
support_url = urljoin(
@@ -295,6 +300,12 @@ def get_plan_data_for_support_view(
plan_data.next_plan = next_plan_data.plan
plan_data.estimated_next_plan_revenue = next_plan_data.estimated_revenue
+ # If customer has a stripe ID, add link to stripe customer dashboard
+ if customer is not None and customer.stripe_customer_id is not None:
+ plan_data.stripe_customer_url = get_stripe_customer_url(
+ customer.stripe_customer_id
+ ) # nocoverage
+
return plan_data
diff --git a/corporate/tests/test_support_views.py b/corporate/tests/test_support_views.py
index ea32a2def9a..00821c9221a 100644
--- a/corporate/tests/test_support_views.py
+++ b/corporate/tests/test_support_views.py
@@ -273,7 +273,7 @@ class TestRemoteServerSupportEndpoint(ZulipTestCase):
def check_legacy_plan_with_upgrade(result: "TestHttpResponse") -> None:
self.assert_in_success_response(
[
- "📅 Current plan information:",
+ "Current plan information:",
"<b>Plan name</b>: Free (legacy plan)<br />",
"<b>Status</b>: New plan scheduled<br />",
"<b>End date</b>: 01 February 2050<br />",
@@ -292,7 +292,7 @@ class TestRemoteServerSupportEndpoint(ZulipTestCase):
def check_legacy_plan_without_upgrade(result: "TestHttpResponse") -> None:
self.assert_in_success_response(
[
- "📅 Current plan information:",
+ "Current plan information:",
"<b>Plan name</b>: Free (legacy plan)<br />",
"<b>Status</b>: Active<br />",
"<b>End date</b>: 01 February 2050<br />",
diff --git a/templates/corporate/support/current_plan_details.html b/templates/corporate/support/current_plan_details.html
index 0ee308eb1e9..4a91ef2f796 100644
--- a/templates/corporate/support/current_plan_details.html
+++ b/templates/corporate/support/current_plan_details.html
@@ -1,5 +1,12 @@
<div class="current-plan-information">
- <p class="support-section-header">📅 Current plan information:</p>
+ <p class="support-section-header">
+ {% if plan_data.stripe_customer_url %}
+ <a target="_blank" rel="noopener noreferrer" href="{{ plan_data.stripe_customer_url }}"><i class="fa fa-credit-card"></i></a>
+ {% else %}
+ <i class="fa fa-credit-card"></i>
+ {% endif %}
+ Current plan information:
+ </p>
{% if plan_data.warning %}
<div class="current-plan-data-missing">
<b>{{ plan_data.warning }}</b><br />