From 484ab5f1c6b6408834ebec2a587f77360585d12f Mon Sep 17 00:00:00 2001 From: Levi Date: Sun, 4 Jun 2017 17:41:48 -0500 Subject: [PATCH] fixed payment when user has already a card --- hosting/static/hosting/js/payment.js | 11 +++++++---- hosting/templates/hosting/payment.html | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hosting/static/hosting/js/payment.js b/hosting/static/hosting/js/payment.js index dc4023e8..af9a9e71 100644 --- a/hosting/static/hosting/js/payment.js +++ b/hosting/static/hosting/js/payment.js @@ -1,10 +1,7 @@ $( document ).ready(function() { - var stripe = Stripe(window.stripeKey); - var elements = stripe.elements({locale: window.current_lan}); - var card = elements.create('card', options={hidePostalCode: true}); - card.mount('#card-element'); + $.ajaxSetup({ beforeSend: function(xhr, settings) { @@ -32,6 +29,12 @@ $( document ).ready(function() { var hasCreditcard = window.hasCreditcard || false; + if (!hasCreditcard){ + var stripe = Stripe(window.stripeKey); + var elements = stripe.elements({locale: window.current_lan}); + var card = elements.create('card', options={hidePostalCode: true}); + card.mount('#card-element'); + } console.log("has creditcard", hasCreditcard); // hasCreditcard= true; diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index 0badfa0f..b6af6f5f 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -57,9 +57,11 @@
Type: {{credit_card_data.cc_brand}}
- + + {% else %}