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 7f6ae398 authored by marcoss's avatar marcoss

Fix code style issues

parent d8743168
......@@ -52,23 +52,31 @@ class Json extends \Magento\Framework\App\Action\Action
*/
protected $_adyenLogger;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* Json constructor.
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\Serialize\SerializerInterface $serializer
) {
parent::__construct($context);
$this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory();
$this->_adyenHelper = $adyenHelper;
$this->_adyenLogger = $adyenLogger;
$this->serializer = $serializer;
// Fix for Magento2.3 adding isAjax to the request params
if(interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
......@@ -214,7 +222,7 @@ class Json extends \Magento\Framework\App\Action\Action
$notification->setLive($notificationMode);
if (isset($response['additionalData'])) {
$notification->setAddtionalData(serialize($response['additionalData']));
$notification->setAddtionalData($this->serializer->serialize($response['additionalData']));
}
if (isset($response['done'])) {
$notification->setDone($response['done']);
......
......@@ -77,24 +77,35 @@ class Redirect extends \Magento\Framework\App\Action\Action
* @var PaymentTokenFactoryInterface
*/
private $paymentTokenFactory;
/**
* @var OrderPaymentExtensionInterfaceFactory
*/
private $paymentExtensionFactory;
/**
* @var OrderPaymentResource
*/
private $orderPaymentResource;
/**
* Redirect constructor.
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
*/
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* Redirect constructor.
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
* @param OrderPaymentResource $orderPaymentResource
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
......@@ -103,7 +114,8 @@ class Redirect extends \Magento\Framework\App\Action\Action
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
PaymentTokenFactoryInterface $paymentTokenFactory,
OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory,
OrderPaymentResource $orderPaymentResource
OrderPaymentResource $orderPaymentResource,
\Magento\Framework\Serialize\SerializerInterface $serializer
) {
parent::__construct($context);
$this->_adyenLogger = $adyenLogger;
......@@ -113,6 +125,7 @@ class Redirect extends \Magento\Framework\App\Action\Action
$this->paymentTokenFactory = $paymentTokenFactory;
$this->paymentExtensionFactory = $paymentExtensionFactory;
$this->orderPaymentResource = $orderPaymentResource;
$this->serializer = $serializer;
if (interface_exists("\Magento\Framework\App\CsrfAwareActionInterface")) {
$request = $this->getRequest();
if ($request instanceof Http && $request->isPost()) {
......@@ -198,9 +211,9 @@ class Redirect extends \Magento\Framework\App\Action\Action
$extensionAttributes = $this->getExtensionAttributes($order->getPayment());
$extensionAttributes->setVaultPaymentToken($paymentToken);
$orderPayment = $order->getPayment()->setExtensionAttributes($extensionAttributes);
$add = unserialize($orderPayment->getAdditionalData());
$add = $this->serializer->unserialize($orderPayment->getAdditionalData());
$add['force_save'] = true;
$orderPayment->setAdditionalData(serialize($add));
$orderPayment->setAdditionalData($this->serializer->serialize($add));
$this->orderPaymentResource->save($orderPayment);
} catch (\Exception $e) {
$this->_adyenLogger->error((string)$e->getMessage());
......
......@@ -44,22 +44,30 @@ class InstallmentValidator extends AbstractValidator
*/
private $session;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* InstallmentValidator constructor.
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\App\ObjectManager $objectManager
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
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\Checkout\Model\Session $session,
\Magento\Framework\Serialize\SerializerInterface $serializer
) {
$this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper;
$this->session = $session;
$this->serializer = $serializer;
parent::__construct($resultFactory);
}
......@@ -77,7 +85,7 @@ class InstallmentValidator extends AbstractValidator
$installmentSelected = $payment->getAdditionalInformation('number_of_installments');
$ccType = $payment->getAdditionalInformation('cc_type');
if ($installmentsAvailable) {
$installments = unserialize($installmentsAvailable);
$installments = $this->serializer->unserialize($installmentsAvailable);
}
if ($installmentSelected && $installmentsAvailable) {
$isValid = false;
......
......@@ -131,6 +131,10 @@ class Data extends AbstractHelper
*/
private $helperBackend;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* Data constructor.
......@@ -154,6 +158,7 @@ class Data extends AbstractHelper
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Backend\Helper\Data $helperBackend
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
......@@ -175,7 +180,8 @@ class Data extends AbstractHelper
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Backend\Helper\Data $helperBackend
\Magento\Backend\Helper\Data $helperBackend,
\Magento\Framework\Serialize\SerializerInterface $serializer
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
......@@ -197,6 +203,7 @@ class Data extends AbstractHelper
$this->localeResolver = $localeResolver;
$this->config = $config;
$this->helperBackend = $helperBackend;
$this->serializer = $serializer;
}
/**
......@@ -955,7 +962,7 @@ class Data extends AbstractHelper
$installments = null;
$installmentsValue = $this->getAdyenCcConfigData('installments');
if ($installmentsValue) {
$installments = unserialize($installmentsValue);
$installments = $this->serializer->unserialize($installmentsValue);
}
if ($installments) {
......
......@@ -30,6 +30,11 @@ class Installments extends \Magento\Framework\App\Config\Value
*/
protected $mathRandom;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
......@@ -46,11 +51,13 @@ class Installments extends \Magento\Framework\App\Config\Value
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Math\Random $mathRandom,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->mathRandom = $mathRandom;
$this->serializer = $serializer;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
......@@ -62,8 +69,7 @@ class Installments extends \Magento\Framework\App\Config\Value
public function beforeSave()
{
$value = $this->getValue();
$unserialized = @unserialize($value);
if ($unserialized !== false) {
if (!is_array($value)) {
return $this;
}
$result = [];
......@@ -94,7 +100,7 @@ class Installments extends \Magento\Framework\App\Config\Value
$finalResult[$key] = $installments;
}
$this->setValue(serialize($finalResult));
$this->setValue($this->serializer->serialize($finalResult));
return $this;
}
......@@ -106,7 +112,7 @@ class Installments extends \Magento\Framework\App\Config\Value
protected function _afterLoad()
{
$value = $this->getValue();
$value = unserialize($value);
$value = $this->serializer->unserialize($value);
if (is_array($value)) {
$value = $this->encodeArrayFieldValue($value);
$this->setValue($value);
......
......@@ -30,12 +30,18 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
*/
protected $mathRandom;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param \Magento\Framework\Math\Random $mathRandom
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
......@@ -46,11 +52,13 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Math\Random $mathRandom,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->mathRandom = $mathRandom;
$this->serializer = $serializer;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
......@@ -62,9 +70,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
public function beforeSave()
{
$value = $this->getValue();
$unserialized = @unserialize($value);
if ($unserialized !== false) {
if (!is_array($value)) {
return $this;
}
$result = [];
......@@ -87,7 +93,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
asort($result);
$this->setValue(serialize($result));
$this->setValue($this->serializer->serialize($result));
return $this;
}
......@@ -100,7 +106,7 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
protected function _afterLoad()
{
$value = $this->getValue();
$value = unserialize($value);
$value = $this->serializer->unserialize($value);
if (is_array($value)) {
$value = $this->encodeArrayFieldValue($value);
......
......@@ -69,6 +69,10 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
*/
private $storeManager;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* AdyenCcConfigProvider constructor.
......@@ -80,6 +84,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
* @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Payment\Model\CcConfig $ccConfig
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
\Magento\Payment\Helper\Data $paymentHelper,
......@@ -88,7 +93,8 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\View\Asset\Source $assetSource,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Payment\Model\CcConfig $ccConfig
\Magento\Payment\Model\CcConfig $ccConfig,
\Magento\Framework\Serialize\SerializerInterface $serializer
) {
$this->_paymentHelper = $paymentHelper;
$this->_adyenHelper = $adyenHelper;
......@@ -97,6 +103,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$this->_assetSource = $assetSource;
$this->ccConfig = $ccConfig;
$this->storeManager = $storeManager;
$this->serializer = $serializer;
}
/**
......@@ -156,7 +163,7 @@ class AdyenCcConfigProvider implements ConfigProviderInterface
$installments = $this->_adyenHelper->getAdyenCcConfigData('installments');
if ($installmentsEnabled && $installments) {
$config['payment']['adyenCc']['installments'] = unserialize($installments);
$config['payment']['adyenCc']['installments'] = $this->serializer->unserialize($installments);
$config['payment']['adyenCc']['hasInstallments'] = true;
} else {
$config['payment']['adyenCc']['installments'] = [];
......
......@@ -144,6 +144,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes();
$config['payment'] ['adyenHpp']['ratePayId'] = $this->adyenHelper->getRatePayId();
// TODO: change the algorithm
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->session->getQuoteId() . date('c'));
$config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI'];
......
......@@ -53,22 +53,32 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface
*/
protected $adyenHelper;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/**
* AdyenHppConfigProvider constructor.
*
* @param PaymentHelper $paymentHelper
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
*/
public function __construct(
\Magento\Framework\App\RequestInterface $request,
\Magento\Framework\UrlInterface $urlBuilder,
\Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper,
\Adyen\Payment\Helper\Data $adyenHelper
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Serialize\SerializerInterface $serializer
) {
$this->request = $request;
$this->urlBuilder = $urlBuilder;
$this->paymentMethodsHelper = $paymentMethodsHelper;
$this->adyenHelper = $adyenHelper;
$this->serializer = $serializer;
}
/**
......@@ -101,7 +111,7 @@ class AdyenPosCloudConfigProvider implements ConfigProviderInterface
$installments = $this->adyenHelper->getAdyenPosCloudConfigData('installments');
if ($installmentsEnabled && $installments) {
$config['payment']['adyenPos']['installments'] = unserialize($installments);
$config['payment']['adyenPos']['installments'] = $this->serializer->unserialize($installments);
$config['payment']['adyenPos']['hasInstallments'] = true;
} else {
$config['payment']['adyenPos']['installments'] = [];
......
......@@ -960,6 +960,26 @@
<argument name="dataStorage" xsi:type="object">adyenPaymentConfigDataStorage</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Config\Backend\Installments">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Config\Backend\InstallmentsPosCloud">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Gateway\Validator\InstallmentValidator">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Ui\AdyenPosCloudConfigProvider">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface"
type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement"/>
<preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface"
......
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