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 98dbe562 authored by Alessio Zampatti's avatar Alessio Zampatti Committed by GitHub

Fixed shopper locale for Paybymail method (#206)

parent 058eb3c0
...@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Command; ...@@ -26,6 +26,7 @@ namespace Adyen\Payment\Gateway\Command;
use Magento\Payment\Gateway\Command; use Magento\Payment\Gateway\Command;
use Magento\Payment\Gateway\CommandInterface; use Magento\Payment\Gateway\CommandInterface;
class PayByMailCommand implements CommandInterface class PayByMailCommand implements CommandInterface
{ {
...@@ -34,11 +35,6 @@ class PayByMailCommand implements CommandInterface ...@@ -34,11 +35,6 @@ class PayByMailCommand implements CommandInterface
*/ */
protected $_adyenHelper; protected $_adyenHelper;
/**
* @var ResolverInterface
*/
protected $_resolver;
/** /**
* @var \Adyen\Payment\Logger\AdyenLogger * @var \Adyen\Payment\Logger\AdyenLogger
*/ */
...@@ -53,11 +49,9 @@ class PayByMailCommand implements CommandInterface ...@@ -53,11 +49,9 @@ class PayByMailCommand implements CommandInterface
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Locale\ResolverInterface $resolver,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger \Adyen\Payment\Logger\AdyenLogger $adyenLogger
) { ) {
$this->_adyenHelper = $adyenHelper; $this->_adyenHelper = $adyenHelper;
$this->_resolver = $resolver;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
} }
/** /**
...@@ -134,6 +128,7 @@ class PayByMailCommand implements CommandInterface ...@@ -134,6 +128,7 @@ class PayByMailCommand implements CommandInterface
$realOrderId = $order->getRealOrderId(); $realOrderId = $order->getRealOrderId();
$orderCurrencyCode = $order->getOrderCurrencyCode(); $orderCurrencyCode = $order->getOrderCurrencyCode();
$storeId = $order->getStore()->getId();
// check if paybymail has it's own skin // check if paybymail has it's own skin
$skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code')); $skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code'));
...@@ -141,18 +136,20 @@ class PayByMailCommand implements CommandInterface ...@@ -141,18 +136,20 @@ class PayByMailCommand implements CommandInterface
// use HPP skin and HMAC // use HPP skin and HMAC
$skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code'); $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code');
$hmacKey = $this->_adyenHelper->getHmac(); $hmacKey = $this->_adyenHelper->getHmac();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale', $storeId));
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code', $storeId));
} else { } else {
// use pay_by_mail skin and hmac // use pay_by_mail skin and hmac
$hmacKey = $this->_adyenHelper->getHmacPayByMail(); $hmacKey = $this->_adyenHelper->getHmacPayByMail();
} }
$amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode); $amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account')); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account', $storeId));
$shopperEmail = $order->getCustomerEmail(); $shopperEmail = $order->getCustomerEmail();
$customerId = $order->getCustomerId(); $customerId = $order->getCustomerId();
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale'));
$shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_resolver->getLocale(); // get locale from store
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code')); $shopperLocale = (!empty($shopperLocale)) ? $shopperLocale : $this->_adyenHelper->getStoreLocale($storeId);
$countryCode = (!empty($countryCode)) ? $countryCode : false; $countryCode = (!empty($countryCode)) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode // if directory lookup is enabled use the billingadress as countrycode
...@@ -164,7 +161,7 @@ class PayByMailCommand implements CommandInterface ...@@ -164,7 +161,7 @@ class PayByMailCommand implements CommandInterface
} }
} }
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days'); $deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days', $storeId);
$deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5; $deliveryDays = (!empty($deliveryDays)) ? $deliveryDays : 5;
$formFields = []; $formFields = [];
...@@ -184,9 +181,9 @@ class PayByMailCommand implements CommandInterface ...@@ -184,9 +181,9 @@ class PayByMailCommand implements CommandInterface
$formFields['shopperEmail'] = $shopperEmail; $formFields['shopperEmail'] = $shopperEmail;
// recurring // recurring
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type')); $recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type', $storeId));
$sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity'); $sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity', $storeId);
if ($sessionValidity == "") { if ($sessionValidity == "") {
$sessionValidity = 3; $sessionValidity = 3;
......
...@@ -816,4 +816,9 @@ class Data extends AbstractHelper ...@@ -816,4 +816,9 @@ class Data extends AbstractHelper
return $this->_assetRepo->createAsset($fileId, $params); return $this->_assetRepo->createAsset($fileId, $params);
} }
public function getStoreLocale($storeId) {
$path = \Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE;
return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
} }
\ No newline at end of file
...@@ -336,9 +336,9 @@ class PaymentMethods extends AbstractHelper ...@@ -336,9 +336,9 @@ class PaymentMethods extends AbstractHelper
return $locale; return $locale;
} }
// should have the vulue if not fall back to default // should have the value if not fall back to default
$localeCode = $this->_config->getValue( $localeCode = $this->_config->getValue(
Data::XML_PATH_DEFAULT_LOCALE, \Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES, \Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode() $store->getCode()
); );
......
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