Skip to content

Commit 4ab8469

Browse files
author
Mariana Lashch
committed
Merge branch 'MAGETWO-96291' into forwardport-1411
2 parents 076ec45 + ee582ec commit 4ab8469

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
},
@@ -428,19 +420,17 @@ define([
428420
* Triggers when customer click "Continue to PayPal" button
429421
*/
430422
payWithPayPal: function () {
431-
this.reInitPayPal(function () {
432-
if (!additionalValidators.validate()) {
433-
return;
434-
}
423+
if (!additionalValidators.validate()) {
424+
return;
425+
}
435426

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

446436
/**

0 commit comments

Comments
 (0)