Skip to content

Commit da57658

Browse files
committed
Merge branch 'MAGETWO-96289' into 2.2-develop-pr11
2 parents ace297a + 1219f0a commit da57658

File tree

1 file changed

+17
-27
lines changed
  • app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer

1 file changed

+17
-27
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
define([
88
'jquery',
99
'underscore',
10-
'mage/utils/wrapper',
1110
'Magento_Checkout/js/view/payment/default',
1211
'Magento_Braintree/js/view/payment/adapter',
1312
'Magento_Checkout/js/model/quote',
@@ -19,7 +18,6 @@ define([
1918
], function (
2019
$,
2120
_,
22-
wrapper,
2321
Component,
2422
Braintree,
2523
quote,
@@ -105,6 +103,12 @@ define([
105103
}
106104
});
107105

106+
quote.shippingAddress.subscribe(function () {
107+
if (self.isActive()) {
108+
self.reInitPayPal();
109+
}
110+
});
111+
108112
// for each component initialization need update property
109113
this.isReviewRequired(false);
110114
this.initClientConfig();
@@ -222,9 +226,8 @@ define([
222226

223227
/**
224228
* Re-init PayPal Auth Flow
225-
* @param {Function} callback - Optional callback
226229
*/
227-
reInitPayPal: function (callback) {
230+
reInitPayPal: function () {
228231
if (Braintree.checkout) {
229232
Braintree.checkout.teardown(function () {
230233
Braintree.checkout = null;
@@ -235,17 +238,6 @@ define([
235238
this.clientConfig.paypal.amount = this.grandTotalAmount;
236239
this.clientConfig.paypal.shippingAddressOverride = this.getShippingAddress();
237240

238-
if (callback) {
239-
this.clientConfig.onReady = wrapper.wrap(
240-
this.clientConfig.onReady,
241-
function (original, checkout) {
242-
this.clientConfig.onReady = original;
243-
original(checkout);
244-
callback();
245-
}.bind(this)
246-
);
247-
}
248-
249241
Braintree.setConfig(this.clientConfig);
250242
Braintree.setup();
251243
},
@@ -429,19 +421,17 @@ define([
429421
* Triggers when customer click "Continue to PayPal" button
430422
*/
431423
payWithPayPal: function () {
432-
this.reInitPayPal(function () {
433-
if (!additionalValidators.validate()) {
434-
return;
435-
}
424+
if (!additionalValidators.validate()) {
425+
return;
426+
}
436427

437-
try {
438-
Braintree.checkout.paypal.initAuthFlow();
439-
} catch (e) {
440-
this.messageContainer.addErrorMessage({
441-
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
442-
});
443-
}
444-
}.bind(this));
428+
try {
429+
Braintree.checkout.paypal.initAuthFlow();
430+
} catch (e) {
431+
this.messageContainer.addErrorMessage({
432+
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
433+
});
434+
}
445435
},
446436

447437
/**

0 commit comments

Comments
 (0)