diff --git a/database_updates.php b/database_updates.php
index c29c68ed..6ad35610 100644
--- a/database_updates.php
+++ b/database_updates.php
@@ -2404,10 +2404,16 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.5'");
}
- // if (CURRENT_DATABASE_VERSION == '1.7.5') {
- // // Insert queries here required to update to DB version 1.7.6
+ if (CURRENT_DATABASE_VERSION == '1.7.5') {
+ mysqli_query($mysqli, "CREATE TABLE `client_stripe` (`client_id` INT(11) NOT NULL, `stripe_id` VARCHAR(255) NOT NULL, `stripe_pm` varchar(255) NULL) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci; ");
+
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.6'");
+ }
+
+ // if (CURRENT_DATABASE_VERSION == '1.7.6') {
+ // // Insert queries here required to update to DB version 1.7.7
// // Then, update the database to the next sequential version
- // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.6'");
+ // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '1.7.7'");
// }
} else {
diff --git a/database_version.php b/database_version.php
index 589a6c56..61ca815b 100644
--- a/database_version.php
+++ b/database_version.php
@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
-DEFINE("LATEST_DATABASE_VERSION", "1.7.5");
+DEFINE("LATEST_DATABASE_VERSION", "1.7.6");
diff --git a/db.sql b/db.sql
index 664915d8..6001fb86 100644
--- a/db.sql
+++ b/db.sql
@@ -342,6 +342,17 @@ CREATE TABLE `client_notes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `client_stripe`
+--
+
+DROP TABLE IF EXISTS `client_stripe`;
+CREATE TABLE IF NOT EXISTS `client_stripe` (
+ `client_id` int(11) NOT NULL,
+ `stripe_id` varchar(255) NOT NULL,
+ `stripe_pm` varchar(255) NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
--
-- Table structure for table `client_tags`
--
diff --git a/js/autopay_setup_stripe.js b/js/autopay_setup_stripe.js
new file mode 100644
index 00000000..d0787f1b
--- /dev/null
+++ b/js/autopay_setup_stripe.js
@@ -0,0 +1,23 @@
+// Initialize Stripe.js
+const stripe = Stripe('pk_test_51OTpmkHRGkC845Mqz0zM2A1pjnnXwOyD5tyPzWnRwVthuizNjuBIjoYgMHBMLQBuegrUXQpIyX4yr1fNMo7QzCs500bBnFJgEr');
+
+initialize();
+
+// Fetch Checkout Session and retrieve the client secret
+async function initialize() {
+ const fetchClientSecret = async () => {
+ const response = await fetch("/portal/portal_post.php?create_stripe_checkout", {
+ method: "POST",
+ });
+ const { clientSecret } = await response.json();
+ return clientSecret;
+ };
+
+ // Initialize Checkout
+ const checkout = await stripe.initEmbeddedCheckout({
+ fetchClientSecret,
+ });
+
+ // Mount Checkout
+ checkout.mount('#checkout');
+}
diff --git a/portal/autopay.php b/portal/autopay.php
new file mode 100644
index 00000000..a4b92821
--- /dev/null
+++ b/portal/autopay.php
@@ -0,0 +1,126 @@
+
+
+
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.
We’re writing to confirm that your payment details have been securely stored with Stripe, our trusted payment processor.
By agreeing to save your payment information, you have authorized us to automatically bill your card ($card_info) for any future invoices. The payment details you’ve provided are securely stored with Stripe and will be used solely for invoices. We do not have access to your full card details.
You may update or remove your payment information at any time using the portal.