Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions handlers/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def get(self):
cancel_flag = "canceled" in (user.stripe_plan_id or "")
updated_flag = self.get_argument("update", "") == "1"
migrated_flag = self.get_argument("migrated", 0)
cancel_error = self.get_argument("cancel-error", "") == "1"
past_due = False
source_card_type = None
source_last_4 = None
Expand Down Expand Up @@ -246,6 +247,7 @@ def get(self):
updated_flag=updated_flag,
migrated_flag=migrated_flag,
cancel_flag=cancel_flag,
cancel_error=cancel_error,
production_site=production_site)

@tornado.web.authenticated
Expand Down Expand Up @@ -1112,13 +1114,21 @@ class PaymentCancelHandler(BaseHandler):
@tornado.web.authenticated
def post(self):
user = self.get_current_user_object()
cancel_comments = self.get_argument("cancel_comments", "")
cancel_reason = self.get_argument("cancel_reason", "")
if user.stripe_customer_id:
try:
customer = stripe.Customer.retrieve(user.stripe_customer_id, expand=["subscriptions"])
if customer and customer.subscriptions.total_count > 0:
subscription = customer.subscriptions.data[0]
if subscription:
subscription.delete(at_period_end=True)
cancellation_details = {
"feedback": cancel_reason,
"comment": cancel_comments,
}
stripe.Subscription.modify(
subscription.id, cancel_at_period_end=True,
cancellation_details=cancellation_details)
if user.stripe_plan_id and ("-canceled" not in user.stripe_plan_id):
user.stripe_plan_id = user.stripe_plan_id + "-canceled"
user.stripe_plan_rate = None
Expand All @@ -1133,7 +1143,7 @@ def post(self):

payment_notifications(user, 'cancellation')
except stripe.error.InvalidRequestError:
pass
self.redirect('/account/settings?cancel-error=1')
return self.redirect('/account/settings?cancel=1')

@tornado.web.authenticated
Expand Down
51 changes: 42 additions & 9 deletions templates/account/payment-cancel.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,56 @@
<div class="content content-membership">
<h1 class="thank-you">Canceling</h1>
<p>
Thanks for trying us out, we're sorry to see you go but understand the site isn't for everyone.
Thanks for trying us out, we&rsquo;re sorry to see you go but understand the site isn&rsquo;t for everyone.
</p>

<p>
To cancel your account right now, click this button to confirm your the cancellation of your
subscription:
Before you go, please let us know why you&rsquo;re canceling your subscription. Your feedback is not
required, but appreciated!
</p>

<form action="/account/payment/cancel" method="POST">
{{ xsrf_form_html() }}
<input type="submit"
class="subscription-button" value="Yes, Please Cancel" border="0">
</form>
<div class="fun-form">
<form action="/account/payment/cancel" method="POST">
{{ xsrf_form_html() }}

<div class="field">
<label for="cancel-reason">Cancellation Reason:</label>
<div class="field-input">
<select name="cancel_reason" id="cancel-reason">
<option>--</option>
<option value="customer_service">Customer service issue</option>
<option value="missing_features">MLTSHP is missing feature(s) I&rsquo;d like</option>
<option value="switched_service">I found an alternative</option>
<option value="too_complex">MLTSHP is complex or hard to use</option>
<option value="too_expensive">MLTSHP is too expensive</option>
<option value="unused">Not using it enough</option>
<option value="other">Other reason not listed</option>
</select>
</div>
<div class="field-help">
Please let us know why you&rsquo;re canceling!
</div>
</div>

<div class="field">
<label for="cancel-comments">Any additional comments?</label>
<div class="field-input">
<textarea name="cancel_comments" id="cancel-comments" rows="4" cols="40"></textarea>
</div>
</div>

<div class="field field-submit">
<input class="btn btn-danger" type="submit"
class="subscription-button" value="Yes, Please Cancel">
</div>
</form>
</div>

<div class="clear"><!-- --></div>

<p>
If you have any questions or need help please email us at <a href="mailto:hello@mltshp.com">hello@mltshp.com</a>
and we'll get back to you as soon as possible.
and we&rsquo;ll get back to you as soon as possible.
</p>
</div>
{% end %}
16 changes: 12 additions & 4 deletions templates/account/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@

{% block main %}
<div class="content content-settings">
{% if cancel_error %}
<div class="alert alert--danger">
<strong>We weren&rsquo;t able to cancel your subscription.</strong>
Please <a href="mailto:hello@mltshp.com">contact us</a>
about this and we&rsquo;ll take care of it.
</div>
{% end %}

<div class="settings-header">
<h1>Your Settings</h1>
<div class="settings-navigation">
Expand Down Expand Up @@ -134,7 +142,7 @@ <h3>MLKSHK Restore Status</h3>
Your MLKSHK posts are safe and sound and ready to be restored. Click the button below
to start restoring your content.
</p>
<a class="btn btn-primary btn-shadow" href="/account/mlkshk-migrate">Let's Go!</a>
<a class="btn btn-primary btn-shadow" href="/account/mlkshk-migrate">Let&rsquo;s Go!</a>
{% end %}
</div>
</div>
Expand Down Expand Up @@ -213,13 +221,13 @@ <h4>Your Membership Plan: <a href="/account/membership">{{ plan_name }}</a></h4>
{% end %}

{% if not cancel_flag %}
<p>If you'd like to cancel your subscription <a href="/account/payment/cancel">you can do so here</a>.</p>
<p>If you&rsquo;d like to cancel your subscription <a href="/account/payment/cancel">you can do so here</a>.</p>
{% end %}
{% else %}
{% if user.stripe_customer_id %}
<p>
You have no active MLTSHP subscription. <a href="/account/membership">Click here to re-subscribe</a>
if you'd like to support MLTSHP!
if you&rsquo;d like to support MLTSHP!
</p>

<p><hr></p>
Expand All @@ -245,7 +253,7 @@ <h4>Your Membership Plan: <a href="/account/membership">{{ plan_name }}</a></h4>

{% else %}
<p>
You are currently using a free account. If you'd like
You are currently using a free account. If you&rsquo;d like
to support MLTSHP and get some nifty new benefits you can
<a href="/account/membership">upgrade to a paid account</a>.
</p>
Expand Down