Commit f2e0d94f authored by attilak's avatar attilak

Handle both old HPP and the new checkout api flow

Response will be handled in PW-705
parent 9f43b97c
......@@ -302,32 +302,36 @@ class Result extends \Magento\Framework\App\Action\Action
protected function _authenticate($response)
{
$merchantSigNotification = $response['merchantSig'];
// do it like this because $_GET is converting dot to underscore
$queryString = $_SERVER['QUERY_STRING'];
$result = [];
$pairs = explode("&", $queryString);
foreach ($pairs as $pair) {
$nv = explode("=", $pair);
$name = urldecode($nv[0]);
$value = urldecode($nv[1]);
$result[$name] = $value;
}
if (!empty($response['merchantSig'])) {
$merchantSigNotification = $response['merchantSig'];
// do it like this because $_GET is converting dot to underscore
$queryString = $_SERVER['QUERY_STRING'];
$result = [];
$pairs = explode("&", $queryString);
foreach ($pairs as $pair) {
$nv = explode("=", $pair);
$name = urldecode($nv[0]);
$value = urldecode($nv[1]);
$result[$name] = $value;
}
// do not include the merchantSig in the merchantSig calculation
unset($result['merchantSig']);
// do not include the merchantSig in the merchantSig calculation
unset($result['merchantSig']);
// Sign request using secret key
$hmacKey = $this->_adyenHelper->getHmac();
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $result);
// Sign request using secret key
$hmacKey = $this->_adyenHelper->getHmac();
$merchantSig = \Adyen\Util\Util::calculateSha256Signature($hmacKey, $result);
if (strcmp($merchantSig, $merchantSigNotification) === 0) {
return true;
}
if (strcmp($merchantSig, $merchantSigNotification) === 0) {
return true;
}
return false;
} else{
// send the payload verification payment\details request to validate the response
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