We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 9249bb27 authored by Ángel Campos's avatar Ángel Campos Committed by GitHub

[PW-2015]: Fix orders not being created but card getting charged when...

[PW-2015]: Fix orders not being created but card getting charged when Persistent Cart and Guest Checkout enabled (#630)

* [PW-2015]: Fix orders not being created but card getting charged when Persistent Cart and Guest Checkout enabled

* [PW-2015]: Removing \Magento\Checkout\Model\Session DI not being used anymore

* Skipping payment validation if no quoteId is present

* Replacing ternary check with if/else for readability
parent 03fae317
......@@ -40,34 +40,35 @@ class InstallmentValidator extends AbstractValidator
private $adyenHelper;
/**
* @var \Magento\Checkout\Model\Session
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $session;
private $serializer;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
* @var \Magento\Quote\Model\QuoteRepository
*/
private $serializer;
private $quoteRepository;
/**
* InstallmentValidator constructor.
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
*/
public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $session,
\Magento\Framework\Serialize\SerializerInterface $serializer
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Quote\Model\QuoteRepository $quoteRepository
) {
$this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
$this->session = $session;
$this->serializer = $serializer;
$this->quoteRepository = $quoteRepository;
parent::__construct($resultFactory);
}
......@@ -77,7 +78,13 @@ class InstallmentValidator extends AbstractValidator
$isValid = true;
$fails = [];
$payment = $validationSubject['payment'];
$quote = $this->session->getQuote();
$quoteId = $payment->getQuoteId();
//This validator also runs for other payments that don't necesarily have a quoteId
if ($quoteId) {
$quote = $this->quoteRepository->get($quoteId);
} else {
$quote = false;
}
$installmentsEnabled = $this->adyenHelper->getAdyenCcConfigData('enable_installments');
if ($quote && $installmentsEnabled) {
$grandTotal = $quote->getGrandTotal();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment