Square Connect PHP SDK

June 29, 2020 ยท View on GitHub

Square logo

Square Connect PHP SDK


Build Status PHP version Apache-2 license

NOTICE: Square Connect PHP SDK will be replaced in Q2, 2020

This Square Connect SDK will enter a security maintenance phase in Q2 2020 and will be RETIRED (EOL) in Q4 2020. In the security maintenance phase, this SDK will continue to receive support and security patches but will no longer receive bug fixes or product updates. Once it is retired, support and security patches will no longer be available. A new SDK, more bespoke to the language, will be available once this SDK enters its security maintenance phase. The SDK itself will continue to work indefinitely until such time that the underlying APIs are retired at which point portions of the SDK may stop functioning. For a full list of API retirement dates, please see our Square API Lifecycle documentation.

Security MaintenanceNew SDK ReleaseRetired (EOL)
Q2, 2020Q2, 2020Q4, 2020

If you have feedback about the new SDKs, or just want to talk to other Square Developers, request an invite to the new slack community for Square Developers

This repository contains a generated PHP client SDK for the Square Connect APIs. 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

Option 1: 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
Option 2: 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.

Option 3: Without Command Line Access

If you cannot access the command line for your server, you can also install the SDK from github. Download the SDK from github with this link, unzip it and add the following line to your php files that will need to access the SDK:

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

Note: you might have to change the path depending on where you place the SDK in relation to your other php files.

Getting Started

Please follow the installation procedure:

Retrieve your location IDs

require 'vendor/autoload.php';

$access_token = 'YOUR_ACCESS_TOKEN';
# setup authorization
$api_config = new \SquareConnect\Configuration();
$api_config->setHost("https://connect.squareup.com");
$api_config->setAccessToken($access_token);
$api_client = new \SquareConnect\ApiClient($api_config);
# create an instance of the Location API
$locations_api = new \SquareConnect\Api\LocationsApi($api_client);

try {
  $locations = $locations_api->listLocations();
  print_r($locations->getLocations());
} catch (\SquareConnect\ApiException $e) {
  echo "Caught exception!<br/>";
  print_r("<strong>Response body:</strong><br/>");
  echo "<pre>"; var_dump($e->getResponseBody()); echo "</pre>";
  echo "<br/><strong>Response headers:</strong><br/>";
  echo "<pre>"; var_dump($e->getResponseHeaders()); echo "</pre>";
  exit(1);
}

Charge the card nonce

require 'vendor/autoload.php';

$access_token = 'YOUR_ACCESS_TOKEN';

# setup authorization
$api_config = new \SquareConnect\Configuration();
$api_config->setHost("https://connect.squareup.com");
$api_config->setAccessToken($access_token);
$api_client = new \SquareConnect\ApiClient($api_config);

# create an instance of the Payments API class
$payments_api = new \SquareConnect\Api\PaymentsApi($api_client);
$location_id = 'YOUR_LOCATION_ID'
$nonce = 'YOUR_NONCE'

$body = new \SquareConnect\Model\CreatePaymentRequest();

$amountMoney = new \SquareConnect\Model\Money();

# Monetary amounts are specified in the smallest unit of the applicable currency.
# This amount is in cents. It's also hard-coded for \$1.00, which isn't very useful.
$amountMoney->setAmount(100);
$amountMoney->setCurrency("USD");

$body->setSourceId($nonce);
$body->setAmountMoney($amountMoney);
$body->setLocationId($location_id);

# Every payment you process with the SDK must have a unique idempotency key.
# If you're unsure whether a particular payment succeeded, you can reattempt
# it with the same idempotency key without worrying about double charging
# the buyer.
$body->setIdempotencyKey(uniqid());

try {
    $result = $payments_api->createPayment($body);
    print_r($result);
} catch (\SquareConnect\ApiException $e) {
    echo "Exception when calling PaymentsApi->createPayment:";
    var_dump($e->getResponseBody());
}

How to configure sandbox environment

require 'vendor/autoload.php';

$access_token = 'YOUR_SANDBOX_ACCESS_TOKEN';
# setup authorization
$api_config = new \SquareConnect\Configuration();
$api_config->setHost("https://connect.squareupsandbox.com");
$api_config->setAccessToken($access_token);
$api_client = new \SquareConnect\ApiClient($api_config);
# create an instance of the Location API
$locations_api = new \SquareConnect\Api\LocationsApi($api_client);

Documentation for API Endpoints

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

ClassMethodHTTP requestDescription
ApplePayApiregisterDomainPOST /v2/apple-pay/domainsRegisterDomain
BankAccountsApigetBankAccountGET /v2/bank-accounts/{bank_account_id}GetBankAccount
BankAccountsApigetBankAccountByV1IdGET /v2/bank-accounts/by-v1-id/{v1_bank_account_id}GetBankAccountByV1Id
BankAccountsApilistBankAccountsGET /v2/bank-accountsListBankAccounts
CashDrawersApilistCashDrawerShiftEventsGET /v2/cash-drawers/shifts/{shift_id}/eventsListCashDrawerShiftEvents
CashDrawersApilistCashDrawerShiftsGET /v2/cash-drawers/shiftsListCashDrawerShifts
CashDrawersApiretrieveCashDrawerShiftGET /v2/cash-drawers/shifts/{shift_id}RetrieveCashDrawerShift
CatalogApibatchDeleteCatalogObjectsPOST /v2/catalog/batch-deleteBatchDeleteCatalogObjects
CatalogApibatchRetrieveCatalogObjectsPOST /v2/catalog/batch-retrieveBatchRetrieveCatalogObjects
CatalogApibatchUpsertCatalogObjectsPOST /v2/catalog/batch-upsertBatchUpsertCatalogObjects
CatalogApicatalogInfoGET /v2/catalog/infoCatalogInfo
CatalogApideleteCatalogObjectDELETE /v2/catalog/object/{object_id}DeleteCatalogObject
CatalogApilistCatalogGET /v2/catalog/listListCatalog
CatalogApiretrieveCatalogObjectGET /v2/catalog/object/{object_id}RetrieveCatalogObject
CatalogApisearchCatalogObjectsPOST /v2/catalog/searchSearchCatalogObjects
CatalogApiupdateItemModifierListsPOST /v2/catalog/update-item-modifier-listsUpdateItemModifierLists
CatalogApiupdateItemTaxesPOST /v2/catalog/update-item-taxesUpdateItemTaxes
CatalogApiupsertCatalogObjectPOST /v2/catalog/objectUpsertCatalogObject
CheckoutApicreateCheckoutPOST /v2/locations/{location_id}/checkoutsCreateCheckout
CustomerGroupsApicreateCustomerGroupPOST /v2/customers/groupsCreateCustomerGroup
CustomerGroupsApideleteCustomerGroupDELETE /v2/customers/groups/{group_id}DeleteCustomerGroup
CustomerGroupsApilistCustomerGroupsGET /v2/customers/groupsListCustomerGroups
CustomerGroupsApiretrieveCustomerGroupGET /v2/customers/groups/{group_id}RetrieveCustomerGroup
CustomerGroupsApiupdateCustomerGroupPUT /v2/customers/groups/{group_id}UpdateCustomerGroup
CustomerSegmentsApilistCustomerSegmentsGET /v2/customers/segmentsListCustomerSegments
CustomerSegmentsApiretrieveCustomerSegmentGET /v2/customers/segments/{segment_id}RetrieveCustomerSegment
CustomersApiaddGroupToCustomerPUT /v2/customers/{customer_id}/groups/{group_id}AddGroupToCustomer
CustomersApicreateCustomerPOST /v2/customersCreateCustomer
CustomersApicreateCustomerCardPOST /v2/customers/{customer_id}/cardsCreateCustomerCard
CustomersApideleteCustomerDELETE /v2/customers/{customer_id}DeleteCustomer
CustomersApideleteCustomerCardDELETE /v2/customers/{customer_id}/cards/{card_id}DeleteCustomerCard
CustomersApilistCustomersGET /v2/customersListCustomers
CustomersApiremoveGroupFromCustomerDELETE /v2/customers/{customer_id}/groups/{group_id}RemoveGroupFromCustomer
CustomersApiretrieveCustomerGET /v2/customers/{customer_id}RetrieveCustomer
CustomersApisearchCustomersPOST /v2/customers/searchSearchCustomers
CustomersApiupdateCustomerPUT /v2/customers/{customer_id}UpdateCustomer
DevicesApicreateDeviceCodePOST /v2/devices/codesCreateDeviceCode
DevicesApigetDeviceCodeGET /v2/devices/codes/{id}GetDeviceCode
DevicesApilistDeviceCodesGET /v2/devices/codesListDeviceCodes
DisputesApiacceptDisputePOST /v2/disputes/{dispute_id}/acceptAcceptDispute
DisputesApicreateDisputeEvidenceTextPOST /v2/disputes/{dispute_id}/evidence_textCreateDisputeEvidenceText
DisputesApilistDisputeEvidenceGET /v2/disputes/{dispute_id}/evidenceListDisputeEvidence
DisputesApilistDisputesGET /v2/disputesListDisputes
DisputesApiremoveDisputeEvidenceDELETE /v2/disputes/{dispute_id}/evidence/{evidence_id}RemoveDisputeEvidence
DisputesApiretrieveDisputeGET /v2/disputes/{dispute_id}RetrieveDispute
DisputesApiretrieveDisputeEvidenceGET /v2/disputes/{dispute_id}/evidence/{evidence_id}RetrieveDisputeEvidence
DisputesApisubmitEvidencePOST /v2/disputes/{dispute_id}/submit-evidenceSubmitEvidence
EmployeesApilistEmployeesGET /v2/employeesListEmployees
EmployeesApiretrieveEmployeeGET /v2/employees/{id}RetrieveEmployee
InventoryApibatchChangeInventoryPOST /v2/inventory/batch-changeBatchChangeInventory
InventoryApibatchRetrieveInventoryChangesPOST /v2/inventory/batch-retrieve-changesBatchRetrieveInventoryChanges
InventoryApibatchRetrieveInventoryCountsPOST /v2/inventory/batch-retrieve-countsBatchRetrieveInventoryCounts
InventoryApiretrieveInventoryAdjustmentGET /v2/inventory/adjustment/{adjustment_id}RetrieveInventoryAdjustment
InventoryApiretrieveInventoryChangesGET /v2/inventory/{catalog_object_id}/changesRetrieveInventoryChanges
InventoryApiretrieveInventoryCountGET /v2/inventory/{catalog_object_id}RetrieveInventoryCount
InventoryApiretrieveInventoryPhysicalCountGET /v2/inventory/physical-count/{physical_count_id}RetrieveInventoryPhysicalCount
LaborApicreateBreakTypePOST /v2/labor/break-typesCreateBreakType
LaborApicreateShiftPOST /v2/labor/shiftsCreateShift
LaborApideleteBreakTypeDELETE /v2/labor/break-types/{id}DeleteBreakType
LaborApideleteShiftDELETE /v2/labor/shifts/{id}DeleteShift
LaborApigetBreakTypeGET /v2/labor/break-types/{id}GetBreakType
LaborApigetEmployeeWageGET /v2/labor/employee-wages/{id}GetEmployeeWage
LaborApigetShiftGET /v2/labor/shifts/{id}GetShift
LaborApilistBreakTypesGET /v2/labor/break-typesListBreakTypes
LaborApilistEmployeeWagesGET /v2/labor/employee-wagesListEmployeeWages
LaborApilistWorkweekConfigsGET /v2/labor/workweek-configsListWorkweekConfigs
LaborApisearchShiftsPOST /v2/labor/shifts/searchSearchShifts
LaborApiupdateBreakTypePUT /v2/labor/break-types/{id}UpdateBreakType
LaborApiupdateShiftPUT /v2/labor/shifts/{id}UpdateShift
LaborApiupdateWorkweekConfigPUT /v2/labor/workweek-configs/{id}UpdateWorkweekConfig
LocationsApicreateLocationPOST /v2/locationsCreateLocation
LocationsApilistLocationsGET /v2/locationsListLocations
LocationsApiretrieveLocationGET /v2/locations/{location_id}RetrieveLocation
LocationsApiupdateLocationPUT /v2/locations/{location_id}UpdateLocation
MerchantsApilistMerchantsGET /v2/merchantsListMerchants
MerchantsApiretrieveMerchantGET /v2/merchants/{merchant_id}RetrieveMerchant
MobileAuthorizationApicreateMobileAuthorizationCodePOST /mobile/authorization-codeCreateMobileAuthorizationCode
OAuthApiobtainTokenPOST /oauth2/tokenObtainToken
OAuthApirenewTokenPOST /oauth2/clients/{client_id}/access-token/renewRenewToken
OAuthApirevokeTokenPOST /oauth2/revokeRevokeToken
OrdersApibatchRetrieveOrdersPOST /v2/locations/{location_id}/orders/batch-retrieveBatchRetrieveOrders
OrdersApicreateOrderPOST /v2/locations/{location_id}/ordersCreateOrder
OrdersApipayOrderPOST /v2/orders/{order_id}/payPayOrder
OrdersApisearchOrdersPOST /v2/orders/searchSearchOrders
OrdersApiupdateOrderPUT /v2/locations/{location_id}/orders/{order_id}UpdateOrder
PaymentsApicancelPaymentPOST /v2/payments/{payment_id}/cancelCancelPayment
PaymentsApicancelPaymentByIdempotencyKeyPOST /v2/payments/cancelCancelPaymentByIdempotencyKey
PaymentsApicompletePaymentPOST /v2/payments/{payment_id}/completeCompletePayment
PaymentsApicreatePaymentPOST /v2/paymentsCreatePayment
PaymentsApigetPaymentGET /v2/payments/{payment_id}GetPayment
PaymentsApilistPaymentsGET /v2/paymentsListPayments
RefundsApigetPaymentRefundGET /v2/refunds/{refund_id}GetPaymentRefund
RefundsApilistPaymentRefundsGET /v2/refundsListPaymentRefunds
RefundsApirefundPaymentPOST /v2/refundsRefundPayment
ReportingApilistAdditionalRecipientReceivableRefundsGET /v2/locations/{location_id}/additional-recipient-receivable-refundsListAdditionalRecipientReceivableRefunds
ReportingApilistAdditionalRecipientReceivablesGET /v2/locations/{location_id}/additional-recipient-receivablesListAdditionalRecipientReceivables
TerminalApicancelTerminalCheckoutPOST /v2/terminals/checkouts/{checkout_id}/cancelCancelTerminalCheckout
TerminalApicreateTerminalCheckoutPOST /v2/terminals/checkoutsCreateTerminalCheckout
TerminalApigetTerminalCheckoutGET /v2/terminals/checkouts/{checkout_id}GetTerminalCheckout
TerminalApisearchTerminalCheckoutsPOST /v2/terminals/checkouts/searchSearchTerminalCheckouts
TransactionsApicaptureTransactionPOST /v2/locations/{location_id}/transactions/{transaction_id}/captureCaptureTransaction
TransactionsApichargePOST /v2/locations/{location_id}/transactionsCharge
TransactionsApicreateRefundPOST /v2/locations/{location_id}/transactions/{transaction_id}/refundCreateRefund
TransactionsApilistRefundsGET /v2/locations/{location_id}/refundsListRefunds
TransactionsApilistTransactionsGET /v2/locations/{location_id}/transactionsListTransactions
TransactionsApiretrieveTransactionGET /v2/locations/{location_id}/transactions/{transaction_id}RetrieveTransaction
TransactionsApivoidTransactionPOST /v2/locations/{location_id}/transactions/{transaction_id}/voidVoidTransaction
V1EmployeesApicreateEmployeePOST /v1/me/employeesCreateEmployee
V1EmployeesApicreateEmployeeRolePOST /v1/me/rolesCreateEmployeeRole
V1EmployeesApicreateTimecardPOST /v1/me/timecardsCreateTimecard
V1EmployeesApideleteTimecardDELETE /v1/me/timecards/{timecard_id}DeleteTimecard
V1EmployeesApilistCashDrawerShiftsGET /v1/{location_id}/cash-drawer-shiftsListCashDrawerShifts
V1EmployeesApilistEmployeeRolesGET /v1/me/rolesListEmployeeRoles
V1EmployeesApilistEmployeesGET /v1/me/employeesListEmployees
V1EmployeesApilistTimecardEventsGET /v1/me/timecards/{timecard_id}/eventsListTimecardEvents
V1EmployeesApilistTimecardsGET /v1/me/timecardsListTimecards
V1EmployeesApiretrieveCashDrawerShiftGET /v1/{location_id}/cash-drawer-shifts/{shift_id}RetrieveCashDrawerShift
V1EmployeesApiretrieveEmployeeGET /v1/me/employees/{employee_id}RetrieveEmployee
V1EmployeesApiretrieveEmployeeRoleGET /v1/me/roles/{role_id}RetrieveEmployeeRole
V1EmployeesApiretrieveTimecardGET /v1/me/timecards/{timecard_id}RetrieveTimecard
V1EmployeesApiupdateEmployeePUT /v1/me/employees/{employee_id}UpdateEmployee
V1EmployeesApiupdateEmployeeRolePUT /v1/me/roles/{role_id}UpdateEmployeeRole
V1EmployeesApiupdateTimecardPUT /v1/me/timecards/{timecard_id}UpdateTimecard
V1ItemsApiadjustInventoryPOST /v1/{location_id}/inventory/{variation_id}AdjustInventory
V1ItemsApiapplyFeePUT /v1/{location_id}/items/{item_id}/fees/{fee_id}ApplyFee
V1ItemsApiapplyModifierListPUT /v1/{location_id}/items/{item_id}/modifier-lists/{modifier_list_id}ApplyModifierList
V1ItemsApicreateCategoryPOST /v1/{location_id}/categoriesCreateCategory
V1ItemsApicreateDiscountPOST /v1/{location_id}/discountsCreateDiscount
V1ItemsApicreateFeePOST /v1/{location_id}/feesCreateFee
V1ItemsApicreateItemPOST /v1/{location_id}/itemsCreateItem
V1ItemsApicreateModifierListPOST /v1/{location_id}/modifier-listsCreateModifierList
V1ItemsApicreateModifierOptionPOST /v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-optionsCreateModifierOption
V1ItemsApicreatePagePOST /v1/{location_id}/pagesCreatePage
V1ItemsApicreateVariationPOST /v1/{location_id}/items/{item_id}/variationsCreateVariation
V1ItemsApideleteCategoryDELETE /v1/{location_id}/categories/{category_id}DeleteCategory
V1ItemsApideleteDiscountDELETE /v1/{location_id}/discounts/{discount_id}DeleteDiscount
V1ItemsApideleteFeeDELETE /v1/{location_id}/fees/{fee_id}DeleteFee
V1ItemsApideleteItemDELETE /v1/{location_id}/items/{item_id}DeleteItem
V1ItemsApideleteModifierListDELETE /v1/{location_id}/modifier-lists/{modifier_list_id}DeleteModifierList
V1ItemsApideleteModifierOptionDELETE /v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options/{modifier_option_id}DeleteModifierOption
V1ItemsApideletePageDELETE /v1/{location_id}/pages/{page_id}DeletePage
V1ItemsApideletePageCellDELETE /v1/{location_id}/pages/{page_id}/cellsDeletePageCell
V1ItemsApideleteVariationDELETE /v1/{location_id}/items/{item_id}/variations/{variation_id}DeleteVariation
V1ItemsApilistCategoriesGET /v1/{location_id}/categoriesListCategories
V1ItemsApilistDiscountsGET /v1/{location_id}/discountsListDiscounts
V1ItemsApilistFeesGET /v1/{location_id}/feesListFees
V1ItemsApilistInventoryGET /v1/{location_id}/inventoryListInventory
V1ItemsApilistItemsGET /v1/{location_id}/itemsListItems
V1ItemsApilistModifierListsGET /v1/{location_id}/modifier-listsListModifierLists
V1ItemsApilistPagesGET /v1/{location_id}/pagesListPages
V1ItemsApiremoveFeeDELETE /v1/{location_id}/items/{item_id}/fees/{fee_id}RemoveFee
V1ItemsApiremoveModifierListDELETE /v1/{location_id}/items/{item_id}/modifier-lists/{modifier_list_id}RemoveModifierList
V1ItemsApiretrieveItemGET /v1/{location_id}/items/{item_id}RetrieveItem
V1ItemsApiretrieveModifierListGET /v1/{location_id}/modifier-lists/{modifier_list_id}RetrieveModifierList
V1ItemsApiupdateCategoryPUT /v1/{location_id}/categories/{category_id}UpdateCategory
V1ItemsApiupdateDiscountPUT /v1/{location_id}/discounts/{discount_id}UpdateDiscount
V1ItemsApiupdateFeePUT /v1/{location_id}/fees/{fee_id}UpdateFee
V1ItemsApiupdateItemPUT /v1/{location_id}/items/{item_id}UpdateItem
V1ItemsApiupdateModifierListPUT /v1/{location_id}/modifier-lists/{modifier_list_id}UpdateModifierList
V1ItemsApiupdateModifierOptionPUT /v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options/{modifier_option_id}UpdateModifierOption
V1ItemsApiupdatePagePUT /v1/{location_id}/pages/{page_id}UpdatePage
V1ItemsApiupdatePageCellPUT /v1/{location_id}/pages/{page_id}/cellsUpdatePageCell
V1ItemsApiupdateVariationPUT /v1/{location_id}/items/{item_id}/variations/{variation_id}UpdateVariation
V1LocationsApilistLocationsGET /v1/me/locationsListLocations
V1LocationsApiretrieveBusinessGET /v1/meRetrieveBusiness
V1TransactionsApicreateRefundPOST /v1/{location_id}/refundsCreateRefund
V1TransactionsApilistBankAccountsGET /v1/{location_id}/bank-accountsListBankAccounts
V1TransactionsApilistOrdersGET /v1/{location_id}/ordersListOrders
V1TransactionsApilistPaymentsGET /v1/{location_id}/paymentsListPayments
V1TransactionsApilistRefundsGET /v1/{location_id}/refundsListRefunds
V1TransactionsApilistSettlementsGET /v1/{location_id}/settlementsListSettlements
V1TransactionsApiretrieveBankAccountGET /v1/{location_id}/bank-accounts/{bank_account_id}RetrieveBankAccount
V1TransactionsApiretrieveOrderGET /v1/{location_id}/orders/{order_id}RetrieveOrder
V1TransactionsApiretrievePaymentGET /v1/{location_id}/payments/{payment_id}RetrievePayment
V1TransactionsApiretrieveSettlementGET /v1/{location_id}/settlements/{settlement_id}RetrieveSettlement
V1TransactionsApiupdateOrderPUT /v1/{location_id}/orders/{order_id}UpdateOrder

Documentation For Models

Documentation For Authorization

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://connect.squareup.com/oauth2/authorize
  • Scopes:
  • BANK_ACCOUNTS_READ: HTTP Method: GET Grants read access to bank account information associated with the targeted Square account. For example, to call the Connect v1 ListBankAccounts endpoint.
  • CUSTOMERS_READ: HTTP Method: GET Grants read access to customer information. For example, to call the ListCustomers endpoint.
  • CUSTOMERS_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to customer information. For example, to create and update customer profiles.
  • DEVICE_CREDENTIAL_MANAGEMENT: HTTP Method: POST, GET Grants read/write access to device credentials information. For example, to call the CreateDeviceCode endpoint.
  • EMPLOYEES_READ: HTTP Method: GET Grants read access to employee profile information. For example, to call the Connect v1 Employees API.
  • EMPLOYEES_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to employee profile information. For example, to create and modify employee profiles.
  • INVENTORY_READ: HTTP Method: GET Grants read access to inventory information. For example, to call the RetrieveInventoryCount endpoint.
  • INVENTORY_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to inventory information. For example, to call the BatchChangeInventory endpoint.
  • ITEMS_READ: HTTP Method: GET Grants read access to business and location information. For example, to obtain a location ID for subsequent activity.
  • ITEMS_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to product catalog information. For example, to modify or add to a product catalog.
  • MERCHANT_PROFILE_READ: HTTP Method: GET Grants read access to business and location information. For example, to obtain a location ID for subsequent activity.
  • ORDERS_READ: HTTP Method: GET Grants read access to order information. For example, to call the BatchRetrieveOrders endpoint.
  • ORDERS_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to order information. For example, to call the CreateCheckout endpoint.
  • PAYMENTS_READ: HTTP Method: GET Grants read access to transaction and refund information. For example, to call the RetrieveTransaction endpoint.
  • PAYMENTS_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to transaction and refunds information. For example, to process payments with the Payments or Checkout API.
  • PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS: HTTP Method: POST, PUT, DELETE Allow third party applications to deduct a portion of each transaction amount. Required to use multiparty transaction functionality with the Payments API.
  • PAYMENTS_WRITE_IN_PERSON: HTTP Method: POST, PUT, DELETE Grants write access to payments and refunds information. For example, to process in-person payments.
  • SETTLEMENTS_READ: HTTP Method: GET Grants read access to settlement (deposit) information. For example, to call the Connect v1 ListSettlements endpoint.
  • TIMECARDS_READ: HTTP Method: GET Grants read access to employee timecard information. For example, to call the Connect v2 SearchShifts endpoint.
  • TIMECARDS_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to employee shift information. For example, to create and modify employee shifts.
  • TIMECARDS_SETTINGS_READ: HTTP Method: GET Grants read access to employee timecard settings information. For example, to call the GetBreakType endpoint.
  • TIMECARDS_SETTINGS_WRITE: HTTP Method: POST, PUT, DELETE Grants write access to employee timecard settings information. For example, to call the UpdateBreakType endpoint.

oauth2ClientSecret

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Pagination of V1 Endpoints

V1 Endpoints return pagination information via HTTP headers. In order to obtain response headers and extract the batch_token parameter you will need to follow the following steps:

  1. Use the full information endpoint methods of each API to get the response HTTP Headers. They are named as their simple counterpart with a WithHttpInfo suffix. Hence listEmployeeRoles would be called listEmployeeRolesWithHttpInfo. This method returns an array with 3 parameters: $response, $http_status, and $http_headers.
  2. Use $batch_token = \SquareConnect\ApiClient::getV1BatchTokenFromHeaders($http_headers) to extract the token and proceed to get the following page if a token is present.

Example

<?php
...
$api_instance = new SquareConnect\Api\V1EmployeesApi();
$order = null;
$limit = 20;
$batch_token = null;
$roles = array();

try {
    do {
        list($result, $status, $headers) = $api_instance->listEmployeeRolesWithHttpInfo($order, $limit, $batch_token);
        $batch_token = \SquareConnect\ApiClient::getV1BatchTokenFromHeaders($headers);
        $roles = array_merge($roles, $result);
    } while (!is_null($batch_token));
    print_r($roles);
} catch (Exception $e) {
    echo 'Exception when calling V1EmployeesApi->listEmployeeRolesWithHttpInfo: ', $e->getMessage(), PHP_EOL;
}
?>

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.