From a8ff85042ffbfe94b678fd818c02deb613bfd116 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 07 Aug 2026 20:42:54 +0000
Subject: [PATCH] =Continuing on with Integrations setup. Working on PostMark now

---
 inc/integrations/services/Square.php |   33 ++++++++++++++-------------------
 1 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/inc/integrations/services/Square.php b/inc/integrations/services/Square.php
index a2b6c9a..aeb001b 100644
--- a/inc/integrations/services/Square.php
+++ b/inc/integrations/services/Square.php
@@ -36,18 +36,16 @@
 		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 = [
@@ -55,6 +53,9 @@
 			'update'	=> true,
 			'delete'	=> true,
 		];
+		$this->hasBatchCreate = true;
+		$this->hasBatchUpdate = true;
+		$this->hasBatchDelete = true;
 
 		$this->defineFields();
 		$this->defineInstructions();
@@ -89,8 +90,8 @@
 			$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');
 	}
 
@@ -271,15 +272,12 @@
 			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
@@ -914,10 +912,7 @@
 			? 'https://connect.squareup.com'
 			: 'https://connect.squareupsandbox.com';
 	}
-	protected function getAccessToken():string
-	{
-		return $this->loadCredentials()['access_token']??'';
-	}
+
 	/***************************************************************
 	 * ACTIONS
 	***************************************************************/

--
Gitblit v1.10.0