getCheckoutApi() Error Message

How do we resolve the following error message?

Uncaught Error: Call to a member function getCheckoutApi() on null in …

Do you have more of the error message or the body of the request so we can take a closer look? :slightly_smiling_face:

As requested, you may refer to the following error. I’ve tried solving this matter to no avail. for several hours.

We are not able to receive payments from our clients to-date because of the migration from SqPaymentForm to Web Payments SDK.

We are using the Web Payments SDK PHP project that Lance from the Square Web Development team provided. [PHP Payment Example Project] connect-api-examples/connect-examples/v2/php_payment at master · square/connect-api-examples · GitHub

ERROR MESSAGE:

Fatal error : Uncaught TypeError: Square\ApiHelper::appendUrlWithTemplateParameters(): Argument #1 ($url) must be of type string, null given, called in /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/vendor/square/square/src/SquareClient.php on line 304 and defined in /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/vendor/square/square/src/ApiHelper.php:47 Stack trace: #0 /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/vendor/square/square/src/SquareClient.php(304): Square\ApiHelper::appendUrlWithTemplateParameters() #1 /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/vendor/square/square/src/Apis/LocationsApi.php(176): Square\SquareClient->getBaseUri() #2 /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/utils/location-info.php(32): Square\Apis\LocationsApi->retrieveLocation() #3 /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/utils/location-info.php(51): LocationInfo->__construct() #4 /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/index.php(3): include(‘…’) #5 {main} thrown in /webroot/f/l/flocc001/acceptpayment.net/www/giftcards/payment/vendor/square/square/src/ApiHelper.php on line 47

It sounds like the SquareClient.php isn’t correctly configured. Were you first able to get it working by just following the README.md? :slightly_smiling_face:

We relaunched COMPOSER UPDATE and executed the following command line script.

php composer.phar install

After executing the above command line script, a Vendor folder was created with various dependencies (or other folders and files)

Please help!

Great! Did you then create a new file .env by copying the contents of the .env.example file and edit this file with your application credentials and environment configuration. WARNING : never save your credentials in your code. :slightly_smiling_face:

Yes, the .env file was updated accordingly or as directed.