From 9efd5548a4fbe1ff184b02ba3f36233dae3654cc Mon Sep 17 00:00:00 2001 From: Djoyke Reijans <115019123+DjoykeAbyah@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:21:06 +0200 Subject: [PATCH] added test for merchantReference with space (#701) * added test for merchantReference with space * removed extra space after test * removed extra whitespace * removed extra whitespace --- tests/Unit/Util/HmacSignatureTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/Unit/Util/HmacSignatureTest.php b/tests/Unit/Util/HmacSignatureTest.php index c6f8a32e..9a16a80b 100644 --- a/tests/Unit/Util/HmacSignatureTest.php +++ b/tests/Unit/Util/HmacSignatureTest.php @@ -57,6 +57,27 @@ public function testNotificationRequestItemHmac() $this->fail('Unexpected exception'); } } + + public function testMerchantReferenceWithSpace() + { + $params = json_decode('{ + "pspReference": "7914073381342284", + "merchantAccountCode": "TestMerchant", + "merchantReference": " TestPayment-1407325143704", + "amount": { + "value": 1130, + "currency": "EUR" + }, + "eventCode": "AUTHORISATION", + "success": "true" + }', true); + $hmacKey = "DFB1EB5485895CFA84146406857104ABB4CBCABDC8AAF103A624C8F6A3EAAB00"; + $hmac = new HmacSignature(); + $hmacCalculation = $hmac->calculateNotificationHMAC($hmacKey, $params); + $expectedHmac = "kLZtgnXU86m/yjnpBD4aqESFgnoDcy1fGOP1Db/L3+4="; + $this->assertEquals($expectedHmac, $hmacCalculation, "The recalculated HMAC does not match the expected value."); + } + public function testHmacSignatureForRefundWithZeroValue() { $params = json_decode('{