From 2511f667e61dddc83b7cdc0e46ed6a03d0937718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= <p.mueller@pcsg.de> Date: Thu, 26 Apr 2018 16:04:24 +0200 Subject: [PATCH] fix: make Amazon widgets reloadable --- bin/controls/PaymentDisplay.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/bin/controls/PaymentDisplay.js b/bin/controls/PaymentDisplay.js index 2a62988..73672d6 100644 --- a/bin/controls/PaymentDisplay.js +++ b/bin/controls/PaymentDisplay.js @@ -105,19 +105,18 @@ define('package/quiqqer/payment-amazon/bin/controls/PaymentDisplay', [ widgetUrl = 'https://static-eu.payments-amazon.com/OffAmazonPayments/eur/lpa/js/Widgets.js'; } - if (typeof amazon !== 'undefined') { - this.$showAmazonPayBtn(); - return; - } - this.$OrderProcess.Loader.show(); - if (typeof window.onAmazonPaymentsReady === 'undefined') { - window.onAmazonPaymentsReady = this.$showAmazonPayBtn; - } + window.onAmazonPaymentsReady = this.$showAmazonPayBtn; + window.onAmazonLoginReady = this.$onAmazonLoginReady; + + if (typeof amazon !== 'undefined') { + var ScriptElm = document.getElement('script[src="' + widgetUrl + '"]'); - if (typeof window.onAmazonLoginReady === 'undefined') { - window.onAmazonLoginReady = this.$onAmazonLoginReady; + if (ScriptElm) { + amazon = null; + ScriptElm.destroy(); + } } new Element('script', { @@ -145,7 +144,7 @@ define('package/quiqqer/payment-amazon/bin/controls/PaymentDisplay', [ this.$AuthBtnElm.removeClass('quiqqer-payment-amazon__hidden'); OffAmazonPayments.Button( - 'quiqqer-payment-amazon-btn', + this.$AuthBtnElm.get('id'), this.getAttribute('sellerid'), { type : 'PwA', -- GitLab