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 bc071ac6 authored by attilak's avatar attilak

Handle response from Checkout API redirect

parent c87b795e
...@@ -87,7 +87,6 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -87,7 +87,6 @@ class Result extends \Magento\Framework\App\Action\Action
$this->_orderHistoryFactory = $orderHistoryFactory; $this->_orderHistoryFactory = $orderHistoryFactory;
$this->_session = $session; $this->_session = $session;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
$this->storeManager = $storeManager;
parent::__construct($context); parent::__construct($context);
} }
...@@ -302,37 +301,33 @@ class Result extends \Magento\Framework\App\Action\Action ...@@ -302,37 +301,33 @@ class Result extends \Magento\Framework\App\Action\Action
protected function _authenticate($response) protected function _authenticate($response)
{ {
if (!empty($response['merchantSig'])) { $merchantSigNotification = $response['merchantSig'];
$merchantSigNotification = $response['merchantSig'];
// do it like this because $_GET is converting dot to underscore // do it like this because $_GET is converting dot to underscore
$queryString = $_SERVER['QUERY_STRING']; $queryString = $_SERVER['QUERY_STRING'];
$result = []; $result = [];
$pairs = explode("&", $queryString); $pairs = explode("&", $queryString);
foreach ($pairs as $pair) { foreach ($pairs as $pair) {
$nv = explode("=", $pair); $nv = explode("=", $pair);
$name = urldecode($nv[0]); $name = urldecode($nv[0]);
$value = urldecode($nv[1]); $value = urldecode($nv[1]);
$result[$name] = $value; $result[$name] = $value;
} }
// do not include the merchantSig in the merchantSig calculation // do not include the merchantSig in the merchantSig calculation
unset($result['merchantSig']); unset($result['merchantSig']);
// Sign request using secret key // Sign request using secret key
$hmacKey = $this->_adyenHelper->getHmac(); $hmacKey = $this->_adyenHelper->getHmac();
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $result); $merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $result);
if (strcmp($merchantSig, $merchantSigNotification) === 0) {
return true;
}
return false;
} else{
// send the payload verification payment\details request to validate the response
if (strcmp($merchantSig, $merchantSigNotification) === 0) {
return true;
} }
return false;
} }
/** /**
......
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