Skip to content

Commit 7214a31

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-94041' into 2.2.6-develop-pr41
2 parents 6481b51 + c28699d commit 7214a31

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

app/code/Magento/Sales/Model/Service/PaymentFailuresService.php

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

88
use Magento\Backend\App\Area\FrontNameResolver;
99
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Mail\Template\TransportBuilder;
1112
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1213
use Magento\Framework\Translate\Inline\StateInterface;
@@ -15,11 +16,14 @@
1516
use Magento\Sales\Api\PaymentFailuresInterface;
1617
use Magento\Store\Model\ScopeInterface;
1718
use Magento\Store\Model\Store;
19+
use Psr\Log\LoggerInterface;
1820

1921
/**
2022
* Service is responsible for handling failed payment transactions.
2123
*
2224
* It depends on Stores > Configuration > Sales > Checkout > Payment Failed Emails configuration.
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2327
*/
2428
class PaymentFailuresService implements PaymentFailuresInterface
2529
{
@@ -50,25 +54,33 @@ class PaymentFailuresService implements PaymentFailuresInterface
5054
*/
5155
private $cartRepository;
5256

57+
/**
58+
* @var LoggerInterface
59+
*/
60+
private $logger;
61+
5362
/**
5463
* @param ScopeConfigInterface $scopeConfig
5564
* @param StateInterface $inlineTranslation
5665
* @param TransportBuilder $transportBuilder
5766
* @param TimezoneInterface $localeDate
5867
* @param CartRepositoryInterface $cartRepository
68+
* @param LoggerInterface|null $logger
5969
*/
6070
public function __construct(
6171
ScopeConfigInterface $scopeConfig,
6272
StateInterface $inlineTranslation,
6373
TransportBuilder $transportBuilder,
6474
TimezoneInterface $localeDate,
65-
CartRepositoryInterface $cartRepository
75+
CartRepositoryInterface $cartRepository,
76+
LoggerInterface $logger = null
6677
) {
6778
$this->scopeConfig = $scopeConfig;
6879
$this->inlineTranslation = $inlineTranslation;
6980
$this->transportBuilder = $transportBuilder;
7081
$this->localeDate = $localeDate;
7182
$this->cartRepository = $cartRepository;
83+
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
7284
}
7385

7486
/**
@@ -126,7 +138,11 @@ public function handle(
126138
->addBcc($bcc)
127139
->getTransport();
128140

129-
$transport->sendMessage();
141+
try {
142+
$transport->sendMessage();
143+
} catch (\Exception $e) {
144+
$this->logger->critical($e->getMessage());
145+
}
130146
}
131147

132148
$this->inlineTranslation->resume();

0 commit comments

Comments
 (0)