From 12e5205559c8def89659f9922a91b8b628289664 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 30 Sep 2025 20:18:30 +0000
Subject: [PATCH] Square update and initial Referral System started

---
 assets/js/dash/SquareCheckout.js |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/assets/js/dash/SquareCheckout.js b/assets/js/dash/SquareCheckout.js
index d7adab8..1a1dda3 100644
--- a/assets/js/dash/SquareCheckout.js
+++ b/assets/js/dash/SquareCheckout.js
@@ -507,29 +507,30 @@
 		if (squareConfig.isOpen !== '1') {
 			return;
 		}
-		const response = await fetch(this.config.api_url + 'checkout', {
+
+		// Square Web Payments SDK handles EVERYTHING
+		// We just need to track the order for status updates
+		const response = await fetch(this.config.api_url + 'save-order', {
 			method: 'POST',
 			headers: {
 				'Content-Type': 'application/json',
 				'X-WP-Nonce': this.config.nonce
 			},
 			body: JSON.stringify({
-				source_id: token,
-				amount: orderData.total,
-				items: orderData.items,
+				order_id: token.orderId,  // From Square SDK response
+				payment_id: token.paymentId,  // From Square SDK response
 				customer: orderData.customer,
-				note: orderData.note,
-				currency: this.config.currency,
+				items: orderData.items,
 				action: 'jvb_integration_action',
 				service: 'square',
-				integration_action: 'process_order'
+				integration_action: 'save_order'
 			})
 		});
 
 		const result = await response.json();
 
 		if (!response.ok) {
-			throw new Error(result.message || 'Payment failed');
+			throw new Error(result.message || 'Failed to save order');
 		}
 
 		return result;

--
Gitblit v1.10.0