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 58740370 authored by alessio's avatar alessio

use Magento\Framework\Serialize\Serializer\Serialize, fix typo on...

use Magento\Framework\Serialize\Serializer\Serialize, fix typo on setAdditionalData, add !empty checks for serialization, change algorithm from md5 to sha256, send deviceFingerprint for Ratepay
parent 7f6ae398
...@@ -255,7 +255,7 @@ interface NotificationInterface ...@@ -255,7 +255,7 @@ interface NotificationInterface
* @param string $additionalData * @param string $additionalData
* @return $this * @return $this
*/ */
public function setAddtionalData($additionalData); public function setAdditionalData($additionalData);
/** /**
* Gets the Done for the notification. * Gets the Done for the notification.
......
...@@ -222,7 +222,7 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -222,7 +222,7 @@ class Json extends \Magento\Framework\App\Action\Action
$notification->setLive($notificationMode); $notification->setLive($notificationMode);
if (isset($response['additionalData'])) { if (isset($response['additionalData'])) {
$notification->setAddtionalData($this->serializer->serialize($response['additionalData'])); $notification->setAdditionalData($this->serializer->serialize($response['additionalData']));
} }
if (isset($response['done'])) { if (isset($response['done'])) {
$notification->setDone($response['done']); $notification->setDone($response['done']);
......
...@@ -140,6 +140,13 @@ class CheckoutDataBuilder implements BuilderInterface ...@@ -140,6 +140,13 @@ class CheckoutDataBuilder implements BuilderInterface
$request = array_merge($request, $openInvoiceFields); $request = array_merge($request, $openInvoiceFields);
} }
// Ratepay specific Fingerprint
if ($payment->getAdditionalInformation("df_value") && $this->adyenHelper->isPaymentMethodRatepayMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)) {
$request['deviceFingerprint'] = $payment->getAdditionalInformation("df_value");
}
//Boleto data //Boleto data
if ($payment->getAdditionalInformation("social_security_number")) { if ($payment->getAdditionalInformation("social_security_number")) {
$request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number"); $request['socialSecurityNumber'] = $payment->getAdditionalInformation("social_security_number");
......
...@@ -1010,6 +1010,19 @@ class Data extends AbstractHelper ...@@ -1010,6 +1010,19 @@ class Data extends AbstractHelper
return false; return false;
} }
/**
* @param $paymentMethod
* @return bool
*/
public function isPaymentMethodRatepayMethod($paymentMethod)
{
if (strpos($paymentMethod, 'ratepay') !== false) {
return true;
}
return false;
}
/** /**
* @param $paymentMethod * @param $paymentMethod
* @return bool * @return bool
......
...@@ -106,12 +106,13 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value ...@@ -106,12 +106,13 @@ class InstallmentsPosCloud extends \Magento\Framework\App\Config\Value
protected function _afterLoad() protected function _afterLoad()
{ {
$value = $this->getValue(); $value = $this->getValue();
if(!empty($value)) {
$value = $this->serializer->unserialize($value); $value = $this->serializer->unserialize($value);
if (is_array($value)) { if (is_array($value)) {
$value = $this->encodeArrayFieldValue($value); $value = $this->encodeArrayFieldValue($value);
$this->setValue($value); $this->setValue($value);
} }
}
return $this; return $this;
} }
......
...@@ -219,6 +219,11 @@ class Cron ...@@ -219,6 +219,11 @@ class Cron
*/ */
private $transactionBuilder; private $transactionBuilder;
/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -263,7 +268,8 @@ class Cron ...@@ -263,7 +268,8 @@ class Cron
SearchCriteriaBuilder $searchCriteriaBuilder, SearchCriteriaBuilder $searchCriteriaBuilder,
OrderRepository $orderRepository, OrderRepository $orderRepository,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel, \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder \Magento\Sales\Model\Order\Payment\Transaction\Builder $transactionBuilder,
\Magento\Framework\Serialize\SerializerInterface $serializer
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
...@@ -285,6 +291,7 @@ class Cron ...@@ -285,6 +291,7 @@ class Cron
$this->orderRepository = $orderRepository; $this->orderRepository = $orderRepository;
$this->agreementResourceModel = $agreementResourceModel; $this->agreementResourceModel = $agreementResourceModel;
$this->transactionBuilder = $transactionBuilder; $this->transactionBuilder = $transactionBuilder;
$this->serializer = $serializer;
} }
/** /**
...@@ -501,8 +508,7 @@ class Cron ...@@ -501,8 +508,7 @@ class Cron
$this->_reason = $notification->getPaymentMethod(); $this->_reason = $notification->getPaymentMethod();
$this->_value = $notification->getAmountValue(); $this->_value = $notification->getAmountValue();
$additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : "";
$additionalData = unserialize($notification->getAdditionalData());
// boleto data // boleto data
if ($this->_paymentMethodCode() == "adyen_boleto") { if ($this->_paymentMethodCode() == "adyen_boleto") {
...@@ -672,7 +678,8 @@ class Cron ...@@ -672,7 +678,8 @@ class Cron
{ {
$this->_adyenLogger->addAdyenNotificationCronjob('Updating the Adyen attributes of the order'); $this->_adyenLogger->addAdyenNotificationCronjob('Updating the Adyen attributes of the order');
$additionalData = unserialize($notification->getAdditionalData()); $additionalData = !empty($notification->getAdditionalData()) ? $this->serializer->unserialize($notification->getAdditionalData()) : "";
$_paymentCode = $this->_paymentMethodCode(); $_paymentCode = $this->_paymentMethodCode();
if ($this->_eventCode == Notification::AUTHORISATION if ($this->_eventCode == Notification::AUTHORISATION
......
...@@ -333,7 +333,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel implements Not ...@@ -333,7 +333,7 @@ class Notification extends \Magento\Framework\Model\AbstractModel implements Not
* @param string $additionalData * @param string $additionalData
* @return $this * @return $this
*/ */
public function setAddtionalData($additionalData) public function setAdditionalData($additionalData)
{ {
return $this->setData(self::ADDITIONAL_DATA, $additionalData); return $this->setData(self::ADDITIONAL_DATA, $additionalData);
} }
......
...@@ -145,7 +145,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface ...@@ -145,7 +145,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config['payment'] ['adyenHpp']['ratePayId'] = $this->adyenHelper->getRatePayId(); $config['payment'] ['adyenHpp']['ratePayId'] = $this->adyenHelper->getRatePayId();
// TODO: change the algorithm // TODO: change the algorithm
$config['payment'] ['adyenHpp']['deviceIdentToken'] = md5($this->session->getQuoteId() . date('c')); $config['payment'] ['adyenHpp']['deviceIdentToken'] = hash("sha256",$this->session->getQuoteId() . date('c'));
$config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI']; $config['payment'] ['adyenHpp']['nordicCountries'] = ['SE', 'NO', 'DK', 'FI'];
return $config; return $config;
......
...@@ -980,6 +980,22 @@ ...@@ -980,6 +980,22 @@
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument> <argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments> </arguments>
</type> </type>
<type name="Adyen\Payment\Model\Ui\AdyenCcConfigProvider">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Model\Cron">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<type name="Adyen\Payment\Controller\Process\Json">
<arguments>
<argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument>
</arguments>
</type>
<preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" <preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface"
type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement"/> type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement"/>
<preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" <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