- = $block->escapeHtml('Error:'); ?>
+ = $block->escapeHtml(__('Error:')); ?>
= /* @noEscape */ $block->getAddressError($address); ?>
diff --git a/app/code/Magento/Multishipping/view/frontend/templates/checkout/success.phtml b/app/code/Magento/Multishipping/view/frontend/templates/checkout/success.phtml
index c8e7c375089cd..57c4afaee6541 100644
--- a/app/code/Magento/Multishipping/view/frontend/templates/checkout/success.phtml
+++ b/app/code/Magento/Multishipping/view/frontend/templates/checkout/success.phtml
@@ -22,7 +22,7 @@
getCheckoutData()->getOrderShippingAddress($orderId); ?>
- = $block->escapeHtml('Ship to:'); ?>
+ = $block->escapeHtml(__('Ship to:')); ?>
= $block->escapeHtml(
$block->getCheckoutData()->formatOrderShippingAddress($shippingAddress)
diff --git a/app/code/Magento/Paypal/Controller/Express/AbstractExpress/PlaceOrder.php b/app/code/Magento/Paypal/Controller/Express/AbstractExpress/PlaceOrder.php
index f0fce97da512a..055af4162d5f3 100644
--- a/app/code/Magento/Paypal/Controller/Express/AbstractExpress/PlaceOrder.php
+++ b/app/code/Magento/Paypal/Controller/Express/AbstractExpress/PlaceOrder.php
@@ -21,6 +21,11 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress
*/
protected $agreementsValidator;
+ /**
+ * @var \Magento\Sales\Api\PaymentFailuresInterface
+ */
+ private $paymentFailures;
+
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Customer\Model\Session $customerSession
@@ -31,6 +36,8 @@ class PlaceOrder extends \Magento\Paypal\Controller\Express\AbstractExpress
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param \Magento\Customer\Model\Url $customerUrl
* @param \Magento\Checkout\Api\AgreementsValidatorInterface $agreementValidator
+ * @param \Magento\Sales\Api\PaymentFailuresInterface|null $paymentFailures
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
@@ -41,9 +48,9 @@ public function __construct(
\Magento\Framework\Session\Generic $paypalSession,
\Magento\Framework\Url\Helper\Data $urlHelper,
\Magento\Customer\Model\Url $customerUrl,
- \Magento\Checkout\Api\AgreementsValidatorInterface $agreementValidator
+ \Magento\Checkout\Api\AgreementsValidatorInterface $agreementValidator,
+ \Magento\Sales\Api\PaymentFailuresInterface $paymentFailures = null
) {
- $this->agreementsValidator = $agreementValidator;
parent::__construct(
$context,
$customerSession,
@@ -54,6 +61,11 @@ public function __construct(
$urlHelper,
$customerUrl
);
+
+ $this->agreementsValidator = $agreementValidator;
+ $this->paymentFailures = $paymentFailures ? : $this->_objectManager->get(
+ \Magento\Sales\Api\PaymentFailuresInterface::class
+ );
}
/**
@@ -148,6 +160,8 @@ private function processException(\Exception $exception, string $message): void
*/
protected function _processPaypalApiError($exception)
{
+ $this->paymentFailures->handle((int)$this->_getCheckoutSession()->getQuoteId(), $exception->getMessage());
+
switch ($exception->getCode()) {
case ApiProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED:
case ApiProcessableException::API_TRANSACTION_EXPIRED:
diff --git a/app/code/Magento/Paypal/Controller/Payflow.php b/app/code/Magento/Paypal/Controller/Payflow.php
index ab21986bde3ba..78c0536e393ac 100644
--- a/app/code/Magento/Paypal/Controller/Payflow.php
+++ b/app/code/Magento/Paypal/Controller/Payflow.php
@@ -41,6 +41,11 @@ abstract class Payflow extends \Magento\Framework\App\Action\Action
*/
protected $_redirectBlockName = 'payflow.link.iframe';
+ /**
+ * @var \Magento\Sales\Api\PaymentFailuresInterface
+ */
+ private $paymentFailures;
+
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Checkout\Model\Session $checkoutSession
@@ -48,6 +53,7 @@ abstract class Payflow extends \Magento\Framework\App\Action\Action
* @param \Magento\Paypal\Model\PayflowlinkFactory $payflowModelFactory
* @param \Magento\Paypal\Helper\Checkout $checkoutHelper
* @param \Psr\Log\LoggerInterface $logger
+ * @param \Magento\Sales\Api\PaymentFailuresInterface|null $paymentFailures
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
@@ -55,14 +61,19 @@ public function __construct(
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Paypal\Model\PayflowlinkFactory $payflowModelFactory,
\Magento\Paypal\Helper\Checkout $checkoutHelper,
- \Psr\Log\LoggerInterface $logger
+ \Psr\Log\LoggerInterface $logger,
+ \Magento\Sales\Api\PaymentFailuresInterface $paymentFailures = null
) {
+ parent::__construct($context);
+
$this->_checkoutSession = $checkoutSession;
$this->_orderFactory = $orderFactory;
$this->_logger = $logger;
$this->_payflowModelFactory = $payflowModelFactory;
$this->_checkoutHelper = $checkoutHelper;
- parent::__construct($context);
+ $this->paymentFailures = $paymentFailures ?: $this->_objectManager->get(
+ \Magento\Sales\Api\PaymentFailuresInterface::class
+ );
}
/**
@@ -74,6 +85,10 @@ public function __construct(
protected function _cancelPayment($errorMsg = '')
{
$errorMsg = trim(strip_tags($errorMsg));
+ $order = $this->_checkoutSession->getLastRealOrder();
+ if ($order->getId()) {
+ $this->paymentFailures->handle((int)$order->getQuoteId(), $errorMsg);
+ }
$gotoSection = false;
$this->_checkoutHelper->cancelCurrentOrder($errorMsg);
diff --git a/app/code/Magento/Paypal/Controller/Transparent/Response.php b/app/code/Magento/Paypal/Controller/Transparent/Response.php
index 23ac20ca8c87b..c54dd529588b9 100644
--- a/app/code/Magento/Paypal/Controller/Transparent/Response.php
+++ b/app/code/Magento/Paypal/Controller/Transparent/Response.php
@@ -14,6 +14,8 @@
use Magento\Paypal\Model\Payflow\Service\Response\Transaction;
use Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator;
use Magento\Paypal\Model\Payflow\Transparent;
+use Magento\Sales\Api\PaymentFailuresInterface;
+use Magento\Framework\Session\Generic as Session;
/**
* Class Response
@@ -47,6 +49,16 @@ class Response extends \Magento\Framework\App\Action\Action
*/
private $transparent;
+ /**
+ * @var PaymentFailuresInterface
+ */
+ private $paymentFailures;
+
+ /**
+ * @var Session
+ */
+ private $sessionTransparent;
+
/**
* Constructor
*
@@ -56,6 +68,8 @@ class Response extends \Magento\Framework\App\Action\Action
* @param ResponseValidator $responseValidator
* @param LayoutFactory $resultLayoutFactory
* @param Transparent $transparent
+ * @param Session|null $sessionTransparent
+ * @param PaymentFailuresInterface|null $paymentFailures
*/
public function __construct(
Context $context,
@@ -63,7 +77,9 @@ public function __construct(
Transaction $transaction,
ResponseValidator $responseValidator,
LayoutFactory $resultLayoutFactory,
- Transparent $transparent
+ Transparent $transparent,
+ Session $sessionTransparent = null,
+ PaymentFailuresInterface $paymentFailures = null
) {
parent::__construct($context);
$this->coreRegistry = $coreRegistry;
@@ -71,6 +87,8 @@ public function __construct(
$this->responseValidator = $responseValidator;
$this->resultLayoutFactory = $resultLayoutFactory;
$this->transparent = $transparent;
+ $this->sessionTransparent = $sessionTransparent ?: $this->_objectManager->get(Session::class);
+ $this->paymentFailures = $paymentFailures ?: $this->_objectManager->get(PaymentFailuresInterface::class);
}
/**
@@ -86,6 +104,7 @@ public function execute()
} catch (LocalizedException $exception) {
$parameters['error'] = true;
$parameters['error_msg'] = $exception->getMessage();
+ $this->paymentFailures->handle((int)$this->sessionTransparent->getQuoteId(), $parameters['error_msg']);
}
$this->coreRegistry->register(Iframe::REGISTRY_KEY, $parameters);
diff --git a/app/code/Magento/Paypal/Model/Payflow/AvsEmsCodeMapper.php b/app/code/Magento/Paypal/Model/Payflow/AvsEmsCodeMapper.php
index 661d1f3814a0b..1ec7f4832bcb2 100644
--- a/app/code/Magento/Paypal/Model/Payflow/AvsEmsCodeMapper.php
+++ b/app/code/Magento/Paypal/Model/Payflow/AvsEmsCodeMapper.php
@@ -24,7 +24,7 @@ class AvsEmsCodeMapper implements PaymentVerificationInterface
*
* @var string
*/
- private static $unavailableCode = 'U';
+ private static $unavailableCode = '';
/**
* List of mapping AVS codes
diff --git a/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php b/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php
index 9d215ca6cbe17..da5599984b701 100644
--- a/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php
+++ b/app/code/Magento/Paypal/Model/Payflow/Service/Request/SecureToken.php
@@ -11,7 +11,6 @@
use Magento\Paypal\Model\Payflow\Transparent;
use Magento\Paypal\Model\Payflowpro;
use Magento\Quote\Model\Quote;
-use Magento\Sales\Model\Order\Payment;
/**
* Class SecureToken
@@ -59,6 +58,7 @@ public function __construct(
*/
public function requestToken(Quote $quote)
{
+ $this->transparent->setStore($quote->getStoreId());
$request = $this->transparent->buildBasicRequest();
$request->setTrxtype(Payflowpro::TRXTYPE_AUTH_ONLY);
diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php
index 792309bd76cf9..1955ef3c67661 100644
--- a/app/code/Magento/Paypal/Model/Payflowlink.php
+++ b/app/code/Magento/Paypal/Model/Payflowlink.php
@@ -10,6 +10,7 @@
use Magento\Payment\Model\Method\ConfigInterfaceFactory;
use Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;
+use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
/**
@@ -239,11 +240,13 @@ public function initialize($paymentAction, $stateObject)
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH:
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_SALE:
$payment = $this->getInfoInstance();
+ /** @var Order $order */
$order = $payment->getOrder();
$order->setCanSendNewEmailFlag(false);
$payment->setAmountAuthorized($order->getTotalDue());
$payment->setBaseAmountAuthorized($order->getBaseTotalDue());
$this->_generateSecureSilentPostHash($payment);
+ $this->setStore($order->getStoreId());
$request = $this->_buildTokenRequest($payment);
$response = $this->postRequest($request, $this->getConfig());
$this->_processTokenErrors($response, $payment);
diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php
index 125aa0f6e65a7..b5fdaf4ae9fd4 100644
--- a/app/code/Magento/Paypal/Model/Payflowpro.php
+++ b/app/code/Magento/Paypal/Model/Payflowpro.php
@@ -647,7 +647,7 @@ public function buildBasicRequest()
*
* @param DataObject $response
* @return void
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws \Magento\Payment\Gateway\Command\CommandException
* @throws \Magento\Framework\Exception\State\InvalidTransitionException
*/
public function processErrors(DataObject $response)
@@ -659,9 +659,9 @@ public function processErrors(DataObject $response)
} elseif ($response->getResultCode() != self::RESPONSE_CODE_APPROVED &&
$response->getResultCode() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER
) {
- throw new \Magento\Framework\Exception\LocalizedException(__($response->getRespmsg()));
+ throw new \Magento\Payment\Gateway\Command\CommandException(__($response->getRespmsg()));
} elseif ($response->getOrigresult() == self::RESPONSE_CODE_DECLINED_BY_FILTER) {
- throw new \Magento\Framework\Exception\LocalizedException(__($response->getRespmsg()));
+ throw new \Magento\Payment\Gateway\Command\CommandException(__($response->getRespmsg()));
}
}
diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Payflow/ReturnUrlTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Payflow/ReturnUrlTest.php
index e25864bbc2f3c..bd4da25cb84d0 100644
--- a/app/code/Magento/Paypal/Test/Unit/Controller/Payflow/ReturnUrlTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Controller/Payflow/ReturnUrlTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Paypal\Test\Unit\Controller\Payflow;
+use Magento\Sales\Api\PaymentFailuresInterface;
use Magento\Checkout\Block\Onepage\Success;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\Context;
@@ -90,6 +91,11 @@ class ReturnUrlTest extends \PHPUnit\Framework\TestCase
*/
private $objectManager;
+ /**
+ * @var PaymentFailuresInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $paymentFailures;
+
/**
* @inheritdoc
*/
@@ -138,6 +144,17 @@ protected function setUp()
->setMethods(['getLastRealOrderId', 'getLastRealOrder', 'restoreQuote'])
->getMock();
+ $this->quote = $this->getMockBuilder(CartInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->context->expects($this->any())->method('getView')->willReturn($this->view);
+ $this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
+
+ $this->paymentFailures = $this->getMockBuilder(PaymentFailuresInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->context->method('getView')
->willReturn($this->view);
$this->context->method('getRequest')
@@ -148,6 +165,7 @@ protected function setUp()
'checkoutSession' => $this->checkoutSession,
'orderFactory' => $this->orderFactory,
'checkoutHelper' => $this->checkoutHelper,
+ 'paymentFailures' => $this->paymentFailures,
]);
}
@@ -321,6 +339,7 @@ public function testCheckAdvancedAcceptingByPaymentMethod()
'checkoutSession' => $this->checkoutSession,
'orderFactory' => $this->orderFactory,
'checkoutHelper' => $this->checkoutHelper,
+ 'paymentFailures' => $this->paymentFailures,
]);
$returnUrl->execute();
diff --git a/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php b/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php
index a10d103860c65..acefebb779200 100644
--- a/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Controller/Transparent/ResponseTest.php
@@ -8,16 +8,16 @@
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Registry;
+use Magento\Framework\Session\Generic as Session;
use Magento\Framework\View\Result\Layout;
use Magento\Framework\View\Result\LayoutFactory;
use Magento\Paypal\Controller\Transparent\Response;
use Magento\Paypal\Model\Payflow\Service\Response\Transaction;
use Magento\Paypal\Model\Payflow\Service\Response\Validator\ResponseValidator;
use Magento\Paypal\Model\Payflow\Transparent;
+use Magento\Sales\Api\PaymentFailuresInterface;
/**
- * Class ResponseTest
- *
* Test for class \Magento\Paypal\Controller\Transparent\Response
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -53,6 +53,19 @@ class ResponseTest extends \PHPUnit\Framework\TestCase
*/
private $payflowFacade;
+ /**
+ * @var PaymentFailuresInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $paymentFailures;
+
+ /**
+ * @var Session|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $sessionTransparent;
+
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
$this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
@@ -97,6 +110,14 @@ protected function setUp()
->disableOriginalConstructor()
->setMethods([])
->getMock();
+ $this->paymentFailures = $this->getMockBuilder(PaymentFailuresInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['handle'])
+ ->getMock();
+ $this->sessionTransparent = $this->getMockBuilder(Session::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getQuoteId'])
+ ->getMock();
$this->object = new Response(
$this->contextMock,
@@ -104,7 +125,9 @@ protected function setUp()
$this->transactionMock,
$this->responseValidatorMock,
$this->resultLayoutFactoryMock,
- $this->payflowFacade
+ $this->payflowFacade,
+ $this->sessionTransparent,
+ $this->paymentFailures
);
}
@@ -131,6 +154,8 @@ public function testExecute()
$this->resultLayoutMock->expects($this->once())
->method('getLayout')
->willReturn($this->getLayoutMock());
+ $this->paymentFailures->expects($this->never())
+ ->method('handle');
$this->assertInstanceOf(\Magento\Framework\Controller\ResultInterface::class, $this->object->execute());
}
@@ -156,6 +181,12 @@ public function testExecuteWithException()
$this->resultLayoutMock->expects($this->once())
->method('getLayout')
->willReturn($this->getLayoutMock());
+ $this->sessionTransparent->method('getQuoteId')
+ ->willReturn(1);
+ $this->paymentFailures->expects($this->once())
+ ->method('handle')
+ ->with(1)
+ ->willReturnSelf();
$this->assertInstanceOf(\Magento\Framework\Controller\ResultInterface::class, $this->object->execute());
}
diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/AvsEmsCodeMapperTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/AvsEmsCodeMapperTest.php
index eb259043a2d4f..ea86a04206f7b 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/AvsEmsCodeMapperTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/AvsEmsCodeMapperTest.php
@@ -85,17 +85,17 @@ public function testGetCodeWithException()
public function getCodeDataProvider()
{
return [
- ['avsZip' => null, 'avsStreet' => null, 'expected' => 'U'],
- ['avsZip' => null, 'avsStreet' => 'Y', 'expected' => 'U'],
- ['avsZip' => 'Y', 'avsStreet' => null, 'expected' => 'U'],
+ ['avsZip' => null, 'avsStreet' => null, 'expected' => ''],
+ ['avsZip' => null, 'avsStreet' => 'Y', 'expected' => ''],
+ ['avsZip' => 'Y', 'avsStreet' => null, 'expected' => ''],
['avsZip' => 'Y', 'avsStreet' => 'Y', 'expected' => 'Y'],
['avsZip' => 'N', 'avsStreet' => 'Y', 'expected' => 'A'],
['avsZip' => 'Y', 'avsStreet' => 'N', 'expected' => 'Z'],
['avsZip' => 'N', 'avsStreet' => 'N', 'expected' => 'N'],
- ['avsZip' => 'X', 'avsStreet' => 'Y', 'expected' => 'U'],
- ['avsZip' => 'N', 'avsStreet' => 'X', 'expected' => 'U'],
- ['avsZip' => '', 'avsStreet' => 'Y', 'expected' => 'U'],
- ['avsZip' => 'N', 'avsStreet' => '', 'expected' => 'U']
+ ['avsZip' => 'X', 'avsStreet' => 'Y', 'expected' => ''],
+ ['avsZip' => 'N', 'avsStreet' => 'X', 'expected' => ''],
+ ['avsZip' => '', 'avsStreet' => 'Y', 'expected' => ''],
+ ['avsZip' => 'N', 'avsStreet' => '', 'expected' => '']
];
}
}
diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php
index d4a7db25cae89..d8e54ad28fcc8 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/Payflow/Service/Request/SecureTokenTest.php
@@ -10,6 +10,9 @@
use Magento\Framework\UrlInterface;
use Magento\Paypal\Model\Payflow\Service\Request\SecureToken;
use Magento\Paypal\Model\Payflow\Transparent;
+use Magento\Paypal\Model\PayflowConfig;
+use Magento\Quote\Model\Quote;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Test class for \Magento\Paypal\Model\Payflow\Service\Request\SecureToken
@@ -19,23 +22,26 @@ class SecureTokenTest extends \PHPUnit\Framework\TestCase
/**
* @var SecureToken
*/
- protected $model;
+ private $model;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Transparent
+ * @var Transparent|MockObject
*/
- protected $transparent;
+ private $transparent;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|Random
+ * @var Random|MockObject
*/
- protected $mathRandom;
+ private $mathRandom;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|UrlInterface
+ * @var UrlInterface|MockObject
*/
- protected $url;
+ private $url;
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
$this->url = $this->createMock(\Magento\Framework\UrlInterface::class);
@@ -52,11 +58,29 @@ protected function setUp()
public function testRequestToken()
{
$request = new DataObject();
+ $storeId = 1;
$secureTokenID = 'Sdj46hDokds09c8k2klaGJdKLl032ekR';
+ $response = new DataObject([
+ 'result' => '0',
+ 'respmsg' => 'Approved',
+ 'securetoken' => '80IgSbabyj0CtBDWHZZeQN3',
+ 'securetokenid' => $secureTokenID,
+ 'result_code' => '0',
+ ]);
+
+ $quote = $this->getMockBuilder(Quote::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $quote->expects($this->once())
+ ->method('getStoreId')
+ ->willReturn($storeId);
$this->transparent->expects($this->once())
->method('buildBasicRequest')
->willReturn($request);
+ $this->transparent->expects($this->once())
+ ->method('setStore')
+ ->with($storeId);
$this->transparent->expects($this->once())
->method('fillCustomerContacts');
$this->transparent->expects($this->once())
@@ -64,7 +88,7 @@ public function testRequestToken()
->willReturn($this->createMock(\Magento\Paypal\Model\PayflowConfig::class));
$this->transparent->expects($this->once())
->method('postRequest')
- ->willReturn(new DataObject());
+ ->willReturn($response);
$this->mathRandom->expects($this->once())
->method('getUniqueHash')
@@ -73,8 +97,6 @@ public function testRequestToken()
$this->url->expects($this->exactly(3))
->method('getUrl');
- $quote = $this->createMock(\Magento\Quote\Model\Quote::class);
-
$this->model->requestToken($quote);
$this->assertEquals($secureTokenID, $request->getSecuretokenid());
diff --git a/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php b/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php
index 362615e965d1b..80c8194e07654 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php
@@ -101,16 +101,20 @@ protected function setUp()
public function testInitialize()
{
+ $storeId = 1;
$order = $this->createMock(\Magento\Sales\Model\Order::class);
+ $order->expects($this->exactly(2))
+ ->method('getStoreId')
+ ->willReturn($storeId);
$this->infoInstance->expects($this->any())
->method('getOrder')
- ->will($this->returnValue($order));
+ ->willReturn($order);
$this->infoInstance->expects($this->any())
->method('setAdditionalInformation')
- ->will($this->returnSelf());
+ ->willReturnSelf();
$this->paypalConfig->expects($this->once())
->method('getBuildNotationCode')
- ->will($this->returnValue('build notation code'));
+ ->willReturn('build notation code');
$response = new \Magento\Framework\DataObject(
[
@@ -148,6 +152,7 @@ public function testInitialize()
$stateObject = new \Magento\Framework\DataObject();
$this->model->initialize(\Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH, $stateObject);
+ self::assertEquals($storeId, $this->model->getStore(), '{Store} should be set');
}
/**
diff --git a/app/code/Magento/Paypal/view/adminhtml/templates/transparent/form.phtml b/app/code/Magento/Paypal/view/adminhtml/templates/transparent/form.phtml
index cdd4779a2fd87..532fa88c4986a 100644
--- a/app/code/Magento/Paypal/view/adminhtml/templates/transparent/form.phtml
+++ b/app/code/Magento/Paypal/view/adminhtml/templates/transparent/form.phtml
@@ -135,7 +135,7 @@ $ccExpMonth = $block->getInfoData('cc_exp_month');
name="payment[is_active_payment_token_enabler]"
class="admin__control-checkbox"/>
diff --git a/app/code/Magento/Quote/Model/PaymentMethodManagement.php b/app/code/Magento/Quote/Model/PaymentMethodManagement.php
index 91d8fe4dbcffd..b6e4bcf5ccc8f 100644
--- a/app/code/Magento/Quote/Model/PaymentMethodManagement.php
+++ b/app/code/Magento/Quote/Model/PaymentMethodManagement.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Quote\Model;
@@ -52,38 +53,37 @@ public function set($cartId, \Magento\Quote\Api\Data\PaymentInterface $method)
{
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $this->quoteRepository->get($cartId);
-
+ $quote->setTotalsCollectedFlag(false);
$method->setChecks([
\Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_CHECKOUT,
\Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY,
\Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY,
\Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
]);
- $payment = $quote->getPayment();
-
- $data = $method->getData();
- $payment->importData($data);
if ($quote->isVirtual()) {
- $quote->getBillingAddress()->setPaymentMethod($payment->getMethod());
+ $address = $quote->getBillingAddress();
} else {
+ $address = $quote->getShippingAddress();
// check if shipping address is set
- if ($quote->getShippingAddress()->getCountryId() === null) {
+ if ($address->getCountryId() === null) {
throw new InvalidTransitionException(
__('The shipping address is missing. Set the address and try again.')
);
}
- $quote->getShippingAddress()->setPaymentMethod($payment->getMethod());
- }
- if (!$quote->isVirtual() && $quote->getShippingAddress()) {
- $quote->getShippingAddress()->setCollectShippingRates(true);
+ $address->setCollectShippingRates(true);
}
+ $paymentData = $method->getData();
+ $payment = $quote->getPayment();
+ $payment->importData($paymentData);
+ $address->setPaymentMethod($payment->getMethod());
+
if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) {
throw new InvalidTransitionException(__('The requested Payment Method is not available.'));
}
- $quote->setTotalsCollectedFlag(false)->collectTotals()->save();
+ $quote->save();
return $quote->getPayment()->getId();
}
diff --git a/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php
index 68b077fcdb965..f18d1fa1b06e5 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/PaymentMethodManagementTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Quote\Test\Unit\Model;
@@ -152,8 +153,8 @@ public function testSetVirtualProduct()
->with($paymentMethod)
->willReturnSelf();
- $quoteMock->expects($this->exactly(2))->method('getPayment')->willReturn($paymentMock);
- $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(true);
+ $quoteMock->method('getPayment')->willReturn($paymentMock);
+ $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true);
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
$methodInstance = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class);
@@ -165,7 +166,6 @@ public function testSetVirtualProduct()
->willReturn(true);
$quoteMock->expects($this->once())->method('setTotalsCollectedFlag')->with(false)->willReturnSelf();
- $quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf();
$quoteMock->expects($this->once())->method('save')->willReturnSelf();
$paymentMock->expects($this->once())->method('getId')->willReturn($paymentId);
@@ -218,9 +218,9 @@ public function testSetVirtualProductThrowsExceptionIfPaymentMethodNotAvailable(
->with($paymentMethod)
->willReturnSelf();
- $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock);
- $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(true);
- $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
+ $quoteMock->method('getPayment')->willReturn($paymentMock);
+ $quoteMock->method('isVirtual')->willReturn(true);
+ $quoteMock->method('getBillingAddress')->willReturn($billingAddressMock);
$methodInstance = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class);
$paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance);
@@ -268,17 +268,20 @@ public function testSetSimpleProduct()
$shippingAddressMock = $this->createPartialMock(
\Magento\Quote\Model\Quote\Address::class,
- ['getCountryId', 'setPaymentMethod']
+ ['getCountryId', 'setPaymentMethod', 'setCollectShippingRates']
);
$shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn(100);
$shippingAddressMock->expects($this->once())
->method('setPaymentMethod')
->with($paymentMethod)
->willReturnSelf();
+ $shippingAddressMock->expects($this->once())
+ ->method('setCollectShippingRates')
+ ->with(true);
- $quoteMock->expects($this->exactly(2))->method('getPayment')->willReturn($paymentMock);
- $quoteMock->expects($this->exactly(2))->method('isVirtual')->willReturn(false);
- $quoteMock->expects($this->exactly(4))->method('getShippingAddress')->willReturn($shippingAddressMock);
+ $quoteMock->method('getPayment')->willReturn($paymentMock);
+ $quoteMock->method('isVirtual')->willReturn(false);
+ $quoteMock->method('getShippingAddress')->willReturn($shippingAddressMock);
$methodInstance = $this->getMockForAbstractClass(\Magento\Payment\Model\MethodInterface::class);
$paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInstance);
@@ -289,7 +292,6 @@ public function testSetSimpleProduct()
->willReturn(true);
$quoteMock->expects($this->once())->method('setTotalsCollectedFlag')->with(false)->willReturnSelf();
- $quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf();
$quoteMock->expects($this->once())->method('save')->willReturnSelf();
$paymentMock->expects($this->once())->method('getId')->willReturn($paymentId);
@@ -303,7 +305,6 @@ public function testSetSimpleProduct()
public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet()
{
$cartId = 100;
- $methodData = ['method' => 'data'];
$quoteMock = $this->createPartialMock(
\Magento\Quote\Model\Quote::class,
@@ -311,6 +312,7 @@ public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet()
);
$this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock);
+ /** @var \Magento\Quote\Model\Quote\Payment|\PHPUnit_Framework_MockObject_MockObject $methodMock */
$methodMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Payment::class, ['setChecks', 'getData']);
$methodMock->expects($this->once())
->method('setChecks')
@@ -321,17 +323,13 @@ public function testSetSimpleProductTrowsExceptionIfShippingAddressNotSet()
\Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
])
->willReturnSelf();
- $methodMock->expects($this->once())->method('getData')->willReturn($methodData);
-
- $paymentMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Payment::class, ['importData']);
- $paymentMock->expects($this->once())->method('importData')->with($methodData)->willReturnSelf();
+ $methodMock->expects($this->never())->method('getData');
$shippingAddressMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address::class, ['getCountryId']);
$shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn(null);
- $quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock);
- $quoteMock->expects($this->once())->method('isVirtual')->willReturn(false);
- $quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($shippingAddressMock);
+ $quoteMock->method('isVirtual')->willReturn(false);
+ $quoteMock->method('getShippingAddress')->willReturn($shippingAddressMock);
$this->model->set($cartId, $methodMock);
}
diff --git a/app/code/Magento/Sales/Api/PaymentFailuresInterface.php b/app/code/Magento/Sales/Api/PaymentFailuresInterface.php
new file mode 100644
index 0000000000000..485ff1ffbe248
--- /dev/null
+++ b/app/code/Magento/Sales/Api/PaymentFailuresInterface.php
@@ -0,0 +1,28 @@
+getIncrementId() == null) {
+ $store = $object->getStore();
+ $storeId = $store->getId();
+ if ($storeId === null) {
+ $storeId = $store->getGroup()->getDefaultStoreId();
+ }
$object->setIncrementId(
$this->sequenceManager->getSequence(
$object->getEntityType(),
- $object->getStore()->getGroup()->getDefaultStoreId()
+ $storeId
)->getNextValue()
);
}
diff --git a/app/code/Magento/Sales/Model/Service/OrderService.php b/app/code/Magento/Sales/Model/Service/OrderService.php
index 1eb3fad11278f..e4a71f028cc82 100644
--- a/app/code/Magento/Sales/Model/Service/OrderService.php
+++ b/app/code/Magento/Sales/Model/Service/OrderService.php
@@ -6,6 +6,7 @@
namespace Magento\Sales\Model\Service;
use Magento\Sales\Api\OrderManagementInterface;
+use Magento\Payment\Gateway\Command\CommandException;
/**
* Class OrderService
@@ -49,6 +50,11 @@ class OrderService implements OrderManagementInterface
*/
protected $orderCommentSender;
+ /**
+ * @var \Magento\Sales\Api\PaymentFailuresInterface
+ */
+ private $paymentFailures;
+
/**
* Constructor
*
@@ -59,6 +65,7 @@ class OrderService implements OrderManagementInterface
* @param \Magento\Sales\Model\OrderNotifier $notifier
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender $orderCommentSender
+ * @param \Magento\Sales\Api\PaymentFailuresInterface|null $paymentFailures
*/
public function __construct(
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
@@ -67,7 +74,8 @@ public function __construct(
\Magento\Framework\Api\FilterBuilder $filterBuilder,
\Magento\Sales\Model\OrderNotifier $notifier,
\Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender $orderCommentSender
+ \Magento\Sales\Model\Order\Email\Sender\OrderCommentSender $orderCommentSender,
+ \Magento\Sales\Api\PaymentFailuresInterface $paymentFailures = null
) {
$this->orderRepository = $orderRepository;
$this->historyRepository = $historyRepository;
@@ -76,6 +84,8 @@ public function __construct(
$this->notifier = $notifier;
$this->eventManager = $eventManager;
$this->orderCommentSender = $orderCommentSender;
+ $this->paymentFailures = $paymentFailures ? : \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(\Magento\Sales\Api\PaymentFailuresInterface::class);
}
/**
@@ -192,6 +202,9 @@ public function place(\Magento\Sales\Api\Data\OrderInterface $order)
return $this->orderRepository->save($order);
//commit
} catch (\Exception $e) {
+ if ($e instanceof CommandException) {
+ $this->paymentFailures->handle((int)$order->getQuoteId(), __($e->getMessage()));
+ }
throw $e;
//rollback;
}
diff --git a/app/code/Magento/Sales/Model/Service/PaymentFailuresService.php b/app/code/Magento/Sales/Model/Service/PaymentFailuresService.php
new file mode 100644
index 0000000000000..3a49bbce256ef
--- /dev/null
+++ b/app/code/Magento/Sales/Model/Service/PaymentFailuresService.php
@@ -0,0 +1,294 @@
+ Configuration > Sales > Checkout > Payment Failed Emails configuration.
+ */
+class PaymentFailuresService implements PaymentFailuresInterface
+{
+ /**
+ * Store config
+ *
+ * @var ScopeConfigInterface
+ */
+ private $scopeConfig;
+
+ /**
+ * @var StateInterface
+ */
+ private $inlineTranslation;
+
+ /**
+ * @var TransportBuilder
+ */
+ private $transportBuilder;
+
+ /**
+ * @var TimezoneInterface
+ */
+ private $localeDate;
+
+ /**
+ * @var CartRepositoryInterface
+ */
+ private $cartRepository;
+
+ /**
+ * @param ScopeConfigInterface $scopeConfig
+ * @param StateInterface $inlineTranslation
+ * @param TransportBuilder $transportBuilder
+ * @param TimezoneInterface $localeDate
+ * @param CartRepositoryInterface $cartRepository
+ */
+ public function __construct(
+ ScopeConfigInterface $scopeConfig,
+ StateInterface $inlineTranslation,
+ TransportBuilder $transportBuilder,
+ TimezoneInterface $localeDate,
+ CartRepositoryInterface $cartRepository
+ ) {
+ $this->scopeConfig = $scopeConfig;
+ $this->inlineTranslation = $inlineTranslation;
+ $this->transportBuilder = $transportBuilder;
+ $this->localeDate = $localeDate;
+ $this->cartRepository = $cartRepository;
+ }
+
+ /**
+ * Sends an email about failed transaction.
+ *
+ * @param int $cartId
+ * @param string $message
+ * @param string $checkoutType
+ * @return PaymentFailuresInterface
+ */
+ public function handle(
+ int $cartId,
+ string $message,
+ string $checkoutType = 'onepage'
+ ): PaymentFailuresInterface {
+ $this->inlineTranslation->suspend();
+ $quote = $this->cartRepository->get($cartId);
+
+ $template = $this->getConfigValue('checkout/payment_failed/template', $quote);
+ $receiver = $this->getConfigValue('checkout/payment_failed/receiver', $quote);
+ $sendTo = [
+ [
+ 'email' => $this->getConfigValue('trans_email/ident_' . $receiver . '/email', $quote),
+ 'name' => $this->getConfigValue('trans_email/ident_' . $receiver . '/name', $quote),
+ ],
+ ];
+
+ $copyMethod = $this->getConfigValue('checkout/payment_failed/copy_method', $quote);
+ $copyTo = $this->getConfigEmails($quote);
+
+ $bcc = [];
+ if (!empty($copyTo)) {
+ switch ($copyMethod) {
+ case 'bcc':
+ $bcc = $copyTo;
+ break;
+ case 'copy':
+ foreach ($copyTo as $email) {
+ $sendTo[] = ['email' => $email, 'name' => null];
+ }
+ break;
+ }
+ }
+
+ foreach ($sendTo as $recipient) {
+ $transport = $this->transportBuilder
+ ->setTemplateIdentifier($template)
+ ->setTemplateOptions([
+ 'area' => FrontNameResolver::AREA_CODE,
+ 'store' => Store::DEFAULT_STORE_ID,
+ ])
+ ->setTemplateVars($this->getTemplateVars($quote, $message, $checkoutType))
+ ->setFrom($this->getSendFrom($quote))
+ ->addTo($recipient['email'], $recipient['name'])
+ ->addBcc($bcc)
+ ->getTransport();
+
+ $transport->sendMessage();
+ }
+
+ $this->inlineTranslation->resume();
+
+ return $this;
+ }
+
+ /**
+ * Returns mail template variables.
+ *
+ * @param Quote $quote
+ * @param string $message
+ * @param string $checkoutType
+ * @return array
+ */
+ private function getTemplateVars(Quote $quote, string $message, string $checkoutType): array
+ {
+ return [
+ 'reason' => $message,
+ 'checkoutType' => $checkoutType,
+ 'dateAndTime' => $this->getLocaleDate(),
+ 'customer' => $this->getCustomerName($quote),
+ 'customerEmail' => $quote->getBillingAddress()->getEmail(),
+ 'billingAddress' => $quote->getBillingAddress(),
+ 'shippingAddress' => $quote->getShippingAddress(),
+ 'shippingMethod' => $this->getConfigValue(
+ 'carriers/' . $this->getShippingMethod($quote) . '/title',
+ $quote
+ ),
+ 'paymentMethod' => $this->getConfigValue(
+ 'payment/' . $this->getPaymentMethod($quote) . '/title',
+ $quote
+ ),
+ 'items' => implode('
', $this->getQuoteItems($quote)),
+ 'total' => $quote->getCurrency()->getStoreCurrencyCode() . ' ' . $quote->getGrandTotal(),
+ ];
+ }
+
+ /**
+ * Returns scope config value by config path.
+ *
+ * @param string $configPath
+ * @param Quote $quote
+ * @return mixed
+ */
+ private function getConfigValue(string $configPath, Quote $quote)
+ {
+ return $this->scopeConfig->getValue(
+ $configPath,
+ ScopeInterface::SCOPE_STORE,
+ $quote->getStoreId()
+ );
+ }
+
+ /**
+ * Returns shipping method from quote.
+ *
+ * @param Quote $quote
+ * @return string
+ */
+ private function getShippingMethod(Quote $quote): string
+ {
+ $shippingMethod = '';
+ $shippingInfo = $quote->getShippingAddress()->getShippingMethod();
+
+ if ($shippingInfo) {
+ $data = explode('_', $shippingInfo);
+ $shippingMethod = $data[0];
+ }
+
+ return $shippingMethod;
+ }
+
+ /**
+ * Returns payment method title from quote.
+ *
+ * @param Quote $quote
+ * @return string
+ */
+ private function getPaymentMethod(Quote $quote): string
+ {
+ $paymentMethod = $quote->getPayment()->getMethod() ?? '';
+
+ return $paymentMethod;
+ }
+
+ /**
+ * Returns quote visible items.
+ *
+ * @param Quote $quote
+ * @return array
+ */
+ private function getQuoteItems(Quote $quote): array
+ {
+ $items = [];
+ foreach ($quote->getAllVisibleItems() as $item) {
+ $itemData = $item->getProduct()->getName() . ' x ' . $item->getQty() . ' ' .
+ $quote->getCurrency()->getStoreCurrencyCode() . ' ' .
+ $item->getProduct()->getFinalPrice($item->getQty());
+ $items[] = $itemData;
+ }
+
+ return $items;
+ }
+
+ /**
+ * Gets email values by configuration path.
+ *
+ * @param Quote $quote
+ * @return array|false
+ */
+ private function getConfigEmails(Quote $quote)
+ {
+ $configData = $this->getConfigValue('checkout/payment_failed/copy_to', $quote);
+ if (!empty($configData)) {
+ return explode(',', $configData);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns sender identity.
+ *
+ * @param Quote $quote
+ * @return string
+ */
+ private function getSendFrom(Quote $quote): string
+ {
+ return $this->getConfigValue('checkout/payment_failed/identity', $quote);
+ }
+
+ /**
+ * Returns current locale date and time
+ *
+ * @return string
+ */
+ private function getLocaleDate(): string
+ {
+ return $this->localeDate->formatDateTime(
+ new \DateTime(),
+ \IntlDateFormatter::MEDIUM,
+ \IntlDateFormatter::MEDIUM
+ );
+ }
+
+ /**
+ * Returns customer name.
+ *
+ * @param Quote $quote
+ * @return string
+ */
+ private function getCustomerName(Quote $quote): string
+ {
+ $customer = __('Guest')->render();
+ if (!$quote->getCustomerIsGuest()) {
+ $customer = $quote->getCustomer()->getFirstname() . ' ' .
+ $quote->getCustomer()->getLastname();
+ }
+
+ return $customer;
+ }
+}
diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml
index ce2948983edbe..ac25cdab22f56 100644
--- a/app/code/Magento/Sales/etc/di.xml
+++ b/app/code/Magento/Sales/etc/di.xml
@@ -65,6 +65,7 @@
+
diff --git a/app/code/Magento/Search/view/frontend/web/form-mini.js b/app/code/Magento/Search/view/frontend/web/form-mini.js
index de16305bbbe8d..27a15017cb3fc 100644
--- a/app/code/Magento/Search/view/frontend/web/form-mini.js
+++ b/app/code/Magento/Search/view/frontend/web/form-mini.js
@@ -55,7 +55,7 @@ define([
this.autoComplete = $(this.options.destinationSelector);
this.searchForm = $(this.options.formSelector);
this.submitBtn = this.searchForm.find(this.options.submitBtn)[0];
- this.searchLabel = $(this.options.searchLabel);
+ this.searchLabel = this.searchForm.find(this.options.searchLabel);
this.isExpandable = this.options.isExpandable;
_.bindAll(this, '_onKeyDown', '_onPropertyChange', '_onSubmit');
@@ -226,6 +226,7 @@ define([
case $.ui.keyCode.ENTER:
this.searchForm.trigger('submit');
+ e.preventDefault();
break;
case $.ui.keyCode.DOWN:
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index a26beda520944..5be5ccbc5e55a 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -60,7 +60,7 @@ public function __construct(
*
* @param string $paymentCode
* @return PaymentVerificationInterface
- * @throws \Exception
+ * @throws ConfigurationMismatchException
*/
public function createPaymentCvv($paymentCode)
{
@@ -73,7 +73,7 @@ public function createPaymentCvv($paymentCode)
*
* @param string $paymentCode
* @return PaymentVerificationInterface
- * @throws \Exception
+ * @throws ConfigurationMismatchException
*/
public function createPaymentAvs($paymentCode)
{
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php
index 02031e6f5b9b5..19408e99ae02e 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php
@@ -30,7 +30,7 @@ class DebuggerFactory
/**
* DebuggerFactory constructor.
*
- * @param bjectManagerInterface $objectManager
+ * @param ObjectManagerInterface $objectManager
* @param Config $config
*/
public function __construct(
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 858ce0f0f3287..5e544e4b4048e 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -7,12 +7,13 @@
use Magento\Framework\App\Area;
use Magento\Framework\Config\ScopeInterface;
+use Magento\Framework\Exception\ConfigurationMismatchException;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\PaymentMethodMapper\PaymentMethodMapper;
use Magento\Signifyd\Model\PaymentVerificationFactory;
use Magento\Signifyd\Model\SignifydOrderSessionId;
-use Magento\Signifyd\Model\PaymentMethodMapper\PaymentMethodMapper;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -72,6 +73,7 @@ public function __construct(
*
* @param Order $order
* @return array
+ * @throws ConfigurationMismatchException
*/
public function build(Order $order)
{
@@ -202,6 +204,7 @@ private function getOrderChannel()
*
* @param OrderPaymentInterface $orderPayment
* @return string
+ * @throws ConfigurationMismatchException
*/
private function getAvsCode(OrderPaymentInterface $orderPayment)
{
@@ -214,6 +217,7 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
*
* @param OrderPaymentInterface $orderPayment
* @return string
+ * @throws ConfigurationMismatchException
*/
private function getCvvCode(OrderPaymentInterface $orderPayment)
{
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 92ad8a0bfd87a..fd78fff27f619 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -15,11 +15,7 @@
-
-
- U
-
-
+
diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php
index 67d2ce4f4f148..d19b248c8008f 100644
--- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php
+++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php
@@ -6,8 +6,29 @@
*/
namespace Magento\Sitemap\Controller\Adminhtml\Sitemap;
+use Magento\Backend\App\Action;
+use Magento\Store\Model\App\Emulation;
+use Magento\Framework\App\ObjectManager;
+
class Generate extends \Magento\Sitemap\Controller\Adminhtml\Sitemap
{
+ /** @var \Magento\Store\Model\App\Emulation $appEmulation */
+ private $appEmulation;
+
+ /**
+ * Generate constructor.
+ * @param Action\Context $context
+ * @param \Magento\Store\Model\App\Emulation|null $appEmulation
+ */
+ public function __construct(
+ Action\Context $context,
+ Emulation $appEmulation = null
+ ) {
+ parent::__construct($context);
+ $this->appEmulation = $appEmulation ?: ObjectManager::getInstance()
+ ->get(\Magento\Store\Model\App\Emulation::class);
+ }
+
/**
* Generate sitemap
*
@@ -23,6 +44,12 @@ public function execute()
// if sitemap record exists
if ($sitemap->getId()) {
try {
+ //We need to emulate to get the correct frontend URL for the product images
+ $this->appEmulation->startEnvironmentEmulation(
+ $sitemap->getStoreId(),
+ \Magento\Framework\App\Area::AREA_FRONTEND,
+ true
+ );
$sitemap->generateXml();
$this->messageManager->addSuccess(
@@ -32,6 +59,8 @@ public function execute()
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t generate the sitemap right now.'));
+ } finally {
+ $this->appEmulation->stopEnvironmentEmulation();
}
} else {
$this->messageManager->addError(__('We can\'t find a sitemap to generate.'));
diff --git a/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml b/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml
index 345f063a7aaa3..f14df1c70a790 100644
--- a/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml
+++ b/app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml
@@ -10,32 +10,18 @@
Swagger UI
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -43,6 +29,7 @@
+
diff --git a/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
index 27b3767f274bc..b20da68734579 100644
--- a/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
+++ b/app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml
@@ -12,11 +12,48 @@
* Modified by Magento, Modifications Copyright © Magento, Inc. All rights reserved.
*/
-/** @var \Magento\Swagger\Block\Index $block */
+/** @var \Magento\Swagger\Block\Index $block
+ *
+ * @codingStandardsIgnoreFile
+ */
$schemaUrl = $block->getSchemaUrl();
?>
+
+