Unexpected token

Greetings I’m trying to use the quick start project template to take a payments but it isn’t working, in console i get this message unexpected token < in JSON at position 0
and I have no idea what’s wrong.thank you in advance.

:wave: Have you checked the JSON of the request to see if it’s a valid request body? :slightly_smiling_face:

Hello yes, it is correct because I am using quick start sample project and I only changed the keys of my app I did it exactly as the example online so I don’t see where the problem is.
This is the url where I’m testing it: Square Web Payments Quickstart

Looking at the logs you are successfully creating a token for the payment request. Also I see that you have just successfully taken a payment. Did you figure out the issue?

Yes, I generate token with this:

<div id="card-container"></div>

<button id="card-button" type="button">Pay</button>
my problem now is with the payment I use this code: <?php $token = ""; if (isset($_POST["token"])) {
$token = $_POST["token"];

}

$precio = “”;
if (isset($_POST[“precio”])) {

$precio = $_POST["precio"];

}

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 Square\Models\SquareClient;

use PHPUnit\Framework\TestCase;

$client = new SquareClient([
‘accessToken’ => ‘11111’,
‘environment’ => Environment::SANDBOX,
]);

$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 the error class SquareClient don’t found I’m new at this so I am a little lost.

Everything looks to be correct. Did you setup a .env ?