square/connect

PHP client library for the Square Connect v2 API


README

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

Requirements

Installing

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:

require('connect-php-sdk/autoload.php');

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:

<?php
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);
    print_r($result);
} 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

Documentation For Authorization

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://connect.squareup.com/oauth2/authorize?<PARAMETERS>
  • Scopes:
  • MERCHANT_PROFILE_READ: GET endpoints related to a merchant's business and location entities. Almost all Connect API applications need this permission in order to obtain a merchant's location IDs
  • PAYMENTS_READ: GET endpoints related to transactions and refunds
  • PAYMENTS_WRITE: POST, PUT, and DELETE endpoints related to transactions and refunds. E-commerce applications must request this permission
  • CUSTOMERS_READ: GET endpoints related to customer management
  • CUSTOMERS_WRITE: POST, PUT, and DELETE endpoints related to customer management
  • SETTLEMENTS_READ: GET endpoints related to settlements (deposits)
  • BANK_ACCOUNTS_READ: GET endpoints related to a merchant's bank accounts
  • ITEMS_READ: GET endpoints related to a merchant's item library
  • ITEMS_WRITE: POST, PUT, and DELETE endpoints related to a merchant's item library
  • ORDERS_READ: GET endpoints related to a merchant's Square online store.
  • ORDERS_WRITE: POST, PUT, and DELETE endpoints related to a merchant's Square online store
  • EMPLOYEES_READ: GET endpoints related to employee management
  • EMPLOYEES_WRITE: POST, PUT, and DELETE endpoints related to employee management
  • TIMECARDS_READ: GET endpoints related to employee timecards
  • TIMECARDS_WRITE: POST, PUT, and DELETE endpoints related to employee timecards

Contributing

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.

License

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.