Skip to content

Commit 392ed5d

Browse files
committed
Merge remote-tracking branch 'mainline/2.1' into MAGETWO-54682-2.1
2 parents 547c401 + d61ff0d commit 392ed5d

File tree

20 files changed

+100
-60
lines changed

20 files changed

+100
-60
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ protected function placeCheckoutOrder()
127127
);
128128
} catch (\Exception $exception) {
129129
$result->setData('error', true);
130-
$result->setData('error_messages', __('Unable to place order. Please try again later.'));
130+
$result->setData(
131+
'error_messages',
132+
__('An error occurred on the server. Please try to place the order again.')
133+
);
131134
}
132135
if ($response instanceof Http) {
133136
$response->representJson($this->jsonHelper->jsonEncode($result));

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ public function textExecuteFailedPlaceOrderDataProvider()
280280
{
281281
$objectFailed = new \Magento\Framework\DataObject();
282282
$objectFailed->setData('error', true);
283-
$objectFailed->setData('error_messages', __('Unable to place order. Please try again later.'));
283+
$objectFailed->setData(
284+
'error_messages',
285+
__('An error occurred on the server. Please try to place the order again.')
286+
);
284287

285288
return [
286289
[

app/code/Magento/Authorizenet/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"Order saving error: %1","Order saving error: %1"
33
"Please choose a payment method.","Please choose a payment method."
44
"We can\'t process your order right now. Please try again later.","We can\'t process your order right now. Please try again later."
5-
"Unable to place order. Please try again later.","Unable to place order. Please try again later."
5+
"An error occurred on the server. Please try to place the order again.","An error occurred on the server. Please try to place the order again."
66
"Credit Card: xxxx-%1","Credit Card: xxxx-%1"
77
"amount %1","amount %1"
88
failed.,failed.

app/code/Magento/Braintree/Model/Ui/ConfigProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public function getConfig()
7979
'payment' => [
8080
self::CODE => [
8181
'isActive' => $this->config->isActive(),
82-
'isSingleUse' => !$isPayPalActive,
8382
'clientToken' => $this->getClientToken(),
8483
'ccTypesMapper' => $this->config->getCctypesMapper(),
8584
'sdkUrl' => $this->config->getSdkUrl(),

app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public function getConfigDataProvider()
154154
'payment' => [
155155
ConfigProvider::CODE => [
156156
'isActive' => true,
157-
'isSingleUse' => false,
158157
'clientToken' => self::CLIENT_TOKEN,
159158
'ccTypesMapper' => ['visa' => 'VI', 'american-express' => 'AE'],
160159
'sdkUrl' => self::SDK_URL,

app/code/Magento/Braintree/view/frontend/web/js/view/payment/braintree.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,19 @@
77
define(
88
[
99
'uiComponent',
10-
'uiRegistry',
11-
'Magento_Braintree/js/view/payment/adapter',
1210
'Magento_Checkout/js/model/payment/renderer-list'
1311
],
1412
function (
1513
Component,
16-
Registry,
17-
Braintree,
1814
rendererList
1915
) {
2016
'use strict';
2117

2218
var config = window.checkoutConfig.payment,
2319
braintreeType = 'braintree',
24-
payPalType = 'braintree_paypal',
25-
path = 'checkout.steps.billing-step.payment.payments-list.',
26-
components = [];
20+
payPalType = 'braintree_paypal';
2721

2822
if (config[braintreeType].isActive) {
29-
components.push(path + braintreeType);
3023
rendererList.push(
3124
{
3225
type: braintreeType,
@@ -44,13 +37,6 @@ define(
4437
);
4538
}
4639

47-
// setup Braintree SDK with merged configuration from all related components
48-
if (components.length) {
49-
Registry.get(components, function () {
50-
Braintree.setup();
51-
});
52-
}
53-
5440
/** Add view logic here if needed */
5541
return Component.extend({});
5642
}

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,22 @@ define(
6161
this.beforePlaceOrder(response);
6262
},
6363

64+
/**
65+
* Device data initialization
66+
*
67+
* @param {Object} checkout
68+
*/
69+
onReady: function (checkout) {
70+
braintree.checkout = checkout;
71+
},
72+
6473
/**
6574
* Triggers on any Braintree error
75+
* @param {Object} response
6676
*/
67-
onError: function () {
68-
this.paymentMethodNonce = null;
77+
onError: function (response) {
78+
braintree.showError($t('Payment ' + this.getTitle() + ' can\'t be initialized'));
79+
throw response.message;
6980
},
7081

7182
/**
@@ -90,7 +101,7 @@ define(
90101
this._super()
91102
.observe(['active']);
92103
this.validatorManager.initialize();
93-
this.initBraintree();
104+
this.initClientConfig();
94105

95106
return this;
96107
},
@@ -122,11 +133,11 @@ define(
122133
* @param {Boolean} isActive
123134
*/
124135
onActiveChange: function (isActive) {
125-
if (!isActive || this.isSingleUse()) {
136+
if (!isActive) {
126137
return;
127138
}
128139

129-
this.reInitBraintree();
140+
this.initBraintree();
130141
},
131142

132143
/**
@@ -146,17 +157,9 @@ define(
146157
},
147158

148159
/**
149-
* Create Braintree configuration
160+
* Init Braintree configuration
150161
*/
151162
initBraintree: function () {
152-
this.initClientConfig();
153-
braintree.config = _.extend(braintree.config, this.clientConfig);
154-
},
155-
156-
/**
157-
* Re-init Braintree configuration
158-
*/
159-
reInitBraintree: function () {
160163
var intervalId = setInterval(function () {
161164
// stop loader when frame will be loaded
162165
if ($('#braintree-hosted-field-number').length) {
@@ -165,6 +168,12 @@ define(
165168
}
166169
}, 500);
167170

171+
if (braintree.checkout) {
172+
braintree.checkout.teardown(function () {
173+
braintree.checkout = null;
174+
});
175+
}
176+
168177
fullScreenLoader.startLoader();
169178
braintree.setConfig(this.clientConfig);
170179
braintree.setup();
@@ -309,14 +318,6 @@ define(
309318
});
310319

311320
return false;
312-
},
313-
314-
/**
315-
* Check if Braintree configured without PayPal
316-
* @returns {Boolean}
317-
*/
318-
isSingleUse: function () {
319-
return window.checkoutConfig.payment[this.getCode()].isSingleUse;
320321
}
321322
});
322323
}

app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ public function savePaymentInformationAndPlaceOrder(
8080
try {
8181
$orderId = $this->cartManagement->placeOrder($cartId);
8282
} catch (\Exception $e) {
83-
throw new CouldNotSaveException(__('Unable to place order. Please try again later.'), $e);
83+
throw new CouldNotSaveException(
84+
__('An error occurred on the server. Please try to place the order again.'),
85+
$e
86+
);
8487
}
8588
return $orderId;
8689
}

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public function savePaymentInformationAndPlaceOrder(
6868
try {
6969
$orderId = $this->cartManagement->placeOrder($cartId);
7070
} catch (\Exception $e) {
71-
throw new CouldNotSaveException(__('Unable to place order. Please try again later.'), $e);
71+
throw new CouldNotSaveException(
72+
__('An error occurred on the server. Please try to place the order again.'),
73+
$e
74+
);
7275
}
7376
return $orderId;
7477
}

app/code/Magento/Checkout/Test/Unit/Model/GuestPaymentInformationManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testSavePaymentInformationAndPlaceOrder()
9393
}
9494

9595
/**
96-
* @expectedExceptionMessage Unable to place order. Please try again later.
96+
* @expectedExceptionMessage An error occurred on the server. Please try to place the order again.
9797
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
9898
*/
9999
public function testSavePaymentInformationAndPlaceOrderException()

0 commit comments

Comments
 (0)