From 9ec05e7df4c43c89b880f916f70f28b30cb985f0 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 23 Sep 2018 13:13:29 +0200 Subject: [PATCH] Merge billing and generic-payment forms and post values as get parameters --- hosting/static/hosting/js/payment.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/hosting/static/hosting/js/payment.js b/hosting/static/hosting/js/payment.js index 4934fdd3..a8b2adb6 100644 --- a/hosting/static/hosting/js/payment.js +++ b/hosting/static/hosting/js/payment.js @@ -124,17 +124,25 @@ $(document).ready(function () { $('#billing-form').submit(); } - +function getCookie(name) { + var value = "; " + document.cookie; + var parts = value.split("; " + name + "="); + if (parts.length === 2) return parts.pop().split(";").shift(); +} var $form_new = $('#payment-form-new'); $form_new.submit(payWithStripe_new); - function payWithStripe_new(e) { e.preventDefault(); function stripeTokenHandler(token) { // Insert the token ID into the form so it gets submitted to the server $('#id_token').val(token.id); - $('#billing-form').submit(); + var get_parameters = $("#billing-form").serialize(); + get_parameters += "&" + $("#generic-payment-form").serialize(); + $('
' + + ''+ + '
').appendTo('body').submit(); } @@ -199,7 +207,15 @@ $(document).ready(function () { $('.credit-card-info .btn.choice-btn').click(function(){ var id = this.dataset['id_card']; $('#id_card').val(id); - $('#billing-form').submit(); + 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(); }); });