From 98fe5054c26828a3a15c8cd7b5905c7cf99c6103 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 18 Mar 2019 16:17:03 +0000 Subject: [PATCH] [FIX] payment_stripe: open>exit>open opened 1 time If using Stripe we did "Pay Now" -> close modal -> "Pay Now" we would get 2 modals and possibly be blocked by infinite loading. With this changeset, we only execute one time our strip.js file so we do not declare multiple MutationObserver. We also only open one checkout at a time from stripe when closing and opening it or multiclicking click (the later one that could block the interface with several stripe iframe opened and one with a infinite loading wheel). opw-1939323 closes #31928 Signed-off-by: Nicolas Lempereur (nle) --- addons/payment_stripe/static/src/js/stripe.js | 8 ++++++-- addons/payment_stripe/views/payment_stripe_templates.xml | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/payment_stripe/static/src/js/stripe.js b/addons/payment_stripe/static/src/js/stripe.js index be767d31161..0283fd453d8 100644 --- a/addons/payment_stripe/static/src/js/stripe.js +++ b/addons/payment_stripe/static/src/js/stripe.js @@ -21,9 +21,13 @@ odoo.define('payment_stripe.stripe', function(require) { $.blockUI.defaults.css["background-color"] = ''; $.blockUI.defaults.overlayCSS["opacity"] = '0.9'; } + var stripeHandler; function getStripeHandler() { - var handler = StripeCheckout.configure({ + if (stripeHandler) { + return stripeHandler; + } + stripeHandler = StripeCheckout.configure({ key: $("input[name='stripe_key']").val(), image: $("input[name='stripe_image']").val(), locale: 'auto', @@ -61,7 +65,7 @@ odoo.define('payment_stripe.stripe', function(require) { }); }, }); - return handler; + return stripeHandler; } require('web.dom_ready'); diff --git a/addons/payment_stripe/views/payment_stripe_templates.xml b/addons/payment_stripe/views/payment_stripe_templates.xml index 2fc054f97ae..059bf6fede4 100644 --- a/addons/payment_stripe/views/payment_stripe_templates.xml +++ b/addons/payment_stripe/views/payment_stripe_templates.xml @@ -21,7 +21,12 @@ - +