From f02ec8b24bebbd21cb4eb04eb66b65f99375ed42 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 9 Aug 2017 13:56:30 +0200 Subject: [PATCH] Improve Stripe.js loading --- .../static/pretixplugins/stripe/pretix-stripe.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 18f28d4358..beb4698e46 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,7 @@ var pretixstripe = { }); }, 'load': function () { + $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true); $.ajax( { url: 'https://js.stripe.com/v3/', @@ -59,11 +60,13 @@ var pretixstripe = { }); pretixstripe.card.mount("#stripe-card"); } + $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", false); } } ); }, 'load_checkout': function () { + $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true); $.ajax( { url: 'https://checkout.stripe.com/checkout.js', @@ -85,6 +88,7 @@ var pretixstripe = { allowRememberMe: false, billingAddress: false }); + $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", false); } } ); @@ -106,21 +110,23 @@ var pretixstripe = { 'checkout_handler': null }; $(function () { - if (!$(".stripe-container").length) // Not on the checkout page + if (!$(".stripe-container, #stripe-checkout").length) // Not on the checkout page return; if ($("input[name=payment][value=stripe]").is(':checked') || $(".payment-redo-form").length) { if ($("#stripe-checkout").length) { pretixstripe.load_checkout(); + } else { + pretixstripe.load(); } - pretixstripe.load(); } else { $("input[name=payment]").change(function () { if ($(this).val() === 'stripe') { if ($("#stripe-checkout").length) { pretixstripe.load_checkout(); + } else { + pretixstripe.load(); } - pretixstripe.load(); } }) }