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/_Base.php |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/inc/integrations/_Base.php b/inc/integrations/_Base.php
index 3c4f266..d381877 100644
--- a/inc/integrations/_Base.php
+++ b/inc/integrations/_Base.php
@@ -1,6 +1,7 @@
 <?php
 namespace JVBase\integrations;
 
+use JVBase\inc\managers\ErrorHelper;
 use JVBase\managers\Cache;
 use JVBase\managers\Errors;
 use JVBase\managers\IconsManager;
@@ -10,6 +11,7 @@
 }
 
 trait _Base {
+	use ErrorHelper;
 	/**
 	 * @var string Unique identifier for this service (ex: square, facebook)
 	 */
@@ -95,7 +97,16 @@
 	 */
 	public function isSetUp(): bool
 	{
-		return !empty($this->loadCredentials());
+		$tmp = null;
+		if ($this->userID) {
+			$tmp = $this->userID;
+			$this->switchUser();
+		}
+		$isSetUp = !empty($this->loadCredentials()??[]);
+		if ($tmp) {
+			$this->switchUser($tmp);
+		}
+		return $isSetUp;
 	}
 
 	public function loadCredentials():array
@@ -108,8 +119,16 @@
 
 	protected function logError(string $method, string $message, array $context = []):void
 	{
+
 		$context['service'] = $this->service_name;
-		Errors::getInstance()->log('['.self::class.']'.$method, $message, $context);
+		Errors::log($message, array_merge(
+			[
+				'service'	=> $this->service_name,
+				'method'	=> $method,
+				'class'		=> static::class,
+			],
+			$context
+		));
 	}
 
 	protected function getReturnURL():string
@@ -131,7 +150,7 @@
 	{
 		if (is_admin()) {
 			$icons = IconsManager::for('admin');
-			return $icons->getRawSvg($icon);
+			return $icons->getRawSvg($icon)??'';
 		}
 		return jvbDashIcon($icon);
 	}

--
Gitblit v1.10.0