Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into MAGETWO-65701
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Korablov committed Mar 15, 2017
2 parents 8175426 + aa93ea8 commit 85a3ef6
Show file tree
Hide file tree
Showing 562 changed files with 3,482 additions and 104 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions app/code/Magento/Braintree/Model/AvsEmsCodeMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Model;

use Magento\Braintree\Model\Ui\ConfigProvider;
use Magento\Braintree\Gateway\Response\PaymentDetailsHandler;
use Magento\Payment\Api\PaymentVerificationInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;

/**
* Processes AVS codes mapping from Braintree transaction to
* electronic merchant systems standard.
*
* @see https://developers.braintreepayments.com/reference/response/transaction
* @see http://www.emsecommerce.net/avs_cvv2_response_codes.htm
*/
class AvsEmsCodeMapper implements PaymentVerificationInterface
{
/**
* Default code for mismatching mapping.
*
* @var string
*/
private static $unavailableCode = 'U';

/**
* List of mapping AVS codes
*
* @var array
*/
private static $avsMap = [
'MM' => 'Y',
'NM' => 'A',
'MN' => 'Z',
'NN' => 'N',
'UU' => 'U',
'II' => 'U',
'AA' => 'E'
];

/**
* Gets payment AVS verification code.
*
* @param OrderPaymentInterface $orderPayment
* @return string
* @throws \InvalidArgumentException If specified order payment has different payment method code.
*/
public function getCode(OrderPaymentInterface $orderPayment)
{
if ($orderPayment->getMethod() !== ConfigProvider::CODE) {
throw new \InvalidArgumentException(
'The "' . $orderPayment->getMethod() . '" does not supported by Braintree AVS mapper.'
);
}

$additionalInfo = $orderPayment->getAdditionalInformation();
if (empty($additionalInfo[PaymentDetailsHandler::AVS_POSTAL_RESPONSE_CODE]) ||
empty($additionalInfo[PaymentDetailsHandler::AVS_STREET_ADDRESS_RESPONSE_CODE])
) {
return self::$unavailableCode;
}

$streetCode = $additionalInfo[PaymentDetailsHandler::AVS_STREET_ADDRESS_RESPONSE_CODE];
$zipCode = $additionalInfo[PaymentDetailsHandler::AVS_POSTAL_RESPONSE_CODE];
$key = $zipCode . $streetCode;
return isset(self::$avsMap[$key]) ? self::$avsMap[$key] : self::$unavailableCode;
}
}
66 changes: 66 additions & 0 deletions app/code/Magento/Braintree/Model/CvvEmsCodeMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Model;

use Magento\Braintree\Gateway\Response\PaymentDetailsHandler;
use Magento\Braintree\Model\Ui\ConfigProvider;
use Magento\Payment\Api\PaymentVerificationInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;

/**
* Processes CVV codes mapping from Braintree transaction to
* electronic merchant systems standard.
*
* @see https://developers.braintreepayments.com/reference/response/transaction
* @see http://www.emsecommerce.net/avs_cvv2_response_codes.htm
*/
class CvvEmsCodeMapper implements PaymentVerificationInterface
{
/**
* Default code for mismatch mapping
*
* @var string
*/
private static $notProvidedCode = 'P';

/**
* List of mapping CVV codes
*
* @var array
*/
private static $cvvMap = [
'M' => 'M',
'N' => 'N',
'U' => 'P',
'I' => 'P',
'S' => 'S',
'A' => ''
];

/**
* Gets payment CVV verification code.
*
* @param OrderPaymentInterface $orderPayment
* @return string
* @throws \InvalidArgumentException If specified order payment has different payment method code.
*/
public function getCode(OrderPaymentInterface $orderPayment)
{
if ($orderPayment->getMethod() !== ConfigProvider::CODE) {
throw new \InvalidArgumentException(
'The "' . $orderPayment->getMethod() . '" does not supported by Braintree CVV mapper.'
);
}

$additionalInfo = $orderPayment->getAdditionalInformation();
if (empty($additionalInfo[PaymentDetailsHandler::CVV_RESPONSE_CODE])) {
return self::$notProvidedCode;
}

$cvv = $additionalInfo[PaymentDetailsHandler::CVV_RESPONSE_CODE];
return isset(self::$cvvMap[$cvv]) ? self::$cvvMap[$cvv] : self::$notProvidedCode;
}
}
101 changes: 101 additions & 0 deletions app/code/Magento/Braintree/Test/Unit/Model/AvsEmsCodeMapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Test\Unit\Model;

use Magento\Braintree\Model\AvsEmsCodeMapper;
use Magento\Braintree\Model\Ui\ConfigProvider;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use PHPUnit_Framework_MockObject_MockObject as MockObject;

class AvsEmsCodeMapperTest extends \PHPUnit_Framework_TestCase
{
/**
* @var AvsEmsCodeMapper
*/
private $mapper;

/**
* @inheritdoc
*/
protected function setUp()
{
$this->mapper = new AvsEmsCodeMapper();
}

/**
* Checks different variations for AVS codes mapping.
*
* @covers \Magento\Braintree\Model\AvsEmsCodeMapper::getCode
* @param string $avsZip
* @param string $avsStreet
* @param string $expected
* @dataProvider getCodeDataProvider
*/
public function testGetCode($avsZip, $avsStreet, $expected)
{
/** @var OrderPaymentInterface|MockObject $orderPayment */
$orderPayment = $this->getMockBuilder(OrderPaymentInterface::class)
->disableOriginalConstructor()
->getMock();

$orderPayment->expects(self::once())
->method('getMethod')
->willReturn(ConfigProvider::CODE);

$orderPayment->expects(self::once())
->method('getAdditionalInformation')
->willReturn([
'avsPostalCodeResponseCode' => $avsZip,
'avsStreetAddressResponseCode' => $avsStreet
]);

self::assertEquals($expected, $this->mapper->getCode($orderPayment));
}

/**
* Checks a test case, when payment order is not Braintree payment method.
*
* @covers \Magento\Braintree\Model\AvsEmsCodeMapper::getCode
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "some_payment" does not supported by Braintree AVS mapper.
*/
public function testGetCodeWithException()
{
/** @var OrderPaymentInterface|MockObject $orderPayment */
$orderPayment = $this->getMockBuilder(OrderPaymentInterface::class)
->disableOriginalConstructor()
->getMock();

$orderPayment->expects(self::exactly(2))
->method('getMethod')
->willReturn('some_payment');

$this->mapper->getCode($orderPayment);
}

/**
* Gets list of AVS codes.
*
* @return array
*/
public function getCodeDataProvider()
{
return [
['avsZip' => null, 'avsStreet' => null, 'expected' => 'U'],
['avsZip' => null, 'avsStreet' => 'M', 'expected' => 'U'],
['avsZip' => 'M', 'avsStreet' => null, 'expected' => 'U'],
['avsZip' => 'M', 'avsStreet' => 'Unknown', 'expected' => 'U'],
['avsZip' => 'I', 'avsStreet' => 'A', 'expected' => 'U'],
['avsZip' => 'M', 'avsStreet' => 'M', 'expected' => 'Y'],
['avsZip' => 'N', 'avsStreet' => 'M', 'expected' => 'A'],
['avsZip' => 'M', 'avsStreet' => 'N', 'expected' => 'Z'],
['avsZip' => 'N', 'avsStreet' => 'N', 'expected' => 'N'],
['avsZip' => 'U', 'avsStreet' => 'U', 'expected' => 'U'],
['avsZip' => 'I', 'avsStreet' => 'I', 'expected' => 'U'],
['avsZip' => 'A', 'avsStreet' => 'A', 'expected' => 'E'],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Test\Unit\Model;

use Magento\Braintree\Model\CvvEmsCodeMapper;
use Magento\Braintree\Model\Ui\ConfigProvider;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use PHPUnit_Framework_MockObject_MockObject as MockObject;

class CvvEmsCodeMapperTest extends \PHPUnit_Framework_TestCase
{
/**
* @var CvvEmsCodeMapper
*/
private $mapper;

/**
* @inheritdoc
*/
protected function setUp()
{
$this->mapper = new CvvEmsCodeMapper();
}

/**
* Checks different variations for cvv codes mapping.
*
* @covers \Magento\Braintree\Model\CvvEmsCodeMapper::getCode
* @param string $cvvCode
* @param string $expected
* @dataProvider getCodeDataProvider
*/
public function testGetCode($cvvCode, $expected)
{
/** @var OrderPaymentInterface|MockObject $orderPayment */
$orderPayment = $this->getMockBuilder(OrderPaymentInterface::class)
->disableOriginalConstructor()
->getMock();

$orderPayment->expects(self::once())
->method('getMethod')
->willReturn(ConfigProvider::CODE);

$orderPayment->expects(self::once())
->method('getAdditionalInformation')
->willReturn(['cvvResponseCode' => $cvvCode]);

self::assertEquals($expected, $this->mapper->getCode($orderPayment));
}

/**
* Checks a test case, when payment order is not Braintree payment method.
*
* @covers \Magento\Braintree\Model\CvvEmsCodeMapper::getCode
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "some_payment" does not supported by Braintree CVV mapper.
*/
public function testGetCodeWithException()
{
/** @var OrderPaymentInterface|MockObject $orderPayment */
$orderPayment = $this->getMockBuilder(OrderPaymentInterface::class)
->disableOriginalConstructor()
->getMock();

$orderPayment->expects(self::exactly(2))
->method('getMethod')
->willReturn('some_payment');

$this->mapper->getCode($orderPayment);
}

/**
* Gets variations of cvv codes and expected mapping result.
*
* @return array
*/
public function getCodeDataProvider()
{
return [
['cvvCode' => '', 'expected' => 'P'],
['cvvCode' => null, 'expected' => 'P'],
['cvvCode' => 'Unknown', 'expected' => 'P'],
['cvvCode' => 'M', 'expected' => 'M'],
['cvvCode' => 'N', 'expected' => 'N'],
['cvvCode' => 'U', 'expected' => 'P'],
['cvvCode' => 'I', 'expected' => 'P'],
['cvvCode' => 'S', 'expected' => 'S'],
['cvvCode' => 'A', 'expected' => ''],
];
}
}
2 changes: 2 additions & 0 deletions app/code/Magento/Braintree/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<masked_fields>cvv,number</masked_fields>
<privateInfoKeys>avsPostalCodeResponseCode,avsStreetAddressResponseCode,cvvResponseCode,processorAuthorizationCode,processorResponseCode,processorResponseText,liabilityShifted,liabilityShiftPossible,riskDataId,riskDataDecision</privateInfoKeys>
<paymentInfoKeys>cc_type,cc_number,avsPostalCodeResponseCode,avsStreetAddressResponseCode,cvvResponseCode,processorAuthorizationCode,processorResponseCode,processorResponseText,liabilityShifted,liabilityShiftPossible,riskDataId,riskDataDecision</paymentInfoKeys>
<avs_ems_adapter>Magento\Braintree\Model\AvsEmsCodeMapper</avs_ems_adapter>
<cvv_ems_adapter>Magento\Braintree\Model\CvvEmsCodeMapper</cvv_ems_adapter>
</braintree>
<braintree_paypal>
<model>BraintreePayPalFacade</model>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/code/Magento/Braintree/view/base/web/images/paypal-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/code/Magento/Braintree/view/base/web/images/paypal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function sendPurgeRequest($tagsPattern)
'1.1',
$headers
);
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'tagsPattern'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public function testSendPurgeRequest($hosts)
$this->socketAdapterMock->expects($this->at($i++))
->method('write')
->with('PURGE', $uri, '1.1', ['X-Magento-Tags-Pattern' => 'tags', 'Host' => $uri->getHost()]);
$this->socketAdapterMock->expects($this->at($i++))
->method('read');
$i++;
}
$this->socketAdapterMock->expects($this->exactly(count($uris)))
Expand Down
Binary file modified app/code/Magento/Captcha/view/adminhtml/web/reload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<argument name="at_call" xsi:type="string">getShortDescription</argument>
<argument name="at_code" xsi:type="string">short_description</argument>
<argument name="css_class" xsi:type="string">overview</argument>
<argument name="at_label" translate="true" xsi:type="string">none</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Overview</argument>
<argument name="add_attribute" xsi:type="string">itemprop="description"</argument>
</arguments>
Expand Down
Binary file modified app/code/Magento/Checkout/view/frontend/web/cvv.png
Binary file modified app/code/Magento/Cms/view/adminhtml/web/images/widget_block.png
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ public function getFinalPrice($qty, $product)
*/
public function getPrice($product)
{
if ($product->getCustomOption('simple_product')) {
return $product->getCustomOption('simple_product')->getProduct()->getPrice();
} else {
return 0;
if (!empty($product)) {
$simpleProductOption = $product->getCustomOption('simple_product');
if (!empty($simpleProductOption)) {
$simpleProduct = $simpleProductOption->getProduct();
if (!empty($simpleProduct)) {
return $simpleProduct->getPrice();
}
}
}
return 0;
}
}
Binary file modified app/code/Magento/Dhl/view/adminhtml/web/logo.jpg
Binary file modified app/code/Magento/Email/view/frontend/web/logo_email.png
Loading

0 comments on commit 85a3ef6

Please sign in to comment.