Create payment error message

In order to create a payment I’m using this code:
require(“vendor/autoload.php”);
use Square\Exceptions\ApiException;
use Square\Exceptions;
use Square\ApiHelper;
use Square\Apis\PaymentsApi;
use Square\Models\CancelPaymentByIdempotencyKeyRequest;
use Square\Models\CompletePaymentResponse;
use Square\Models\CreatePaymentRequest;
use Square\Models\CreatePaymentResponse;
use Square\Models\Currency;
use Square\Models\GetPaymentResponse;
use Square\Models\ListPaymentsResponse;
use Square\Models\Payment;
use Square\Models\Money;

use PHPUnit\Framework\TestCase;

$amount_money = new \Square\Models\Money();
$amount_money->setAmount(2000);
$amount_money->setCurrency(‘USD’);

$body = new \Square\Models\CreatePaymentRequest(
‘cnon:CBASEEjQm2rSKpGpWP_8c-T9eWM’,
‘437861’,
$amount_money
);

$api_response = $client->getPaymentsApi()->createPayment($body);

if ($api_response->isSuccess()) {
$result = $api_response->getResult();
} else {
$errors = $api_response->getErrors();
}

I get this error Undefined variable: client Where do I get that variable? thank you.

Did you correctly configure your client:

$client = new SquareClient([
    'accessToken' => 'YOUR SANDBOX ACCESS TOKEN HERE',
    'environment' => Environment::SANDBOX,
]);

Now my problem is this: class SquareClient don’t found

:wave: To use the Square API, you import the Client class, instantiate a Client object, and initialize it with the appropriate access token. Here’s how:

Instantiate a SquareClient object with the access token for the Square account whose resources you want to manage. To access sandbox resources, initialize the SquareClient with environment set to sandbox:

use Square\SquareClient;
use Square\Environment;

$client = new SquareClient([
    'accessToken' => 'YOUR SANDBOX ACCESS TOKEN HERE',
    'environment' => Environment::SANDBOX
]);

To access production resources, set environment to production:

use Square\SquareClient;
use Square\Environment;

$client = new SquareClient([
    'accessToken' => 'YOUR PRODUCTION ACCESS TOKEN HERE',
    'environment' => Environment::PRODUCTION
]);

To set a custom environment provide a customUrl, and set the environment to

Environment::CUSTOM:
use Square\SquareClient;
use Square\Environment;

$client = new SquareClient([
    'accessToken' => 'YOUR ACCESS TOKEN HERE',
    'environment' => Environment::CUSTOM,
    'customUrl' => 'https://your.customdomain.com'
]);

For more please see the README.md of the SDK. :slightly_smiling_face:

Thank you very much for your help