Skip to content

Commit 577b777

Browse files
author
Yaroslav Onischenko
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents e0d29e9 + b7dbda1 commit 577b777

File tree

69 files changed

+1312
-853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1312
-853
lines changed

app/code/Magento/Authorizenet/view/frontend/web/template/payment/authorizenet-directpost.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
allowtransparency="true"
3030
frameborder="0"
3131
name="iframeTransparent"
32-
style="display:none;width:100%;background-color:transparent">
32+
class="payment-method-iframe">
3333

3434
</iframe>
3535
<form class="form" id="co-transparent-form" action="#" method="post" data-bind="mageInit: {

app/code/Magento/BraintreeTwo/Block/Paypal/Button.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\BraintreeTwo\Model\Ui\ConfigProvider;
1313
use Magento\Framework\View\Element\Template\Context;
1414
use Magento\BraintreeTwo\Gateway\Config\PayPal\Config;
15+
use Magento\Payment\Model\MethodInterface;
1516

1617
/**
1718
* Class Button
@@ -42,6 +43,11 @@ class Button extends Template implements ShortcutInterface
4243
*/
4344
private $configProvider;
4445

46+
/**
47+
* @var MethodInterface
48+
*/
49+
private $payment;
50+
4551
/**
4652
* Constructor
4753
*
@@ -50,6 +56,7 @@ class Button extends Template implements ShortcutInterface
5056
* @param Session $checkoutSession
5157
* @param Config $config
5258
* @param ConfigProvider $configProvider
59+
* @param MethodInterface $payment
5360
* @param array $data
5461
*/
5562
public function __construct(
@@ -58,6 +65,7 @@ public function __construct(
5865
Session $checkoutSession,
5966
Config $config,
6067
ConfigProvider $configProvider,
68+
MethodInterface $payment,
6169
array $data = []
6270
) {
6371
parent::__construct($context, $data);
@@ -66,6 +74,7 @@ public function __construct(
6674
$this->checkoutSession = $checkoutSession;
6775
$this->config = $config;
6876
$this->configProvider = $configProvider;
77+
$this->payment = $payment;
6978
}
7079

7180
/**
@@ -125,7 +134,8 @@ public function getAmount()
125134
*/
126135
public function isActive()
127136
{
128-
return $this->config->isActive() && $this->config->isDisplayShoppingCart();
137+
return $this->payment->isAvailable($this->checkoutSession->getQuote()) &&
138+
$this->config->isDisplayShoppingCart();
129139
}
130140

131141
/**

app/code/Magento/BraintreeTwo/etc/frontend/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<item name="alias" xsi:type="string">braintree.paypal.mini-cart</item>
5050
<item name="button_id" xsi:type="string">braintree-paypal-mini-cart</item>
5151
</argument>
52+
<argument name="payment" xsi:type="object">BraintreeTwoPayPalFacade</argument>
5253
</arguments>
5354
</type>
5455
</config>

app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ require([
2929
"jquery/jquery.hashchange",
3030
"mage/mage",
3131
"prototype",
32+
"mage/adminhtml/form",
3233
"domReady!"
3334
], function(jQuery, registry){
3435

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin
192192
*/
193193
protected $_httpClientFactory;
194194

195+
/**
196+
* @inheritdoc
197+
*/
198+
protected $_debugReplacePrivateDataKeys = [
199+
'SiteID', 'Password'
200+
];
201+
195202
/**
196203
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
197204
* @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
@@ -904,37 +911,36 @@ protected function _getQuotes()
904911
{
905912
$responseBody = '';
906913
try {
907-
$debugData = [];
908914
for ($offset = 0; $offset <= self::UNAVAILABLE_DATE_LOOK_FORWARD; $offset++) {
909-
$debugData['try-' . $offset] = [];
910-
$debugPoint = &$debugData['try-' . $offset];
915+
$debugPoint = [];
911916

912917
$requestXml = $this->_buildQuotesRequestXml();
913918
$date = date(self::REQUEST_DATE_FORMAT, strtotime($this->_getShipDate() . " +{$offset} days"));
914919
$this->_setQuotesRequestXmlDate($requestXml, $date);
915920

916921
$request = $requestXml->asXML();
917-
$debugPoint['request'] = $request;
922+
$debugPoint['request'] = $this->filterDebugData($request);
918923
$responseBody = $this->_getCachedQuotes($request);
919924
$debugPoint['from_cache'] = $responseBody === null;
920925

921926
if ($debugPoint['from_cache']) {
922927
$responseBody = $this->_getQuotesFromServer($request);
923928
}
924929

925-
$debugPoint['response'] = $responseBody;
930+
$debugPoint['response'] = $this->filterDebugData($responseBody);
926931

927932
$bodyXml = $this->_xmlElFactory->create(['data' => $responseBody]);
928933
$code = $bodyXml->xpath('//GetQuoteResponse/Note/Condition/ConditionCode');
929934
if (isset($code[0]) && (int)$code[0] == self::CONDITION_CODE_SERVICE_DATE_UNAVAILABLE) {
930935
$debugPoint['info'] = sprintf(__("DHL service is not available at %s date"), $date);
931936
} else {
937+
$this->_debug($debugPoint);
932938
break;
933939
}
934940

935941
$this->_setCachedQuotes($request, $responseBody);
942+
$this->_debug($debugPoint);
936943
}
937-
$this->_debug($debugData);
938944
} catch (\Exception $e) {
939945
$this->_errors[$e->getCode()] = $e->getMessage();
940946
}
@@ -1308,7 +1314,6 @@ public function proccessAdditionalValidation(\Magento\Framework\DataObject $requ
13081314
return $this;
13091315
}
13101316

1311-
13121317
/**
13131318
* Return container types of carrier
13141319
*

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C
119119
*/
120120
protected $_productCollectionFactory;
121121

122+
/**
123+
* @inheritdoc
124+
*/
125+
protected $_debugReplacePrivateDataKeys = [
126+
'Key', 'Password', 'MeterNumber'
127+
];
128+
122129
/**
123130
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
124131
* @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
@@ -454,7 +461,7 @@ protected function _doRatesRequest($purpose)
454461
$ratesRequest = $this->_formRateRequest($purpose);
455462
$requestString = serialize($ratesRequest);
456463
$response = $this->_getCachedQuotes($requestString);
457-
$debugData = ['request' => $ratesRequest];
464+
$debugData = ['request' => $this->filterDebugData($ratesRequest)];
458465
if ($response === null) {
459466
try {
460467
$client = $this->_createRateSoapClient();
@@ -1560,4 +1567,21 @@ public function getDeliveryConfirmationTypes(\Magento\Framework\DataObject $para
15601567
{
15611568
return $this->getCode('delivery_confirmation_types');
15621569
}
1570+
1571+
/**
1572+
* Recursive replace sensitive fields in debug data by the mask
1573+
* @param string $data
1574+
* @return string
1575+
*/
1576+
protected function filterDebugData($data)
1577+
{
1578+
foreach (array_keys($data) as $key) {
1579+
if (is_array($data[$key])) {
1580+
$data[$key] = $this->filterDebugData($data[$key]);
1581+
} elseif (in_array($key, $this->_debugReplacePrivateDataKeys)) {
1582+
$data[$key] = self::DEBUG_KEYS_MASK;
1583+
}
1584+
}
1585+
return $data;
1586+
}
15631587
}

app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
*/
66
namespace Magento\Fedex\Test\Unit\Model;
77

8-
use Magento\Quote\Model\Quote\Address\RateRequest;
8+
use Magento\Fedex\Model\Carrier;
99
use Magento\Framework\DataObject;
1010
use Magento\Framework\Xml\Security;
11+
use Magento\Quote\Model\Quote\Address\RateRequest;
1112

1213
/**
1314
* Class CarrierTest
@@ -212,4 +213,59 @@ public function testCollectRatesErrorMessage()
212213

213214
$this->assertSame($this->error, $this->_model->collectRates($request));
214215
}
216+
217+
/**
218+
* @param string $data
219+
* @param array $maskFields
220+
* @param string $expected
221+
* @dataProvider logDataProvider
222+
*/
223+
public function testFilterDebugData($data, array $maskFields, $expected)
224+
{
225+
$refClass = new \ReflectionClass(Carrier::class);
226+
$property = $refClass->getProperty('_debugReplacePrivateDataKeys');
227+
$property->setAccessible(true);
228+
$property->setValue($this->_model, $maskFields);
229+
230+
$refMethod = $refClass->getMethod('filterDebugData');
231+
$refMethod->setAccessible(true);
232+
$result = $refMethod->invoke($this->_model, $data);
233+
static::assertEquals($expected, $result);
234+
}
235+
236+
/**
237+
* Get list of variations
238+
*/
239+
public function logDataProvider()
240+
{
241+
return [
242+
[
243+
[
244+
'WebAuthenticationDetail' => [
245+
'UserCredential' => [
246+
'Key' => 'testKey',
247+
'Password' => 'testPassword'
248+
]
249+
],
250+
'ClientDetail' => [
251+
'AccountNumber' => 4121213,
252+
'MeterNumber' => 'testMeterNumber'
253+
]
254+
],
255+
['Key', 'Password', 'MeterNumber'],
256+
[
257+
'WebAuthenticationDetail' => [
258+
'UserCredential' => [
259+
'Key' => '****',
260+
'Password' => '****'
261+
]
262+
],
263+
'ClientDetail' => [
264+
'AccountNumber' => 4121213,
265+
'MeterNumber' => '****'
266+
]
267+
],
268+
],
269+
];
270+
}
215271
}

app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Paypal\Block\Express\InContext\Minicart;
77

8+
use Magento\Checkout\Model\Session;
9+
use Magento\Payment\Model\MethodInterface;
810
use Magento\Paypal\Model\Config;
911
use Magento\Paypal\Model\ConfigFactory;
1012
use Magento\Paypal\Block\Express\InContext;
@@ -41,25 +43,40 @@ class Button extends Template implements ShortcutInterface
4143
*/
4244
private $config;
4345

46+
/**
47+
* @var MethodInterface
48+
*/
49+
private $payment;
50+
51+
/**
52+
* @var Session
53+
*/
54+
private $session;
55+
4456
/**
4557
* Constructor
46-
*
4758
* @param Context $context
4859
* @param ResolverInterface $localeResolver
4960
* @param ConfigFactory $configFactory
61+
* @param MethodInterface $payment
62+
* @param Session $session
5063
* @param array $data
5164
*/
5265
public function __construct(
5366
Context $context,
5467
ResolverInterface $localeResolver,
5568
ConfigFactory $configFactory,
69+
Session $session,
70+
MethodInterface $payment,
5671
array $data = []
5772
) {
5873
parent::__construct($context, $data);
5974

6075
$this->localeResolver = $localeResolver;
6176
$this->config = $configFactory->create();
6277
$this->config->setMethod(Config::METHOD_EXPRESS);
78+
$this->payment = $payment;
79+
$this->session = $session;
6380
}
6481

6582
/**
@@ -75,7 +92,9 @@ private function isInContext()
7592
*/
7693
protected function shouldRender()
7794
{
78-
return $this->isMiniCart && $this->isInContext();
95+
return $this->payment->isAvailable($this->session->getQuote())
96+
&& $this->isMiniCart
97+
&& $this->isInContext();
7998
}
8099

81100
/**

app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<rule type="disable" event="activate-rule"/>
3333
</relation>
3434
<relation target=":self">
35-
<rule type="simple/mark-enable" event="activate-rule"/>
36-
<rule type="simple/disable" event="deactivate-rule"/>
35+
<rule type="simpleMarkEnable" event="activate-rule"/>
36+
<rule type="simpleDisable" event="deactivate-rule"/>
3737
<rule type="conflict" event=":load">
3838
<argument name="paypal_payflowpro_au">paypal_payflowpro_au</argument>
3939
<argument name="payments_pro_hosted_solution_au">payments_pro_hosted_solution_au</argument>
@@ -62,8 +62,8 @@
6262
<rule type="disable" event="activate-rule"/>
6363
</relation>
6464
<relation target=":self">
65-
<rule type="simple/mark-enable" event="activate-rule"/>
66-
<rule type="simple/disable" event="deactivate-rule"/>
65+
<rule type="simpleMarkEnable" event="activate-rule"/>
66+
<rule type="simpleDisable" event="deactivate-rule"/>
6767
<rule type="conflict" event=":load">
6868
<argument name="wps_other">wps_other</argument>
6969
<argument name="payments_pro_hosted_solution_au">payments_pro_hosted_solution_au</argument>
@@ -91,8 +91,8 @@
9191
<rule type="disable" event="activate-rule"/>
9292
</relation>
9393
<relation target=":self">
94-
<rule type="simple/mark-enable" event="activate-rule"/>
95-
<rule type="simple/disable" event="deactivate-rule"/>
94+
<rule type="simpleMarkEnable" event="activate-rule"/>
95+
<rule type="simpleDisable" event="deactivate-rule"/>
9696
<rule type="conflict" event=":load">
9797
<argument name="wps_other">wps_other</argument>
9898
<argument name="paypal_payflowpro_au">paypal_payflowpro_au</argument>
@@ -120,15 +120,14 @@
120120
<rule type="disable" event="activate-rule"/>
121121
</relation>
122122
<relation target=":self">
123-
<rule type="simple/mark-enable" event="activate-rule"/>
124-
<rule type="simple/disable" event="deactivate-rule"/>
125-
<rule type="paypal/in-context/enable" event="activate-rule"/>
126-
<rule type="paypal/in-context/disable" event="deactivate-rule"/>
127-
<rule type="paypal/in-context/show-merchant-id" event="activate-rule"/>
128-
<rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/>
129-
<rule type="paypal/in-context/activate" event="activate-in-context-api"/>
130-
<rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/>
131-
<rule type="paypal/in-context/disable-conditional" event=":load"/>
123+
<rule type="simpleMarkEnable" event="activate-rule"/>
124+
<rule type="simpleDisable" event="deactivate-rule"/>
125+
<rule type="inContextDisable" event="deactivate-rule"/>
126+
<rule type="inContextShowMerchantId" event="activate-rule"/>
127+
<rule type="inContextHideMerchantId" event="deactivate-rule"/>
128+
<rule type="inContextActivate" event="activate-in-context-api"/>
129+
<rule type="inContextDeactivate" event="deactivate-in-context-api"/>
130+
<rule type="inContextDisableConditional" event=":load"/>
132131
<rule type="conflict" event=":load">
133132
<argument name="wps_other">wps_other</argument>
134133
</rule>

0 commit comments

Comments
 (0)