mirror of https://github.com/zulip/zulip.git
support: Add link to stripe customer dashboard.
Adds a link to the stripe customer dashboard if the Customer object for an active plan has a stripe_customer_id. If there is no stripe ID to link to, then the icon is shown without a link, which is the case for remote server/realm sponsorships and legacy plans.
This commit is contained in:
parent
39c6a01c74
commit
37afad038c
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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 />",
|
||||
|
|
|
@ -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 />
|
||||
|
|
Loading…
Reference in New Issue