Skip to content

Commit e960b85

Browse files
authored
Merge pull request PAYONE-GmbH#562 from FatchipRobert/MAG2-324-HashFix
MAG2-324 - Fixed a problem with hash function
2 parents 0124ca7 + ff5f44f commit e960b85

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Helper/Toolkit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,14 @@ public function generateUUIDv4()
264264
* Returns a hashed string and defines a default through the sAlgorithm parameter
265265
*
266266
* @param string $sString
267+
* @param string $sAlgorithm
268+
* @param string $sKey
267269
* @return string
268270
*/
269271
public function hashString($sString, $sAlgorithm = 'sha384', $sKey = false)
270272
{
271273
if ($sAlgorithm == "sha384" && $sKey !== false) {
272-
return hash_hmac($sAlgorithm, $sString, $sKey);
274+
return hash_hmac($sAlgorithm, $sString, $sKey ?? '');
273275
}
274276
return hash($sAlgorithm, $sString);
275277
}

Test/Unit/Helper/RatepayTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,22 @@ public function testRefreshProfiles()
140140
{
141141
$aShopConfig = [['shop_id' => '12345', 'currency' => 'EUR']];
142142
$this->scopeConfig->method('getValue')->willReturn(json_encode($aShopConfig));
143+
$this->profile->method('sendRequest')->willReturn(['status' => 'OK']);
143144

144145
$result = $this->classToTest->refreshProfiles('payone_ratepay_invoice');
145146
$this->assertNull($result);
146147
}
147148

149+
public function testRefreshProfilesException()
150+
{
151+
$aShopConfig = [['shop_id' => '12345', 'currency' => 'EUR']];
152+
$this->scopeConfig->method('getValue')->willReturn(json_encode($aShopConfig));
153+
$this->profile->method('sendRequest')->willReturn(['status' => 'ERROR']);
154+
155+
$this->expectException(\Exception::class);
156+
$this->classToTest->refreshProfiles('payone_ratepay_invoice');
157+
}
158+
148159
public function testGetRatepayDeviceFingerprintToken()
149160
{
150161
$this->checkoutSession->method('getPayoneRatepayDeviceFingerprintToken')->willReturn(null);

0 commit comments

Comments
 (0)