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 4a176d04 authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Use quote retrieved by quote id (#667)

parent d6032d10
......@@ -85,6 +85,11 @@ class PaymentMethods extends AbstractHelper
*/
protected $themeProvider;
/**
* @var \Magento\Quote\Model\Quote
*/
protected $quote;
/**
* PaymentMethods constructor.
*
......@@ -133,41 +138,51 @@ class PaymentMethods extends AbstractHelper
{
// get quote from quoteId
$quote = $this->quoteRepository->getActive($quoteId);
$store = $quote->getStore();
$paymentMethods = $this->fetchAlternativeMethods($store, $country);
// If quote cannot be found early return the empty paymentMethods array
if (empty($quote)) {
return [];
}
$this->setQuote($quote);
$paymentMethods = $this->fetchAlternativeMethods($country);
return $paymentMethods;
}
/**
* @param $store
* @param $country
* @return array
*/
protected function fetchAlternativeMethods($store, $country)
protected function fetchAlternativeMethods($country)
{
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData('merchant_account');
$quote = $this->getQuote();
$store = $quote->getStore();
$merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData('merchant_account', $store->getId());
if (!$merchantAccount) {
return [];
}
$currencyCode = $this->getCurrentCurrencyCode($store);
$adyFields = [
"channel" => "Web",
"merchantAccount" => $merchantAccount,
"countryCode" => $this->getCurrentCountryCode($store, $country),
"amount" => [
"currency" => $this->getCurrentCurrencyCode($store),
"currency" => $currencyCode,
"value" => (int)$this->adyenHelper->formatAmount(
$this->getCurrentPaymentAmount(),
$this->getCurrentCurrencyCode($store)
$currencyCode
),
],
"shopperReference" => $this->getCurrentShopperReference(),
"shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store->getId())
];
$billingAddress = $this->getQuote()->getBillingAddress();
$billingAddress = $quote->getBillingAddress();
if (!empty($billingAddress)) {
if ($customerTelephone = trim($billingAddress->getTelephone())) {
......@@ -319,7 +334,7 @@ class PaymentMethods extends AbstractHelper
{
// initialize the adyen client
$client = $this->adyenHelper->initializeAdyenClient($this->getQuote()->getStoreId());
$client = $this->adyenHelper->initializeAdyenClient($store->getId());
// initialize service
$service = $this->adyenHelper->createAdyenCheckoutService($client);
......@@ -342,7 +357,15 @@ class PaymentMethods extends AbstractHelper
*/
protected function getQuote()
{
return $this->session->getQuote();
return $this->quote;
}
/**
* @param \Magento\Quote\Model\Quote $quote
*/
protected function setQuote(\Magento\Quote\Model\Quote $quote)
{
$this->quote = $quote;
}
/**
......@@ -389,4 +412,4 @@ class PaymentMethods extends AbstractHelper
return $responseData;
}
}
\ No newline at end of file
}
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