Hello,
I encountered a TypeError when running the SDK on PHP 8.4. Here are the details of the issue:
Description
On PHP 8.4+ with strict types enabled, a TypeError occurs when the Comgate API returns a response where the message field is null or missing (which happens during some successful payment status checks).
Error message
Fatal error: Uncaught TypeError: Comgate\SDK\Entity\Response\PaymentStatusResponse::setMessage(): Argument #1 ($message) must be of type string, null given, called in .../vendor/comgate/sdk/src/Entity/Response/PaymentStatusResponse.php on line 133
Cause
In Comgate\SDK\Entity\Response\PaymentStatusResponse::__construct (around line 128-129):
$code = (int) $parsedResponse['code'];
$message = $parsedResponse['message'];
If $parsedResponse['message'] is missing or null, $message is null. The subsequent call to setMessage($message) fails because the method is strictly typed:
public function setMessage(string $message): PaymentStatusResponse
Proposed solution
Cast the message to string or fallback to an empty string in the constructor:
$message = (string) ($parsedResponse['message'] ?? '');
Hello,
I encountered a TypeError when running the SDK on PHP 8.4. Here are the details of the issue:
Description
On PHP 8.4+ with strict types enabled, a TypeError occurs when the Comgate API returns a response where the message field is null or missing (which happens during some successful payment status checks).
Error message
Fatal error: Uncaught TypeError: Comgate\SDK\Entity\Response\PaymentStatusResponse::setMessage(): Argument #1 ($message) must be of type string, null given, called in .../vendor/comgate/sdk/src/Entity/Response/PaymentStatusResponse.php on line 133
Cause
In Comgate\SDK\Entity\Response\PaymentStatusResponse::__construct (around line 128-129):
$code = (int) $parsedResponse['code'];
$message = $parsedResponse['message'];
If $parsedResponse['message'] is missing or null, $message is null. The subsequent call to setMessage($message) fails because the method is strictly typed:
public function setMessage(string $message): PaymentStatusResponse
Proposed solution
Cast the message to string or fallback to an empty string in the constructor:
$message = (string) ($parsedResponse['message'] ?? '');