From 9b6be66623d8aac0ce862864604f3f5879eb13f5 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Fri, 4 Jul 2025 15:42:26 -0400 Subject: [PATCH] Initial work on Adding Payment Methods for Online Payments in Client on Agent Side and initial work on AI Providers with multiple model support assigned to various sections and custom prompts --- client_autopay.php | 130 ++++++++++++++++++++++++++++++++++ database_updates.php | 31 +++++++- db.sql | 41 ++++++++++- includes/database_version.php | 2 +- 4 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 client_autopay.php diff --git a/client_autopay.php b/client_autopay.php new file mode 100644 index 00000000..a4231baa --- /dev/null +++ b/client_autopay.php @@ -0,0 +1,130 @@ + + +
+
+

AutoPay

+
+ +
+ + + + Save card details
+ In order to set up automatic payments, you must create a customer record in Stripe.
+ First, you must authorize Stripe to store your card details for the purpose of automatic payment. +

+ +
+
+ +
+
+ + +
+
+ +
+ +
+
+
+ + + elseif (empty($stripe_pm)) { ?> + + Save card details
+ Please add the payment details you would like to save.
+ By adding payment details here, you grant consent for future automatic payments of invoices.

+ + + + +
+ +
+ + + + Manage saved payment methods + + customers->retrievePaymentMethod( + $stripe_id, + $stripe_pm, + [] + ); + + } catch (Exception $e) { + $error = $e->getMessage(); + error_log("Stripe payment error - encountered exception when fetching payment method info for $stripe_pm: $error"); + logApp("Stripe", "error", "Exception when fetching payment method info for $stripe_pm: $error"); + } + + $card_name = nullable_htmlentities($payment_method->billing_details->name); + $card_brand = nullable_htmlentities($payment_method->card->display_brand); + $card_last4 = nullable_htmlentities($payment_method->card->last4); + $card_expires = nullable_htmlentities($payment_method->card->exp_month) . "/" . nullable_htmlentities($payment_method->card->exp_year); + + ?> + +
+ +
+ Actions
+ - Remove saved payment method + + + + +
+ +
+ + + CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.1'"); } - // if (CURRENT_DATABASE_VERSION == '2.2.1') { - // // Insert queries here required to update to DB version 2.2.2 + if (CURRENT_DATABASE_VERSION == '2.2.1') { + mysqli_query($mysqli, "CREATE TABLE `ai_providers` ( + `ai_provider_id` INT(11) NOT NULL AUTO_INCREMENT, + `ai_provider_name` VARCHAR(200) NOT NULL, + `ai_provider_api_url` VARCHAR(200) NOT NULL, + `ai_provider_api_key` VARCHAR(200) DEFAULT NULL, + `ai_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `ai_updated_at` DATETIME NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`ai_provider_id`) + )"); + + mysqli_query($mysqli, "CREATE TABLE `ai_provider_models` ( + `ai_model_provider_id` INT(11) NOT NULL AUTO_INCREMENT, + `ai_model_provider_name` VARCHAR(200) NOT NULL, + `ai_model_prompt` TEXT DEFAULT NULL, + `ai_model_use_case` VARCHAR(200) DEFAULT NULL, + `ai_model_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `ai_model_updated_at` DATETIME NULL ON UPDATE CURRENT_TIMESTAMP, + `ai_model_ai_provider_id` INT(11) NOT NULL, + PRIMARY KEY (`ai_model_provider_id`) + )"); + + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.2'"); + } + + // if (CURRENT_DATABASE_VERSION == '2.2.2') { + // // Insert queries here required to update to DB version 2.2.3 // // Then, update the database to the next sequential version - // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.2'"); + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.3'"); // } } else { diff --git a/db.sql b/db.sql index d02d3ea2..d73df616 100644 --- a/db.sql +++ b/db.sql @@ -1,4 +1,4 @@ -/*M!999999\- enable the sandbox mode */ +/*M!999999\- enable the sandbox mode */ -- MariaDB dump 10.19 Distrib 10.11.11-MariaDB, for debian-linux-gnu (x86_64) -- -- Host: localhost Database: itflow_dev @@ -38,6 +38,43 @@ CREATE TABLE `accounts` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `ai_provider_models` +-- + +DROP TABLE IF EXISTS `ai_provider_models`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `ai_provider_models` ( + `ai_model_provider_id` int(11) NOT NULL AUTO_INCREMENT, + `ai_model_provider_name` varchar(200) NOT NULL, + `ai_model_prompt` text DEFAULT NULL, + `ai_model_use_case` varchar(200) DEFAULT NULL, + `ai_model_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `ai_model_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + `ai_model_ai_provider_id` int(11) NOT NULL, + PRIMARY KEY (`ai_model_provider_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ai_providers` +-- + +DROP TABLE IF EXISTS `ai_providers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `ai_providers` ( + `ai_provider_id` int(11) NOT NULL AUTO_INCREMENT, + `ai_provider_name` varchar(200) NOT NULL, + `ai_provider_api_url` varchar(200) NOT NULL, + `ai_provider_api_key` varchar(200) DEFAULT NULL, + `ai_created_at` datetime NOT NULL DEFAULT current_timestamp(), + `ai_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(), + PRIMARY KEY (`ai_provider_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `api_keys` -- @@ -2591,4 +2628,4 @@ CREATE TABLE `vendors` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2025-06-21 18:33:02 +-- Dump completed on 2025-07-04 15:39:35 diff --git a/includes/database_version.php b/includes/database_version.php index 5ade9c63..023e9a12 100644 --- a/includes/database_version.php +++ b/includes/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "2.2.1"); +DEFINE("LATEST_DATABASE_VERSION", "2.2.2");