We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit ab20f519 authored by Alexandros Moraitis's avatar Alexandros Moraitis Committed by GitHub

Separate Checks IP and HMAC (#809)

* Separate Checks IP and HMAC

* Merge the if statements
parent c36a919e
...@@ -205,29 +205,28 @@ class Json extends \Magento\Framework\App\Action\Action ...@@ -205,29 +205,28 @@ class Json extends \Magento\Framework\App\Action\Action
*/ */
protected function _processNotification($response, $notificationMode) protected function _processNotification($response, $notificationMode)
{ {
if ($this->configHelper->getNotificationsIpCheck()) { //Validate if Ip check is enabled and if the notification comes from a verified IP
//Validate if the notification comes from a verified IP if ($this->configHelper->getNotificationsIpCheck() && !$this->isIpValid()) {
if (!$this->isIpValid()) { $this->_adyenLogger->addAdyenNotification(
"Notification has been rejected because the IP address could not be verified"
);
return false;
}
if ($this->configHelper->getNotificationsHmacCheck() && $this->hmacSignature->isHmacSupportedEventCode(
$response
)) {
//Validate the Hmac calculation
if (!$this->hmacSignature->isValidNotificationHMAC(
$this->configHelper->getNotificationsHmacKey(),
$response
)) {
$this->_adyenLogger->addAdyenNotification( $this->_adyenLogger->addAdyenNotification(
"Notification has been rejected because the IP address could not be verified" 'HMAC key validation failed ' . print_r($response, 1)
); );
return false; return false;
} }
if ($this->configHelper->getNotificationsHmacCheck()) {
if ($this->hmacSignature->isHmacSupportedEventCode($response)) {
//Validate the Hmac calculation
if (!$this->hmacSignature->isValidNotificationHMAC(
$this->configHelper->getNotificationsHmacKey(),
$response
)) {
$this->_adyenLogger->addAdyenNotification(
'HMAC key validation failed ' . print_r($response, 1)
);
return false;
}
}
}
} }
// validate the notification // validate the notification
if ($this->authorised($response)) { if ($this->authorised($response)) {
// log the notification // log the notification
......
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