Skip to content

Commit d5644db

Browse files
committed
Merge remote-tracking branch 'mpi/MPI-PR-Bugfixes' into PRS
2 parents c17c5df + 4d86238 commit d5644db

File tree

50 files changed

+1845
-580
lines changed

Some content is hidden

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

50 files changed

+1845
-580
lines changed

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,11 @@ protected function processPaymentFraudStatus(\Magento\Sales\Model\Order\Payment
744744
return $this;
745745
}
746746

747-
$payment->setIsFraudDetected(true);
747+
$fdsFilterAction = (string)$fraudDetailsResponse->getFdsFilterAction();
748+
if ($this->fdsFilterActionIsReportOnly($fdsFilterAction) === false) {
749+
$payment->setIsFraudDetected(true);
750+
}
751+
748752
$payment->setAdditionalInformation('fraud_details', $fraudData);
749753
} catch (\Exception $e) {
750754
//this request is optional
@@ -989,4 +993,16 @@ private function getPsrLogger()
989993
}
990994
return $this->psrLogger;
991995
}
996+
997+
/**
998+
* Checks if filter action is Report Only. Transactions that trigger this filter are processed as normal,
999+
* but are also reported in the Merchant Interface as triggering this filter.
1000+
*
1001+
* @param string $fdsFilterAction
1002+
* @return bool
1003+
*/
1004+
private function fdsFilterActionIsReportOnly($fdsFilterAction)
1005+
{
1006+
return $fdsFilterAction === (string)$this->dataHelper->getFdsFilterActionLabel('report');
1007+
}
9921008
}

app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
140140
*/
141141
order.addExcludedPaymentMethod('<?= /* @noEscape */ $code ?>');
142142

143-
<?php if (!$block->isAjaxRequest()): ?>
144-
document.observe('dom:loaded', function(){
145-
<?php endif; ?>
146-
147143
directPostModel = new directPost(
148144
'<?= /* @noEscape */ $code ?>',
149145
'directpost-iframe',
@@ -153,9 +149,5 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
153149
'<?= $block->escapeUrl($block->getUrl('*/*/save', [
154150
'_secure' => $block->getRequest()->isSecure()
155151
]));?>');
156-
157-
<?php if (!$block->isAjaxRequest()): ?>
158-
});
159-
<?php endif; ?>
160152
});
161153
</script>

app/code/Magento/Braintree/Gateway/Request/ChannelDataBuilder.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55
*/
66
namespace Magento\Braintree\Gateway\Request;
77

8-
use Magento\Payment\Gateway\Request\BuilderInterface;
8+
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\App\ProductMetadataInterface;
10+
use Magento\Payment\Gateway\Config\Config;
11+
use Magento\Payment\Gateway\Request\BuilderInterface;
1012

1113
/**
1214
* Class BnCodeDataBuilder
1315
*/
1416
class ChannelDataBuilder implements BuilderInterface
1517
{
16-
/**
17-
* @var ProductMetadataInterface
18-
*/
19-
private $productMetadata;
20-
2118
/**
2219
* @var string
2320
*/
@@ -28,23 +25,36 @@ class ChannelDataBuilder implements BuilderInterface
2825
*/
2926
private static $channelValue = 'Magento2_Cart_%s_BT';
3027

28+
/**
29+
* @var ProductMetadataInterface
30+
*/
31+
private $productMetadata;
32+
33+
/**
34+
* @var Config
35+
*/
36+
private $config;
37+
3138
/**
3239
* Constructor
3340
*
3441
* @param ProductMetadataInterface $productMetadata
42+
* @param Config $config
3543
*/
36-
public function __construct(ProductMetadataInterface $productMetadata)
44+
public function __construct(ProductMetadataInterface $productMetadata, Config $config = null)
3745
{
3846
$this->productMetadata = $productMetadata;
47+
$this->config = $config ?: ObjectManager::getInstance()->get(Config::class);
3948
}
4049

4150
/**
4251
* @inheritdoc
4352
*/
4453
public function build(array $buildSubject)
4554
{
55+
$channel = $this->config->getValue('channel');
4656
return [
47-
self::$channel => sprintf(self::$channelValue, $this->productMetadata->getEdition())
57+
self::$channel => $channel ?: sprintf(self::$channelValue, $this->productMetadata->getEdition())
4858
];
4959
}
5060
}

app/code/Magento/Braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
use Magento\Braintree\Gateway\Request\ChannelDataBuilder;
99
use Magento\Framework\App\ProductMetadataInterface;
10+
use Magento\Payment\Gateway\Config\Config;
11+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1012

1113
/**
1214
* Class PaymentDataBuilderTest
@@ -16,19 +18,32 @@
1618
class ChannelDataBuilderTest extends \PHPUnit_Framework_TestCase
1719
{
1820
/**
19-
* @var ProductMetadataInterface|\PHPUnit_Framework_MockObject_MockObject
21+
* @var ProductMetadataInterface|MockObject
2022
*/
21-
private $productMetadataMock;
23+
private $productMetadata;
24+
25+
/**
26+
* @var Config|MockObject
27+
*/
28+
private $config;
2229

2330
/**
2431
* @var ChannelDataBuilder
2532
*/
2633
private $builder;
2734

35+
/**
36+
* @inheritdoc
37+
*/
2838
protected function setUp()
2939
{
30-
$this->productMetadataMock = $this->getMock(ProductMetadataInterface::class);
31-
$this->builder = new ChannelDataBuilder($this->productMetadataMock);
40+
$this->productMetadata = $this->getMockBuilder(ProductMetadataInterface::class)
41+
->disableOriginalConstructor()
42+
->getMock();
43+
$this->config = $this->getMockBuilder(Config::class)
44+
->disableOriginalConstructor()
45+
->getMock();
46+
$this->builder = new ChannelDataBuilder($this->productMetadata, $this->config);
3247
}
3348

3449
/**
@@ -40,11 +55,37 @@ protected function setUp()
4055
public function testBuild($edition, array $expected)
4156
{
4257
$buildSubject = [];
43-
$this->productMetadataMock->expects(static::once())
44-
->method('getEdition')
58+
59+
$this->config->method('getValue')
60+
->with(self::equalTo('channel'))
61+
->willReturn(null);
62+
63+
$this->productMetadata->method('getEdition')
4564
->willReturn($edition);
4665

47-
$this->assertEquals($expected, $this->builder->build($buildSubject));
66+
self::assertEquals($expected, $this->builder->build($buildSubject));
67+
}
68+
69+
/**
70+
* Checks a case when a channel provided via payment method configuration.
71+
*/
72+
public function testBuildWithChannelFromConfig()
73+
{
74+
$channel = 'Magento2_Cart_ConfigEdition_BT';
75+
76+
$this->config->method('getValue')
77+
->with(self::equalTo('channel'))
78+
->willReturn($channel);
79+
80+
$this->productMetadata->expects(self::never())
81+
->method('getEdition');
82+
83+
self::assertEquals(
84+
[
85+
'channel' => $channel
86+
],
87+
$this->builder->build([])
88+
);
4889
}
4990

5091
/**

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@
187187
</type>
188188
<!-- END command managers section for Vault -->
189189

190+
<type name="Magento\Braintree\Gateway\Request\ChannelDataBuilder">
191+
<arguments>
192+
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
193+
</arguments>
194+
</type>
195+
190196
<!-- Braintree commands -->
191197
<virtualType name="BraintreeAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
192198
<arguments>

app/code/Magento/Dhl/Block/Adminhtml/Unitofmeasure.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,12 @@ public function _construct()
7171
)
7272
);
7373

74-
$weight = round(
75-
$this->carrierHelper->convertMeasureWeight(
76-
$kgWeight,
77-
\Zend_Measure_Weight::KILOGRAM,
78-
\Zend_Measure_Weight::POUND
79-
),
80-
3
74+
$convertedWeight = $this->carrierHelper->convertMeasureWeight(
75+
$kgWeight,
76+
\Zend_Measure_Weight::KILOGRAM,
77+
\Zend_Measure_Weight::POUND
8178
);
79+
$weight = sprintf('%.3f', $convertedWeight);
8280

8381
$this->setDivideOrderWeightNoteLbp(
8482
__(

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public function setRequest(\Magento\Framework\DataObject $request)
422422

423423
$shippingWeight = $request->getPackageWeight();
424424

425-
$requestObject->setValue(round($request->getPackageValue(), 2))
425+
$requestObject->setValue(sprintf('%.2f', $request->getPackageValue()))
426426
->setValueWithDiscount($request->getPackageValueWithDiscount())
427427
->setCustomsValue($request->getPackageCustomsValue())
428428
->setDestStreet($this->string->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35))
@@ -670,13 +670,13 @@ protected function _getWeight($weight, $maxWeight = false, $configWeightUnit = f
670670

671671
if ($configWeightUnit != $countryWeightUnit) {
672672
$weight = $this->_carrierHelper->convertMeasureWeight(
673-
round($weight, 3),
673+
sprintf('%.3f', $weight),
674674
$configWeightUnit,
675675
$countryWeightUnit
676676
);
677677
}
678678

679-
return round($weight, 3);
679+
return sprintf('%.3f', $weight);
680680
}
681681

682682
/**
@@ -806,7 +806,7 @@ protected function _makePieces(\Magento\Shipping\Model\Simplexml\Element $nodeBk
806806
$nodePiece = $nodePieces->addChild('Piece', '', '');
807807
$nodePiece->addChild('PieceID', $numberOfPieces);
808808
$this->_addDimension($nodePiece);
809-
$nodePiece->addChild('Weight', $sumWeight);
809+
$nodePiece->addChild('Weight', sprintf('%.3f', $sumWeight));
810810
break;
811811
} else {
812812
unset($items[$key]);
@@ -815,7 +815,7 @@ protected function _makePieces(\Magento\Shipping\Model\Simplexml\Element $nodeBk
815815
$nodePiece = $nodePieces->addChild('Piece', '', '');
816816
$nodePiece->addChild('PieceID', $numberOfPieces);
817817
$this->_addDimension($nodePiece);
818-
$nodePiece->addChild('Weight', $sumWeight);
818+
$nodePiece->addChild('Weight', sprintf('%.3f', $sumWeight));
819819
$sumWeight = 0;
820820
break;
821821
}
@@ -826,7 +826,7 @@ protected function _makePieces(\Magento\Shipping\Model\Simplexml\Element $nodeBk
826826
$nodePiece = $nodePieces->addChild('Piece', '', '');
827827
$nodePiece->addChild('PieceID', $numberOfPieces);
828828
$this->_addDimension($nodePiece);
829-
$nodePiece->addChild('Weight', $sumWeight);
829+
$nodePiece->addChild('Weight', sprintf('%.3f', $sumWeight));
830830
}
831831
} else {
832832
$nodePiece = $nodePieces->addChild('Piece', '', '');
@@ -870,13 +870,13 @@ protected function _getDimension($dimension, $configWeightUnit = false)
870870

871871
if ($configDimensionUnit != $countryDimensionUnit) {
872872
$dimension = $this->_carrierHelper->convertMeasureDimension(
873-
round($dimension, 3),
873+
sprintf('%.3f', $dimension),
874874
$configDimensionUnit,
875875
$countryDimensionUnit
876876
);
877877
}
878878

879-
return round($dimension, 3);
879+
return sprintf('%.3f', $dimension);
880880
}
881881

882882
/**
@@ -1614,7 +1614,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
16141614
}
16151615
$nodePiece->addChild('PieceID', ++$i);
16161616
$nodePiece->addChild('PackageType', $packageType);
1617-
$nodePiece->addChild('Weight', round($package['params']['weight'], 1));
1617+
$nodePiece->addChild('Weight', sprintf('%.1f', $package['params']['weight']));
16181618
$params = $package['params'];
16191619
if ($params['width'] && $params['length'] && $params['height']) {
16201620
if (!$originRegion) {
@@ -1635,7 +1635,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
16351635
}
16361636

16371637
if (!$originRegion) {
1638-
$nodeShipmentDetails->addChild('Weight', round($rawRequest->getPackageWeight(), 1));
1638+
$nodeShipmentDetails->addChild('Weight', sprintf('%.1f', $rawRequest->getPackageWeight()));
16391639
$nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1));
16401640
$nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod());
16411641
$nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod());

0 commit comments

Comments
 (0)