How do I change the Square Version in a PHP request?

I have my site setup to make a createPaymentLink, and it’s working just fine. But when I look in the API logs in the account, every call from my site shows the Square Version as 2022-10-19. When I go into the app settings on the square site for the app I’m working with, it shows the API Version is set to “2022-11-16 (Latest)”. I have also updated the SDK version on my site to version 24.0.0.20221116, the newest SDK available. So why are the API logs still showing that calls from my site are using version 2022-10-19?

Also, when I use the API explorer on the square developer site, and I use the createPaymentLink API explorer, the version at the top right is set to 2022-11-16. When I run the sample code, the API Logs show that the call is using version 2022-11-16. But there is no code in the example code setting the version number. And when I change the version in the top-right on the explorer page to any version other than the newest one, the sample code box switches to only show CURL examples - I can no longer see PHP example code. So I can tell in the CURL code where it is setting the version, but where do I set the version in my PHP code?

I figured out the answer myself through another question someone asked about changing the square version through C#. I feel like this is pretty important information that should be documented somewhere obvious though. In case anyone else needs the answer, when you initialize a new square client object, you can include the ‘squareVersion’ variable as a string or pre-defined variable set to the version you want to use (‘2022-11-16’, or ‘2022-10-19’, etc)

$client = new \Square\SquareClient([
  'accessToken' => SQUARE_ACCESS_TOKEN,
  'environment' => SQUARE_ENVIRONMENT,
  'squareVersion' => SQUARE_VERSION
]);

However, this makes me wonder something else. Where is the “default” squareVersion coming from?!? Like I said, I have set the API version to ‘2022-11-16’ in my square app settings on the square dashboard, and I have also updated the SDK on my server to the newest version (24.0.0.20221116), which should correlate to the ‘squareVersion’ of ‘2022-11-16’, but when I don’t include the ‘squareVersion’ variable in my initialization of the square client object, the version defaults to ‘2022-10-19’. Where is it getting that from?

I also just noticed that when I specify the ‘squareVersion’ as ‘2022-11-16’ in my square client initialization, the request header shown in the API logs includes these 2 lines

square-version: 2022-11-16
user-agent: Square-PHP-SDK/24.0.0.20221116 (2022-11-16) Zend/3.2.0 (Linux-2.6.32-954.3.5.lve1.4.89.el6.x86_64)

But when I don’t specify the ‘squareVersion’ variable in my square client initialization, the request header shown in the API logs includes these 2 lines

square-version: 2022-10-19
user-agent: Square-PHP-SDK/24.0.0.20221116 (2022-10-19) Zend/3.2.0 (Linux-2.6.32-954.3.5.lve1.4.89.el6.x86_64)

So the user-agent is looking at the actual SDK value on my server, but it’s also combining it with the squareVersion. But again, why is it defaulting to an older version if I don’t specify it? Where is that value coming from? Shouldn’t it be coming from the SDK files somewhere?

I found the problem. I updated my square SDK using composer last week. Apparently when I did that, 7 out of 2000+ files were not updated. I’m not sure how or why, but I just downloaded the version 24 SDK manually and ran a CRC comparison of all files in the SDK versus the files on my webserver that were updated via composer.

But in case anyone in the future wants to know where the default version of the requests sent by the SDK is set, it’s in
vendor\square\square\src\ConfigurationDefaults.php

Glad to hear you were able to find where the version is configured. :slightly_smiling_face: