diff --git a/src/Services/HostedService.php b/src/Services/HostedService.php index 113136b..74f02b7 100644 --- a/src/Services/HostedService.php +++ b/src/Services/HostedService.php @@ -141,12 +141,12 @@ public function parseResponse($response, $encoded = false) $response = $this->mapTransactionStatusResponse($response); } - $timestamp = $response["TIMESTAMP"]; - $merchantId = $response["MERCHANT_ID"]; - $orderId = $response["ORDER_ID"]; - $result = $response["RESULT"]; - $message = $response["MESSAGE"]; - $transactionId = $response["PASREF"]; + $timestamp = $response["TIMESTAMP"] ?? ""; + $merchantId = $response["MERCHANT_ID"] ?? ""; + $orderId = $response["ORDER_ID"] ?? ""; + $result = $response["RESULT"] ?? ""; + $message = $response["MESSAGE"] ?? ""; + $transactionId = $response["PASREF"] ?? ""; $authCode = $response["AUTHCODE"] ?? ""; $paymentMethod = $response["PAYMENTMETHOD"] ?? ""; diff --git a/test/Integration/Gateways/GpEcomConnector/HppTest.php b/test/Integration/Gateways/GpEcomConnector/HppTest.php index bc19e54..56062b2 100644 --- a/test/Integration/Gateways/GpEcomConnector/HppTest.php +++ b/test/Integration/Gateways/GpEcomConnector/HppTest.php @@ -1099,6 +1099,30 @@ public function testProcessPaymentConsumeResponse() $this->assertEquals("00", $responseCode); } + public function testParseResponseWithoutUppercaseKeysDoesNotWarn() + { + $service = new HostedService($this->config()); + + $response = []; + $response["SHA1HASH"] = GenerationUtils::generateNewHash( + "secret", + implode('.', ["", "", "", "", "", "", ""]), + ShaHashType::SHA1 + ); + + set_error_handler(function ($errno, $errstr) { + throw new \ErrorException($errstr); + }); + try { + $parsedResponse = $service->parseResponse(json_encode($response)); + } finally { + restore_error_handler(); + } + + $this->assertNotNull($parsedResponse); + $this->assertEquals("", $parsedResponse->responseCode); + } + /* 06. CardStorageCreatePayerStoreCardResponse */ public function testCardStorageCreatePayerStoreCardResponse()