PHP client library for the Square Connect v2 API

2.0.2 2017-02-01 17:36 UTC


This repository contains a generated PHP client SDK for the Square Connect APIs v2. Check out our API specification repository for the specification and template files we used to generate this.

If you are looking for a sample e-commerce application using these APIs, check out the connect-api-examples repository.

To learn more about the Square APIs in general, head on over to the Square API documentation



With Composer

The PHP SDK is available on Packagist. To add it to Composer, simply run:

$ php composer.phar require square/connect

Or add this line under "require" to your composer.json:

"require": {
    "square/connect": "*",

And then install your composer dependencies with

$ php composer.phar install
From GitHub

Clone this repository, or download the zip into your project's folder and then add the following line in your code:


Note: you might have to change the path depending on your project's folder structure.

Getting Started

Please follow the installation procedure and then run the following:

require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new SquareConnect\Api\CheckoutApi();
$authorization = "authorization_example"; // string | The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
$location_id = "location_id_example"; // string | The ID of the business location to associate the checkout with.
$body = new \SquareConnect\Model\CreateCheckoutRequest(); // \SquareConnect\Model\CreateCheckoutRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $api_instance->createCheckout($authorization, $location_id, $body);
} catch (Exception $e) {
    echo 'Exception when calling CheckoutApi->createCheckout: ', $e->getMessage(), PHP_EOL;


Documentation for API Endpoints

All URIs are relative to https://connect.squareup.com

Class Method HTTP request Description
CheckoutApi createCheckout POST /v2/locations/{location_id}/checkouts CreateCheckout
CustomerApi createCustomer POST /v2/customers CreateCustomer
CustomerApi deleteCustomer DELETE /v2/customers/{customer_id} DeleteCustomer
CustomerApi listCustomers GET /v2/customers ListCustomers
CustomerApi retrieveCustomer GET /v2/customers/{customer_id} RetrieveCustomer
CustomerApi updateCustomer PUT /v2/customers/{customer_id} UpdateCustomer
CustomerCardApi createCustomerCard POST /v2/customers/{customer_id}/cards CreateCustomerCard
CustomerCardApi deleteCustomerCard DELETE /v2/customers/{customer_id}/cards/{card_id} DeleteCustomerCard
LocationApi listLocations GET /v2/locations ListLocations
RefundApi createRefund POST /v2/locations/{location_id}/transactions/{transaction_id}/refund CreateRefund
RefundApi listRefunds GET /v2/locations/{location_id}/refunds ListRefunds
TransactionApi captureTransaction POST /v2/locations/{location_id}/transactions/{transaction_id}/capture CaptureTransaction
TransactionApi charge POST /v2/locations/{location_id}/transactions Charge
TransactionApi listTransactions GET /v2/locations/{location_id}/transactions ListTransactions
TransactionApi retrieveTransaction GET /v2/locations/{location_id}/transactions/{transaction_id} RetrieveTransaction
TransactionApi voidTransaction POST /v2/locations/{location_id}/transactions/{transaction_id}/void VoidTransaction

Documentation For Models


Send bug reports, feature requests, and code contributions to the API specifications repository, as this repository contains only the generated SDK code. If you notice something wrong about this SDK in particular, feel free to raise an issue here.


Copyright 2017 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.