API error on my existing webiste code

Hello, I have this code obtained, I need to obtain broken down information, to be stored in the database table Mysql

require ‘vendor/autoload.php’;
use Square\SquareClient;
use Square\LocationsApi;
use Square\Exceptions\ApiException;
use Square\Models\ListLocationsResponse;
use Square\Environment;
use Square\Models\Money;
use Square\Models\CreatePaymentRequest;
use Square\Models\createPayment;
use Square\Models\Transaction;

$data = json_decode(file_get_contents(‘php://input’), true);
$squareClient = new SquareClient([
‘accessToken’ => ‘XXXXXX’,
‘environment’ => Environment::SANDBOX,

$payments_api = $squareClient->getPaymentsApi();
$money = new Money();
$amount = $_REQUEST[‘amount’] * 100;

$orderId = rand(9000,1000);
$create_payment_request = new CreatePaymentRequest($data[‘sourceId’], $orderId, $money);

$response = $payments_api->createPayment($create_payment_request);
if ($response->isSuccess()) {

“This is where I need to do the process to save information to the database table”

$order = new Square\Models\Order(“location_id_here”);
$order->cart_number = $response[‘cart_number’];
$order->expiry_date = $response[‘expiry_date’];
$order->cvc_code = $response[‘cvc_code’];
$order->payment_method = ‘Prepaid’;
$order->total = $amount;

// Insert into the database
echo json_encode($response->getResult());
} else {
echo json_encode($response->getErrors());

My website: wcuniforms

Once the payment is completed you will get a response from Square that you can pars and save to your database. :slightly_smiling_face: