1. Go to this page and download the library: Download square/connect library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
square / connect example snippets
use SquareConnect\Configuration;
use SquareConnect\ApiClient;
$access_token = 'YOUR_ACCESS_TOKEN';
# setup authorization
$api_config = new Configuration();
$api_config->setHost("https://connect.squareup.com");
$api_config->setAccessToken($access_token);
$api_client = new ApiClient($api_config);
use Square\SquareClient;
use Square\Environment;
// Initialize the Square client.
$api_client = new SquareClient([
'accessToken' => "YOUR_ACCESS_TOKEN",
'environment' => Environment::SANDBOX
]); // In production, the environment arg is 'production'
# Fail if the card form didn't send a value for `nonce` to the server
$nonce = $_POST['nonce'];
if (is_null($nonce)) {
echo "Invalid card data";
http_response_code(422);
return;
}