forked from GithubBackups/healthchecks
Notify user about first charge, show "Pricing" in top nav again.
This commit is contained in:
parent
35aed93b7f
commit
2f0e6b5672
@ -11,14 +11,12 @@ class Subscription(models.Model):
|
||||
|
||||
def _get_braintree_sub(self):
|
||||
if not hasattr(self, "_sub"):
|
||||
print("getting subscription over network")
|
||||
self._sub = braintree.Subscription.find(self.subscription_id)
|
||||
|
||||
return self._sub
|
||||
|
||||
def _get_braintree_payment_method(self):
|
||||
if not hasattr(self, "_pm"):
|
||||
print("getting payment method over network")
|
||||
self._pm = braintree.PaymentMethod.find(self.payment_method_token)
|
||||
|
||||
return self._pm
|
||||
|
@ -27,9 +27,15 @@ def pricing(request):
|
||||
sub = Subscription(user=request.user)
|
||||
sub.save()
|
||||
|
||||
first_charge = False
|
||||
if "first_charge" in request.session:
|
||||
first_charge = True
|
||||
del request.session["first_charge"]
|
||||
|
||||
ctx = {
|
||||
"page": "pricing",
|
||||
"sub": sub
|
||||
"sub": sub,
|
||||
"first_charge": first_charge
|
||||
}
|
||||
|
||||
return render(request, "payments/pricing.html", ctx)
|
||||
@ -38,6 +44,8 @@ def pricing(request):
|
||||
def log_and_bail(request, result):
|
||||
for error in result.errors.deep_errors:
|
||||
messages.error(request, error.message)
|
||||
else:
|
||||
messages.error(request, result.message)
|
||||
|
||||
return redirect("hc-pricing")
|
||||
|
||||
@ -83,6 +91,7 @@ def create_plan(request):
|
||||
sub.subscription_id = result.subscription.id
|
||||
sub.save()
|
||||
|
||||
request.session["first_charge"] = True
|
||||
return redirect("hc-pricing")
|
||||
|
||||
|
||||
|
@ -53,4 +53,8 @@ $(function () {
|
||||
})
|
||||
});
|
||||
|
||||
$("#payment-method-cancel").click(function() {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
});
|
@ -81,7 +81,7 @@
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if USE_PAYMENTS and False %}
|
||||
{% if USE_PAYMENTS %}
|
||||
<li {% if page == 'pricing' %} class="active" {% endif %}>
|
||||
<a href="{% url 'hc-pricing' %}">Pricing</a>
|
||||
</li>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div class="alert alert-danger">
|
||||
<p>
|
||||
<strong>We're sorry!</strong> There was a problem setting
|
||||
up the subscription. Response from payment processor:</p>
|
||||
up the subscription. Response from payment gateway:</p>
|
||||
|
||||
{% for message in messages %}
|
||||
<p class="error-message">{{ message }}</p>
|
||||
@ -25,7 +25,11 @@
|
||||
<div class="col-md-12">
|
||||
<div id="subscription-status" class="jumbotron">
|
||||
<p>
|
||||
{% if first_charge %}
|
||||
You just paid <strong>${{ sub.price }}</strong>
|
||||
{% else %}
|
||||
You are currently paying <strong>${{ sub.price }}/month</strong>
|
||||
{% endif %}
|
||||
|
||||
{% if sub.pm_is_credit_card %}
|
||||
using {{ sub.card_type }} card
|
||||
@ -178,8 +182,12 @@
|
||||
<div id="payment-form"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Set Up Subscription</button>
|
||||
<button id="payment-method-cancel" type="button" class="btn btn-default">
|
||||
Cancel
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Set Up Subscription
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user