From a6413da67a4579866f0fd0323ddb23a7b6b9654a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 18 Sep 2026 17:00:53 +0000
Subject: [PATCH] =Cleaning up the Integrations setup a bit, started the Helcim integration work too

---
 inc/integrations/services/GoogleMyBusiness.php |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/inc/integrations/services/GoogleMyBusiness.php b/inc/integrations/services/GoogleMyBusiness.php
index 694285e..44002c7 100644
--- a/inc/integrations/services/GoogleMyBusiness.php
+++ b/inc/integrations/services/GoogleMyBusiness.php
@@ -56,6 +56,8 @@
 			);
 				$client_id->setRequired();
 				$client_id->setHint('From your Google Cloud Console OAuth credentials.');
+				$client_id->makeSetupField();
+				$this->updateField('client_id', $client_id);
 
 			$secret = $this->addField(
 				'client_secret',
@@ -65,6 +67,8 @@
 			);
 				$secret->setSubType('password');
 				$secret->setRequired();
+				$secret->makeSetupField();
+				$this->updateField('client_secret', $client_id);
 
 			if ($this->getAccessToken()) {
 				$accs = $this->addField('accounts', 'Accounts', 'select', [$this, 'testUserCanConnect']);
@@ -101,6 +105,25 @@
 				'Add redirect URI: <code>'.esc_html($this->getRedirectUri()).'</code>',
 				'Use the "Authorize" button below to complete OAuth flow'
 			];
+
+			$this->instructions = [
+				'Go to <a href="https://console.cloud.google.com/apis/credentials" target="_blank">Google Cloud Console</a>',
+				'Create OAuth 2.0 Client ID credentials',
+				'Enable the following APIs in your project:',
+				[
+					'<a href="https://console.cloud.google.com/apis/library/mybusinessaccountmanagement.googleapis.com" target="_blank">My Business Account Management API</a>',
+					'<a href="https://console.cloud.google.com/apis/library/mybusinessbusinessinformation.googleapis.com" target="_blank">My Business Business Information API</a>',
+					'<a href="https://console.cloud.google.com/apis/library/mybusiness.googleapis.com" target="_blank">Google My Business API</a> (legacy v4, required for reviews)',
+				],
+				'On the OAuth consent screen, add these scopes:',
+				[
+					'<code>https://www.googleapis.com/auth/business.manage</code>',
+					'<code>https://www.googleapis.com/auth/userinfo.email</code>',
+					'<code>https://www.googleapis.com/auth/userinfo.profile</code>',
+				],
+				'Add redirect URI: <code>'.esc_html($this->getRedirectUri()).'</code>',
+				'Use the "Authorize" button below to complete OAuth flow'
+			];
 		}
 		protected function defineOAuth():void
 		{
@@ -119,11 +142,13 @@
 		}
 		protected function defineActions():void
 		{
-			$this->addAction(
-				'Update Location',
-				[$this, 'handleUpdateLocation'],
-				'update_location',
-			);
+			if ($this->hasOAuthCredentials($this->userID)) {
+				$this->addAction(
+					'Update Location',
+					[$this, 'handleUpdateLocation'],
+					'update_location',
+				);
+			}
 		}
 			public function handleUpdateLocation(array $data):array
 			{

--
Gitblit v1.10.0