Skip to content

Commit 7f2b288

Browse files
author
Momotenko,Natalia(nmomotenko)
committed
Merge pull request #529 from magento-mpi/MPI-bugfixes
[MPI] Bugfixes
2 parents 603fcb4 + aea6eee commit 7f2b288

File tree

33 files changed

+753
-445
lines changed

33 files changed

+753
-445
lines changed

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

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88

99
use Magento\Framework\App\ObjectManager;
1010
use Magento\Payment\Block\Transparent\Iframe;
11-
use Magento\Framework\Escaper;
1211

1312
/**
1413
* Class Redirect
1514
*/
1615
class Redirect extends \Magento\Authorizenet\Controller\Directpost\Payment
1716
{
18-
/**
19-
* @var Escaper
20-
*/
21-
private $escaper;
22-
2317
/**
2418
* Retrieve params and put javascript into iframe
2519
*
@@ -29,7 +23,7 @@ public function execute()
2923
{
3024
$helper = $this->dataFactory->create('frontend');
3125

32-
$redirectParams = $this->filterData($this->getRequest()->getParams());
26+
$redirectParams = $this->getRequest()->getParams();
3327
$params = [];
3428
if (!empty($redirectParams['success'])
3529
&& isset($redirectParams['x_invoice_num'])
@@ -38,9 +32,11 @@ public function execute()
3832
$this->_getDirectPostSession()->unsetData('quote_id');
3933
$params['redirect_parent'] = $helper->getSuccessOrderUrl([]);
4034
}
35+
4136
if (!empty($redirectParams['error_msg'])) {
4237
$cancelOrder = empty($redirectParams['x_invoice_num']);
4338
$this->_returnCustomerQuote($cancelOrder, $redirectParams['error_msg']);
39+
$params['error_msg'] = $redirectParams['error_msg'];
4440
}
4541

4642
if (isset($redirectParams['controller_action_name'])
@@ -50,34 +46,8 @@ public function execute()
5046
unset($params['redirect_parent']);
5147
}
5248

53-
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams));
49+
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, $params);
5450
$this->_view->addPageLayoutHandles();
5551
$this->_view->loadLayout(false)->renderLayout();
5652
}
57-
58-
/**
59-
* Escape xss in request data
60-
* @param array $data
61-
* @return array
62-
*/
63-
private function filterData(array $data)
64-
{
65-
$self = $this;
66-
array_walk($data, function (&$item) use ($self) {
67-
$item = $self->getEscaper()->escapeXssInUrl($item);
68-
});
69-
return $data;
70-
}
71-
72-
/**
73-
* Get Escaper instance
74-
* @return Escaper
75-
*/
76-
private function getEscaper()
77-
{
78-
if (!$this->escaper) {
79-
$this->escaper = ObjectManager::getInstance()->get(Escaper::class);
80-
}
81-
return $this->escaper;
82-
}
8353
}

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Authorizenet\Controller\Directpost\Payment\Redirect;
99
use Magento\Framework\App\RequestInterface;
1010
use Magento\Framework\App\ViewInterface;
11-
use Magento\Framework\Escaper;
1211
use Magento\Framework\Registry;
1312
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1413
use Magento\Payment\Block\Transparent\Iframe;
@@ -34,11 +33,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
3433
*/
3534
private $coreRegistry;
3635

37-
/**
38-
* @var Escaper|MockObject
39-
*/
40-
private $escaper;
41-
4236
/**
4337
* @var Redirect
4438
*/
@@ -57,21 +51,11 @@ protected function setUp()
5751
->setMethods(['register'])
5852
->getMock();
5953

60-
$this->escaper = static::getMockBuilder(Escaper::class)
61-
->disableOriginalConstructor()
62-
->setMethods(['escapeXssInUrl'])
63-
->getMock();
64-
6554
$this->controller = $objectManager->getObject(Redirect::class, [
6655
'request' => $this->request,
6756
'view' => $this->view,
6857
'coreRegistry' => $this->coreRegistry
6958
]);
70-
71-
$refClass = new \ReflectionClass(Redirect::class);
72-
$refProperty = $refClass->getProperty('escaper');
73-
$refProperty->setAccessible(true);
74-
$refProperty->setValue($this->controller, $this->escaper);
7559
}
7660

7761
/**
@@ -87,14 +71,9 @@ public function testExecute()
8771
->method('getParams')
8872
->willReturn($params);
8973

90-
$this->escaper->expects(static::once())
91-
->method('escapeXssInUrl')
92-
->with($url)
93-
->willReturn($url);
94-
9574
$this->coreRegistry->expects(static::once())
9675
->method('register')
97-
->with(Iframe::REGISTRY_KEY, $params);
76+
->with(Iframe::REGISTRY_KEY, []);
9877

9978
$this->view->expects(static::once())
10079
->method('addPageLayoutHandles');

app/code/Magento/Braintree/Controller/Payment/GetNonce.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
use Magento\Framework\Controller\ResultInterface;
1313
use Magento\Framework\Session\SessionManagerInterface;
1414
use Magento\Framework\Webapi\Exception;
15-
use Psr\Log\LoggerInterface;
16-
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
17-
use Magento\CheckoutAgreements;
1815
use Magento\Theme;
16+
use Psr\Log\LoggerInterface;
1917

2018
/**
2119
* Class GetNonce

app/code/Magento/Braintree/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
"magento/module-catalog": "*",
1717
"magento/module-quote": "*",
1818
"magento/module-paypal": "*",
19-
"magento/module-checkout-agreements": "*",
2019
"magento/module-theme": "*",
2120
"braintree/braintree_php": "3.7.0"
2221
},
22+
"suggest": {
23+
"magento/module-checkout-agreements": "100.0.*"
24+
},
2325
"type": "magento2-module",
2426
"version": "100.0.2",
2527
"license": [

app/code/Magento/Braintree/etc/module.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<module name="Magento_Catalog"/>
1616
<module name="Magento_Quote"/>
1717
<module name="Magento_Paypal"/>
18-
<module name="Magento_CheckoutAgreements"/>
1918
<module name="Magento_Theme"/>
2019
</sequence>
2120
</module>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ define([
1010
'Magento_Checkout/js/view/payment/default',
1111
'Magento_Braintree/js/view/payment/adapter',
1212
'Magento_Checkout/js/model/quote',
13-
'Magento_Checkout/js/model/full-screen-loader'
14-
], function ($, _, Component, Braintree, quote, fullScreenLoader) {
13+
'Magento_Checkout/js/model/full-screen-loader',
14+
'Magento_Checkout/js/model/payment/additional-validators'
15+
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators) {
1516
'use strict';
1617

1718
var checkout;
@@ -173,7 +174,9 @@ define([
173174
* Triggers when customer click "Continue to PayPal" button
174175
*/
175176
payWithPayPal: function () {
176-
checkout.paypal.initAuthFlow();
177+
if (additionalValidators.validate()) {
178+
checkout.paypal.initAuthFlow();
179+
}
177180
},
178181

179182
/**

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@
131131
</fieldset>
132132
<input type="submit" id="braintree_submit" style="display:none" />
133133
</form>
134+
<div class="checkout-agreements-block">
135+
<!-- ko foreach: $parent.getRegion('before-place-order') -->
136+
<!-- ko template: getTemplate() --><!-- /ko -->
137+
<!--/ko-->
138+
</div>
134139
<div class="actions-toolbar">
135140
<div class="primary">
136141
<button class="action primary checkout"

app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
name="agreement[<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>]"
3434
value="1"
3535
title="<?php echo $block->escapeHtml($agreement->getCheckboxText()) ?>"
36-
class="checkbox""/>
36+
class="checkbox"
37+
data-validate="{required:true}"/>
3738
<label class="label" for="agreement-<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>">
3839
<span><?php echo $agreement->getIsHtml() ? $agreement->getCheckboxText() : $block->escapeHtml($agreement->getCheckboxText()) ?></span>
3940
</label>

app/code/Magento/Payment/view/frontend/templates/transparent/iframe.phtml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
// @codingStandardsIgnoreFile
8+
use Magento\Framework\Json\Helper\Data;
89

910
/** @var \Magento\Payment\Block\Transparent\Iframe $block */
1011
$params = $block->getParams();
@@ -26,6 +27,22 @@ $params = $block->getParams();
2627
parent.location="<?php echo $block->escapeXssInUrl($params['redirect_parent']); ?>";
2728
}
2829
);
30+
<?php elseif (isset($params['error_msg'])): ?>
31+
var require = window.top.require;
32+
require(
33+
[
34+
'jquery',
35+
'Magento_Ui/js/model/messageList',
36+
'mage/translate'
37+
],
38+
function($, globalMessageList, $t) {
39+
var parent = window.top;
40+
$(parent).trigger('clearTimeout');
41+
globalMessageList.addErrorMessage({
42+
message: $t('Unable to place order. Please try again later.')
43+
});
44+
}
45+
);
2946
<?php elseif (isset($params['order_success'])): ?>
3047
window.top.location = "<?php echo $block->escapeXssInUrl($params['order_success']); ?>";
3148
<?php else: ?>

app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-number-validator/credit-card-type.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,20 @@ define(
9191
}
9292
},
9393
{
94-
title: 'Maestro',
94+
title: 'Maestro International',
9595
type: 'MI',
96-
pattern: '^((5((0|[6-9])\\d*)?)|(6|6[37]\\d*))$',
96+
pattern: '^(5(0|[6-9])|63|67(?!59|6770|6774))\\d*$',
97+
gaps: [4, 8, 12],
98+
lengths: [12, 13, 14, 15, 16, 17, 18, 19],
99+
code: {
100+
name: 'CVC',
101+
size: 3
102+
}
103+
},
104+
{
105+
title: 'Maestro Domestic',
106+
type: 'MD',
107+
pattern: '^6759(?!24|38|40|6[3-9]|70|76)|676770|676774\\d*$',
97108
gaps: [4, 8, 12],
98109
lengths: [12, 13, 14, 15, 16, 17, 18, 19],
99110
code: {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\System\Config\Field\Depends;
7+
8+
use Magento\Paypal\Block\Adminhtml\System\Config\Field\Enable\AbstractEnable;
9+
10+
/**
11+
* Class BmlSortOrderApi
12+
*/
13+
class BmlApiSortOrder extends AbstractEnable
14+
{
15+
/**
16+
* Getting the name of a UI attribute
17+
*
18+
* @return string
19+
*/
20+
protected function getDataAttributeName()
21+
{
22+
return 'bml-api-sort-order';
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\System\Config\Field\Depends;
7+
8+
use Magento\Paypal\Block\Adminhtml\System\Config\Field\Enable\AbstractEnable;
9+
10+
/**
11+
* Class BmlSortOrder
12+
*/
13+
class BmlSortOrder extends AbstractEnable
14+
{
15+
/**
16+
* Getting the name of a UI attribute
17+
*
18+
* @return string
19+
*/
20+
protected function getDataAttributeName()
21+
{
22+
return 'bml-sort-order';
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\System\Config\Field\Depends;
7+
8+
use Magento\Paypal\Block\Adminhtml\System\Config\Field\Enable\AbstractEnable;
9+
10+
/**
11+
* Class MerchantId
12+
*/
13+
class MerchantId extends AbstractEnable
14+
{
15+
/**
16+
* Getting the name of a UI attribute
17+
*
18+
* @return string
19+
*/
20+
protected function getDataAttributeName()
21+
{
22+
return 'merchant-id';
23+
}
24+
}

app/code/Magento/Paypal/Block/Adminhtml/System/Config/ResolutionRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public function __construct(
4242
*/
4343
public function getJson()
4444
{
45-
return json_encode($this->rulesReader->read());
45+
return json_encode($this->rulesReader->read(), JSON_FORCE_OBJECT);
4646
}
4747
}

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,12 @@ public function updateShippingMethod($methodCode)
756756
if ($methodCode != $shippingAddress->getShippingMethod()) {
757757
$this->ignoreAddressValidation();
758758
$shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
759+
$cartExtension = $this->_quote->getExtensionAttributes();
760+
if ($cartExtension && $cartExtension->getShippingAssignments()) {
761+
$cartExtension->getShippingAssignments()[0]
762+
->getShipping()
763+
->setMethod($methodCode);
764+
}
759765
$this->_quote->collectTotals();
760766
$this->quoteRepository->save($this->_quote);
761767
}

0 commit comments

Comments
 (0)