credit cards, denim, jeans-1583534.jpg

The official authorize.net sdk for PHP has been all but abandoned…

I think this thread titled “No 8.1 support in 2023 is actually insane.” says it perfectly.

Here is a major payment provider whose clients are required to be PCI compliant offering an official piece of software that is not able to run on PCI compliant systems.

Anyway, in order to get this running on php 8.2 for our client’s simple payment form, we included the 8.1 fixes that the kind folks in the thread provider along with one additional fix for Log.php that was needed for our use case in 8.2. 

2 People in the thread “forked” the authorize.net repo, but we were not comfortable switching to an unofficial fork as its possible those repos could get compromised or disappear.  In the case of disappearing it would leave a mystery of what to do in the future.  And in the case of compromised – well that would be bad.

So my method was to do composer patching.

composer require cweagans/composer-patches

In my case I had an issue with some legacy packages and actually had to do:

composer require cweagans/composer-patches:*

Then download this patch zip file, extract it, and put the patches folder in the root of your project.

Then make sure your composer.json includes the below.

				
					    "config": {
        "allow-plugins": {
            "cweagans/composer-patches": true
        }
    },
    "extra": {
        "patches": {
            "authorizenet/authorizenet": [
                "patches/authorizenet-authorizenet-lib-net-authorize-api-contract-v1-updatesplittendergrouprequest-php.patch",
                "patches/authorizenet-authorizenet-lib-net-authorize-util-log-php.patch"
            ]
        }
    }
				
			

Now when you install authroize.net you will see the below telling you the patches are being ran.  That’s it, now you have a portable composer patch off the official repo.  This feels safer to me and if the official repo ever gets 8.2 support, I can just pull my patches out.

				
					$ composer install
...
Gathering patches for dependencies. This might take a minute.
  - Installing authorizenet/authorizenet (2.0.2): Extracting archive
  - Applying patches for authorizenet/authorizenet
    patches/authorizenet-authorizenet-lib-net-authorize-api-contract-v1-updatesplittendergrouprequest-php.patch (0)


				
			

Our clients use case is very simple, so I cannot guarantee this will solve all the php 8.2 problems in the library as we didn’t have budget to explore this any further.  Hopefully it works for you.  

Leave a Comment

Your email address will not be published. Required fields are marked *