From a62105fa284bdef00c8600439e85ee7f9042758f Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 24 Nov 2017 09:42:26 +0100 Subject: [PATCH] Stripe Elements: Fix incorrect JavaScript and display loading indicator --- .../static/pretixplugins/stripe/pretix-stripe-checkout.js | 2 +- .../stripe/static/pretixplugins/stripe/pretix-stripe.js | 8 +++++++- .../pretixplugins/stripe/checkout_payment_form.html | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe-checkout.js b/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe-checkout.js index f6053e1435..9797d5ffa0 100644 --- a/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe-checkout.js +++ b/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe-checkout.js @@ -64,7 +64,7 @@ $(function () { $(".checkout-button-row .btn-primary").click( function (e) { - if (($("input[name=payment][value=stripe]").prop('checked') || $("input[type=checkbox][name=payment]").length === 0) + if (($("input[name=payment][value=stripe]").prop('checked') || $("input[type=checkbox][name=radio]").length === 0) && $("#stripe_token").val() == "") { pretixstripe.start(); e.preventDefault(); diff --git a/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe.js b/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe.js index 417e418d57..903359a499 100644 --- a/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe.js +++ b/src/pretix/plugins/stripe/static/pretixplugins/stripe/pretix-stripe.js @@ -28,6 +28,9 @@ var pretixstripe = { }); }, 'load': function () { + if (pretixstripe.stripe !== null) { + return; + } $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true); $.ajax( { @@ -66,6 +69,9 @@ var pretixstripe = { ); }, 'load_checkout': function () { + if (pretixstripe.checkout_handler !== null) { + return; + } $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true); $.ajax( { @@ -151,7 +157,7 @@ $(function () { $('.stripe-container').closest("form").submit( function () { - if (($("input[name=payment][value=stripe]").prop('checked') || $("input[name=payment][type=checkbox]").length === 0) + if (($("input[name=payment][value=stripe]").prop('checked') || $("input[name=payment][type=radio]").length === 0) && $("#stripe_token").val() == "") { if ($("#stripe-checkout").length) { pretixstripe.show_checkout(); diff --git a/src/pretix/plugins/stripe/templates/pretixplugins/stripe/checkout_payment_form.html b/src/pretix/plugins/stripe/templates/pretixplugins/stripe/checkout_payment_form.html index dff1ecf4ab..f196af3afe 100644 --- a/src/pretix/plugins/stripe/templates/pretixplugins/stripe/checkout_payment_form.html +++ b/src/pretix/plugins/stripe/templates/pretixplugins/stripe/checkout_payment_form.html @@ -31,6 +31,7 @@ {% endif %}
+