Skip to content

Commit

Permalink
MAG2-304 - Changed Client API hash mechanic
Browse files Browse the repository at this point in the history
  • Loading branch information
FatchipRobert committed Feb 5, 2024
1 parent 5791d9e commit 89959f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions Helper/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ public function getHostedIframeRequestCCHash()
$this->getConfigParam('portalid').
'creditcardcheck'.
'JSON'.
'yes'.
$this->getConfigParam('key');
return $this->toolkitHelper->hashString($sStringToHash, 'sha384');
'yes';
return $this->toolkitHelper->hashString($sStringToHash, 'sha384', $this->getConfigParam('key'));
}

/**
Expand All @@ -140,9 +139,8 @@ public function getBankaccountCheckRequestHash()
$this->getConfigParam('mode', PayoneConfig::METHOD_CREDITCARD, 'payone_payment').
$this->getConfigParam('portalid').
'bankaccountcheck'.
'JSON'.
$this->getConfigParam('key');
return $this->toolkitHelper->hashString($sStringToHash, 'sha384');
'JSON';
return $this->toolkitHelper->hashString($sStringToHash, 'sha384', $this->getConfigParam('key'));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Helper/Toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ public function generateUUIDv4()
* @param string $sString
* @return string
*/
public function hashString($sString, $sAlgorithm = 'md5')
public function hashString($sString, $sAlgorithm = 'md5', $sKey = false)
{
if ($sAlgorithm == "sha384" && $sKey !== false) {
return hash_hmac($sAlgorithm, $sString, $sKey);
}
return hash($sAlgorithm, $sString);
}
}

0 comments on commit 89959f3

Please sign in to comment.