diff --git a/hc/payments/models.py b/hc/payments/models.py index 1ed8dbe9..5d392340 100644 --- a/hc/payments/models.py +++ b/hc/payments/models.py @@ -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 diff --git a/hc/payments/views.py b/hc/payments/views.py index a510b527..a5ad7761 100644 --- a/hc/payments/views.py +++ b/hc/payments/views.py @@ -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") diff --git a/static/js/pricing.js b/static/js/pricing.js index 28817274..328a2ab5 100644 --- a/static/js/pricing.js +++ b/static/js/pricing.js @@ -53,4 +53,8 @@ $(function () { }) }); + $("#payment-method-cancel").click(function() { + location.reload(); + }); + }); \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 8e82147d..051453b7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -81,7 +81,7 @@ {% endif %} - {% if USE_PAYMENTS and False %} + {% if USE_PAYMENTS %}
  • Pricing
  • diff --git a/templates/payments/pricing.html b/templates/payments/pricing.html index 9ebb18fa..4d3781de 100644 --- a/templates/payments/pricing.html +++ b/templates/payments/pricing.html @@ -12,7 +12,7 @@

    We're sorry! There was a problem setting - up the subscription. Response from payment processor:

    + up the subscription. Response from payment gateway:

    {% for message in messages %}

    {{ message }}

    @@ -25,7 +25,11 @@

    + {% if first_charge %} + You just paid ${{ sub.price }} + {% else %} You are currently paying ${{ sub.price }}/month + {% endif %} {% if sub.pm_is_credit_card %} using {{ sub.card_type }} card @@ -178,8 +182,12 @@