From fff721dd185f5b97f7ae7a6e64189e55887ff590 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 05 Jul 2026 18:36:57 +0000
Subject: [PATCH] =Cleaning up the Square integration (still a bit more to do yet). Also majorly overhauled /rest/ files to ignore a rest request 'user' paramater, and rely on get_current_user_id() instead.

---
 inc/rest/routes/IntegrationsHelcimRoutes.php |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/inc/rest/routes/IntegrationsHelcimRoutes.php b/inc/rest/routes/IntegrationsHelcimRoutes.php
index 6476e16..b626ecb 100644
--- a/inc/rest/routes/IntegrationsHelcimRoutes.php
+++ b/inc/rest/routes/IntegrationsHelcimRoutes.php
@@ -55,7 +55,10 @@
 	public function handleInitializeCheckout(WP_REST_Request $request): WP_REST_Response
 	{
 		$data    = $request->get_json_params();
-		$user_id = absint($data['user'] ?? get_current_user_id());
+		$user_id = get_current_user_id();
+		if (!$user_id) {
+			return $this->unauthorized();
+		}
 
 		if (empty($data['amount'])) {
 			return $this->validationError(['message' => 'Amount is required']);
@@ -88,7 +91,7 @@
 	 */
 	public function getInvoices(WP_REST_Request $request): WP_REST_Response
 	{
-		$user_id = absint($request->get_param('user') ?? get_current_user_id());
+		$user_id = get_current_user_id();
 
 		if (!$user_id) {
 			return $this->validationError(['message' => 'Not logged in']);
@@ -135,7 +138,7 @@
 	 */
 	public function getSavedCards(WP_REST_Request $request): WP_REST_Response
 	{
-		$user_id = absint($request->get_param('user') ?? get_current_user_id());
+		$user_id = get_current_user_id();
 
 		if (!$user_id) {
 			return $this->validationError(['message' => 'Not logged in']);

--
Gitblit v1.10.0