Error [number 1] During inheritance of JsonSerializable: Uncaught ; File: folder_name/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MerchantAuthenticationType.php; Line: 11
Error [number 8192] Return type of net\authorize\api\contract\v1\MerchantAuthenticationType::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice; File: folder_name/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MerchantAuthenticationType.php; Line: 261
05-09-2023 05:49 AM
If anyone with the same problem comes across this message: in the end, we fixed it ourselves without any help from Authorize.net (can you tell how angry I am about their lack of support?). We took the advice of jdpace2 in the Issues section of the Github repo (https://github.com/AuthorizeNet/sdk-php/issues/440#issuecomment-1622942466
Search for all instances of
public function jsonSerialize()
Replace them with:
#[\ReturnTypeWillChange]
public function jsonSerialize()
This allowed us to move to PHP 8.1 without any issues. It's not a perfect solution, but it works for now.
08-22-2023 03:08 AM
I encountered a
PHP Fatal error
when we upgraded to PHP 8.0 from PHP7.4 (PHP 8 Support for AuthorizeNet/sdk-php). Eventually Authorize.net did update the version to 2.0.2 which resolved the error. I am hopeful someone from the Authorize.net development team will bump the version to 2.0.3 and properly resolve the return type issue.
The new issue caused by upgrading to PHP 8.1 from PHP 8.0 (PHP 8.0 is EOL as of 11-26-2023) is the same error that @iteracy received:
Deprecated [description] => Return type of net\authorize\api\contract\v1\MerchantAuthenticationType::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [file]
The workaround was to fork the https://github.com/AuthorizeNet/sdk-php and do a search and replace for all references of
public function jsonSerialize(){
then replace this with
#[\ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
Based on the error message I received, specifying the return type to mixed and/or adding #[\ReturnTypeWillChange] will temporarily suppress the notice. I tested the fork with our PHPUnit test suite and the errors went away and the warning message went away. You can use our version of the AuthorizeNet/sdk-php -> https://github.com/resumeblaze/sdk-php.
You can see there were 528 additions and 178 deletions: https://github.com/AuthorizeNet/sdk-php/compare/master...resumeblaze:sdk-php:master. Then number of changes is inline with other users that have come across the same issue, for examplehttps://github.com/AuthorizeNet/sdk-php/compare/master...zhartaunik:authorizenet-sdk-php:master.
Its important to note this does not fix the problem, it will suppress the notice so that you may use the package with PHP 8.1.
01-04-2024 01:12 AM - edited 01-04-2024 01:15 AM
I can't believe they still haven't fixed this
01-05-2024 12:27 AM
Here is an update from support. Looks like support can't help with this issue and the case was automatically closed.
Thank you for contacting Authorize.Net in regard to integration, happy to assist.
I understand that you need assistance on the compatibility of PHP versions. We apologize, but we are not trained in web development or integration, so our ability to answer developer or integration related questions is limited. We can only assist for some basic troubleshooting steps about integration.
We appreciate your time and business.
If the information provided above satisfies your needs, please close this Support Case. Otherwise, please add an update to this Support Case with your follow-up questions so I can further assist you. For your convenience the Authorize.Net Support Center, located at: https://support.authorize.net. You may also call us at (877) 447-3938, available 24 hours a day, 7 days a week.
For more information regarding our privacy practices, visit the privacy page at Authorize.Net.
01-08-2024 10:42 AM
One more update! I spoke to someone at Authorize.net today and they are aware of the issue. They have been contacted by several merchants encountering the same error. Keep the pressure on the support team and open tickets at https://support.authorize.net/. They said they will update the SDK soon. Make sure to point out that PHP 8.1 is the current (stable version of PHP). 8.0 is no longer supported: https://www.php.net/supported-versions.php.
01-09-2024 03:17 PM
It appears that when you upgrade to PHP 8.2, there is another subtle error. The latest release of PHP is 8.2, not 8.1. There are only security updates for PHP 8.1 for the next 10-months. 8.2 is in active development for the next 10-months. See
https://www.php.net/supported-versions.php
/authorizenet/lib/net/authorize/util/Log.php:366
Creation of dynamic property net\authorize\util\Log::$sensitiveStringRegexes is deprecated
This is a simple fix, go to:
sdk-php/lib/net/authorize/util/Log.php on line 34 and add a declaration.
private $sensitiveStringRegexes = NULL;
The warning will go away. I have made this change to the forked repository at https://github.com/resumeblaze/sdk-php/releases/tag/2.0.4
I bumped our forked version from 2.0.3 to 2.0.4
01-11-2024 12:50 AM