Skip to content

Commit

Permalink
Show vendor specific cancel URL
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed May 25, 2019
1 parent 11033ab commit d574d0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ <h2 class="card-pf-title">
<strong title="{% trans 'Paid until' %}">{{ tenant.paid_until }}</strong>
</div>

{% if cancel_url %}
<div class="list-view-pf-additional-info-item">
<a class="btn btn-danger"
title="{% trans 'Cancel subscription on GitHub' %}"
href="https://github.com/settings/billing">
title="{% trans 'Cancel subscription' %}"
href="{{ cancel_url }}">
{% trans 'Cancel' %}
</a>
</div>
{% endif %}
</div>
</div>
</div> <!-- /main info -->
Expand Down
10 changes: 10 additions & 0 deletions tcms_github_marketplace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,23 @@ def get_context_data(self, **kwargs):

mp_purchase = purchases.first()

cancel_url = None
if mp_purchase is not None:
if mp_purchase.vendor.lower() == 'github':
cancel_url = "https://github.com/settings/billing"

if mp_purchase.vendor.lower() == 'fastspring':
cancel_url = mp_purchase.payload['data']['account']['url']

mp_purchase = mp_purchase.payload['marketplace_purchase']
if mp_purchase['billing_cycle'] == 'monthly':
subscription_price = mp_purchase['plan']['monthly_price_in_cents'] // 100
subscription_period = _('mo')
elif mp_purchase['billing_cycle'] == 'yearly':
subscription_price = mp_purchase['plan']['yearly_price_in_cents'] // 100
subscription_period = _('yr')

subscription_price = int(subscription_price)
else:
subscription_price = '-'
subscription_period = '-'
Expand All @@ -296,6 +305,7 @@ def get_context_data(self, **kwargs):
'purchases': purchases,
'subscription_price': subscription_price,
'subscription_period': subscription_period,
'cancel_url': cancel_url,
}

return context

0 comments on commit d574d0b

Please sign in to comment.