From 2a694295adce460b0623e6b7628b4ec7f4af7bf2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 23 Sep 2018 17:00:48 +0200 Subject: [PATCH] Refactor payment.js --- hosting/static/hosting/js/payment.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/hosting/static/hosting/js/payment.js b/hosting/static/hosting/js/payment.js index a8b2adb6..7b649754 100644 --- a/hosting/static/hosting/js/payment.js +++ b/hosting/static/hosting/js/payment.js @@ -129,6 +129,14 @@ function getCookie(name) { var parts = value.split("; " + name + "="); if (parts.length === 2) return parts.pop().split(";").shift(); } + +function submitBillingForm(){ + var billing_form =$('#billing-form'); + billing_form.append(''); + billing_form.append(''); + billing_form.append(''); + billing_form.submit(); +} var $form_new = $('#payment-form-new'); $form_new.submit(payWithStripe_new); function payWithStripe_new(e) { @@ -137,12 +145,7 @@ function getCookie(name) { function stripeTokenHandler(token) { // Insert the token ID into the form so it gets submitted to the server $('#id_token').val(token.id); - var get_parameters = $("#billing-form").serialize(); - get_parameters += "&" + $("#generic-payment-form").serialize(); - $('
' + - ''+ - '
').appendTo('body').submit(); + submitBillingForm(); } @@ -207,15 +210,7 @@ function getCookie(name) { $('.credit-card-info .btn.choice-btn').click(function(){ var id = this.dataset['id_card']; $('#id_card').val(id); - var get_parameters = $("#billing-form").serialize(); - var generic_payment_form = $("#generic-payment-form"); - if (generic_payment_form !== null) { - get_parameters += "&" + generic_payment_form.serialize(); - } - $('
' + - ''+ - '
').appendTo('body').submit(); + submitBillingForm(); }); });