Jake Vanderwerf
2025-09-30 12e5205559c8def89659f9922a91b8b628289664
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;