| | |
| | | Webhooks; |
| | | |
| | | protected string $orderPostType = '_square_order'; |
| | | protected string $apiVersion = '2026-07-15'; |
| | | public bool $hasBatchCreate = true; |
| | | public bool $hasBatchUpdate = true; |
| | | public bool $hasBatchDelete = true; |
| | | public array $apiEndpoints = [ |
| | | |
| | | ]; |
| | | |
| | | protected function __construct() |
| | | { |
| | | $this->service_name = 'square'; |
| | | $this->title = 'Square'; |
| | | $this->icon = 'square-logo'; |
| | | $this->apiVersion = '2026-07-15'; |
| | | $this->supportsWebp = false; |
| | | |
| | | $this->canSync = [ |
| | |
| | | 'update' => true, |
| | | 'delete' => true, |
| | | ]; |
| | | $this->hasBatchCreate = true; |
| | | $this->hasBatchUpdate = true; |
| | | $this->hasBatchDelete = true; |
| | | |
| | | $this->defineFields(); |
| | | $this->defineInstructions(); |
| | |
| | | $locs->setHidden(); |
| | | $locs->setOptions($this->getLocationOptions()); |
| | | |
| | | $loc = $this->addField('location_id', 'Default Location', 'select', 'manage_options'); |
| | | $loc->setOptions($this->loadCredentials()['locations']); |
| | | $loc = $this->addField('location_id', 'Set Location', 'select', 'manage_options'); |
| | | $loc->setOptions($this->loadCredentials()['locations']??[]); |
| | | $loc->setHint('Select default Square location for transactions'); |
| | | } |
| | | |
| | |
| | | return $this->response(false, 'Rate limit exceeded'); |
| | | } |
| | | $endpoint = str_replace($this->getBaseURL(), '', $endpoint); |
| | | switch ($endpoint) { |
| | | case '/v2/customers/search': |
| | | return $this->handleEmailSearchResponse($response, $method); |
| | | case '/v2/customers': |
| | | return $this->handleCreateUserResponse($response, $method); |
| | | case '/v2/locations': |
| | | return $this->handleGetLocationResponse($response, $method); |
| | | } |
| | | return $this->response(false, 'Unhandled Response for '.$endpoint.' endpoint, with method: '.$method); |
| | | return match ($endpoint) { |
| | | '/v2/customers/search' => $this->handleEmailSearchResponse($response, $method), |
| | | '/v2/customers' => $this->handleCreateUserResponse($response, $method), |
| | | '/v2/locations' => $this->handleGetLocationResponse($response, $method), |
| | | default => $this->response(false, 'Unhandled Response for ' . $endpoint . ' endpoint, with method: ' . $method), |
| | | }; |
| | | } |
| | | |
| | | protected function setContentTypes(): void |
| | |
| | | ? 'https://connect.squareup.com' |
| | | : 'https://connect.squareupsandbox.com'; |
| | | } |
| | | protected function getAccessToken():string |
| | | { |
| | | return $this->loadCredentials()['access_token']??''; |
| | | } |
| | | |
| | | /*************************************************************** |
| | | * ACTIONS |
| | | ***************************************************************/ |