Skip to content

Commit 78bee8b

Browse files
committed
Merge branch 'MAGETWO-58670' into MPI-PR-bugfixes
2 parents 12602c4 + 1986c70 commit 78bee8b

File tree

1 file changed

+17
-3
lines changed
  • app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context

1 file changed

+17
-3
lines changed

app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-express.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ define(
2525
) {
2626
'use strict';
2727

28+
// State of PayPal module initialization
29+
var clientInit = false;
30+
2831
return Component.extend({
2932

3033
defaults: {
@@ -93,15 +96,26 @@ define(
9396
* @returns {Object}
9497
*/
9598
initClient: function () {
99+
var selector = '#' + this.getButtonId();
100+
96101
_.each(this.clientConfig, function (fn, name) {
97102
if (typeof fn === 'function') {
98103
this.clientConfig[name] = fn.bind(this);
99104
}
100105
}, this);
101106

102-
domObserver.get('#' + this.getButtonId(), function () {
103-
paypalExpressCheckout.checkout.setup(this.merchantId, this.clientConfig);
104-
}.bind(this));
107+
if (!clientInit) {
108+
domObserver.get(selector, function () {
109+
paypalExpressCheckout.checkout.setup(this.merchantId, this.clientConfig);
110+
clientInit = true;
111+
domObserver.off(selector);
112+
}.bind(this));
113+
} else {
114+
domObserver.get(selector, function () {
115+
$(selector).on('click', this.clientConfig.click);
116+
domObserver.off(selector);
117+
}.bind(this));
118+
}
105119

106120
return this;
107121
},

0 commit comments

Comments
 (0)