All URIs are relative to https://connect.squareup.com
Method | HTTP request | Description |
---|---|---|
createCustomer | POST /v2/customers | CreateCustomer |
createCustomerCard | POST /v2/customers/{customer_id}/cards | CreateCustomerCard |
deleteCustomer | DELETE /v2/customers/{customer_id} | DeleteCustomer |
deleteCustomerCard | DELETE /v2/customers/{customer_id}/cards/{card_id} | DeleteCustomerCard |
listCustomers | GET /v2/customers | ListCustomers |
retrieveCustomer | GET /v2/customers/{customer_id} | RetrieveCustomer |
searchCustomers | POST /v2/customers/search | SearchCustomers |
updateCustomer | PUT /v2/customers/{customer_id} | UpdateCustomer |
\SquareConnect\Model\CreateCustomerResponse createCustomer($body)
CreateCustomer
Creates a new customer for a business, which can have associated cards on file. You must provide at least one of the following values in your request to this endpoint: - given_name
- family_name
- company_name
- email_address
- phone_number
This endpoint does not accept an idempotency key. If you accidentally create a duplicate customer, you can delete it with the DeleteCustomer endpoint.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$body = new \SquareConnect\Model\CreateCustomerRequest(); // \SquareConnect\Model\CreateCustomerRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
$result = $api_instance->createCustomer($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->createCustomer: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
body | \SquareConnect\Model\CreateCustomerRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
\SquareConnect\Model\CreateCustomerResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\CreateCustomerCardResponse createCustomerCard($customer_id, $body)
CreateCustomerCard
Adds a card on file to an existing customer. In the United States Square takes care of automatically updating any cards on file that might have expired since you first attached them to a customer. As with charges, calls to CreateCustomerCard
are idempotent. Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the first call.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$customer_id = "customer_id_example"; // string | The ID of the customer to link the card on file to.
$body = new \SquareConnect\Model\CreateCustomerCardRequest(); // \SquareConnect\Model\CreateCustomerCardRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
$result = $api_instance->createCustomerCard($customer_id, $body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->createCustomerCard: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
customer_id | string | The ID of the customer to link the card on file to. | |
body | \SquareConnect\Model\CreateCustomerCardRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
\SquareConnect\Model\CreateCustomerCardResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\DeleteCustomerResponse deleteCustomer($customer_id)
DeleteCustomer
Deletes a customer from a business, along with any linked cards on file.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$customer_id = "customer_id_example"; // string | The ID of the customer to delete.
try {
$result = $api_instance->deleteCustomer($customer_id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->deleteCustomer: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
customer_id | string | The ID of the customer to delete. |
\SquareConnect\Model\DeleteCustomerResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\DeleteCustomerCardResponse deleteCustomerCard($customer_id, $card_id)
DeleteCustomerCard
Removes a card on file from a customer.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$customer_id = "customer_id_example"; // string | The ID of the customer that the card on file belongs to.
$card_id = "card_id_example"; // string | The ID of the card on file to delete.
try {
$result = $api_instance->deleteCustomerCard($customer_id, $card_id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->deleteCustomerCard: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
customer_id | string | The ID of the customer that the card on file belongs to. | |
card_id | string | The ID of the card on file to delete. |
\SquareConnect\Model\DeleteCustomerCardResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\ListCustomersResponse listCustomers($cursor, $sort_field, $sort_order)
ListCustomers
Lists a business's customers.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$cursor = "cursor_example"; // string | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Paginating results](#paginatingresults) for more information.
$sort_field = "sort_field_example"; // string | Indicates how Customers should be sorted. Default: `DEFAULT`. See [CustomerSortField](#type-customersortfield) for possible values.
$sort_order = "sort_order_example"; // string | Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`. See [SortOrder](#type-sortorder) for possible values.
try {
$result = $api_instance->listCustomers($cursor, $sort_field, $sort_order);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->listCustomers: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
cursor | string | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See Paginating results for more information. | [optional] |
sort_field | string | Indicates how Customers should be sorted. Default: `DEFAULT`. See CustomerSortField for possible values. | [optional] |
sort_order | string | Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`. See SortOrder for possible values. | [optional] |
\SquareConnect\Model\ListCustomersResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\RetrieveCustomerResponse retrieveCustomer($customer_id)
RetrieveCustomer
Returns details for a single customer.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$customer_id = "customer_id_example"; // string | The ID of the customer to retrieve.
try {
$result = $api_instance->retrieveCustomer($customer_id);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->retrieveCustomer: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
customer_id | string | The ID of the customer to retrieve. |
\SquareConnect\Model\RetrieveCustomerResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\SearchCustomersResponse searchCustomers($body)
SearchCustomers
Searches a business's customers.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$body = new \SquareConnect\Model\SearchCustomersRequest(); // \SquareConnect\Model\SearchCustomersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
$result = $api_instance->searchCustomers($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->searchCustomers: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
body | \SquareConnect\Model\SearchCustomersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
\SquareConnect\Model\SearchCustomersResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
\SquareConnect\Model\UpdateCustomerResponse updateCustomer($customer_id, $body)
UpdateCustomer
Updates the details of an existing customer. The ID of the customer may change if the customer has been merged into another customer. You cannot edit a customer's cards on file with this endpoint. To make changes to a card on file, you must delete the existing card on file with the DeleteCustomerCard endpoint, then create a new one with the CreateCustomerCard endpoint.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new SquareConnect\Api\CustomersApi();
$customer_id = "customer_id_example"; // string | The ID of the customer to update.
$body = new \SquareConnect\Model\UpdateCustomerRequest(); // \SquareConnect\Model\UpdateCustomerRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
$result = $api_instance->updateCustomer($customer_id, $body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CustomersApi->updateCustomer: ', $e->getMessage(), PHP_EOL;
}
?>
Name | Type | Description | Notes |
---|---|---|---|
customer_id | string | The ID of the customer to update. | |
body | \SquareConnect\Model\UpdateCustomerRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
\SquareConnect\Model\UpdateCustomerResponse
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]