Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

feat!: simplified webhook notifications without iterator (might break your current webhook settings)

Miguel Ribeiroe0f204803e63
diff --git a/endpoints/cronjobs/sendcancellationnotifications.php b/endpoints/cronjobs/sendcancellationnotifications.php
index b6d159f..32f5f0e 100644
--- a/endpoints/cronjobs/sendcancellationnotifications.php
+++ b/endpoints/cronjobs/sendcancellationnotifications.php
@@ -29,6 +29,7 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
$pushoverNotificationsEnabled = false;
$discordNotificationsEnabled = false;
$ntfyNotificationsEnabled = false;
+ $webhookNotificationsEnabled = false;
// Check if email notifications are enabled and get the settings
$query = "SELECT * FROM email_notifications WHERE user_id = :userId";
@@ -113,8 +114,24 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
$ntfy['ignore_ssl'] = $row["ignore_ssl"];
}
+ // Check if webhook notifications are enabled and have cancelation payload set and get the settings
+ $query = "SELECT * FROM webhook_notifications WHERE user_id = :userId";
+ $stmt = $db->prepare($query);
+ $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
+ $result = $stmt->execute();
+
+ $webhook = [];
+ if ($row = $result->fetchArray(SQLITE3_ASSOC)) {
+ $webhook['url'] = $row["url"];
+ $webhook['headers'] = $row["headers"];
+ $webhook['cancelation_payload'] = $row["cancelation_payload"];
+ $webhook['ignore_ssl'] = $row["ignore_ssl"];
+ $webhook['request_method'] = $row["request_method"];
+ $webhookNotificationsEnabled = $row['enabled'] && $row['cancelation_payload'] != "";
+ }
+
$notificationsEnabled = $emailNotificationsEnabled || $gotifyNotificationsEnabled || $telegramNotificationsEnabled ||
- $pushoverNotificationsEnabled || $discordNotificationsEnabled ||$ntfyNotificationsEnabled;
+ $pushoverNotificationsEnabled || $discordNotificationsEnabled ||$ntfyNotificationsEnabled || $webhookNotificationsEnabled;
// If no notifications are enabled, no need to run
if (!$notificationsEnabled) {
@@ -177,6 +194,8 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
$notify[$rowSubscription['payer_user_id']][$i]['category'] = $categories[$rowSubscription['category_id']]['name'];
$notify[$rowSubscription['payer_user_id']][$i]['payer'] = $household[$rowSubscription['payer_user_id']]['name'];
$notify[$rowSubscription['payer_user_id']][$i]['date'] = $rowSubscription['next_payment'];
+ $notify[$rowSubscription['payer_user_id']][$i]['url'] = $rowSubscription['url'];
+ $notify[$rowSubscription['payer_user_id']][$i]['notes'] = $rowSubscription['notes'];
$i++;
}
@@ -499,6 +518,68 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
}
}
+ // Webhook notifications if enabled
+ if ($webhookNotificationsEnabled) {
+ foreach ($notify as $userId => $perUser) {
+ // Get name of user from household table
+ $stmt = $db->prepare('SELECT * FROM household WHERE id = :userId');
+ $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
+ $result = $stmt->execute();
+ $user = $result->fetchArray(SQLITE3_ASSOC);
+
+ if ($user['name']) {
+ $payer = $user['name'];
+ }
+
+ foreach ($perUser as $subscription) {
+ // Ensure the payload is reset for each subscription
+ $payload = $webhook['cancelation_payload'];
+ $payload = str_replace("{{subscription_name}}", $subscription['name'], $payload);
+ $payload = str_replace("{{subscription_price}}", $subscription['price'], $payload);
+ $payload = str_replace("{{subscription_currency}}", $subscription['currency'], $payload);
+ $payload = str_replace("{{subscription_category}}", $subscription['category'], $payload);
+ $payload = str_replace("{{subscription_payer}}", $payer, $payload);
+ $payload = str_replace("{{subscription_date}}", $subscription['date'], $payload);
+ $payload = str_replace("{{subscription_url}}", $subscription['url'], $payload);
+ $payload = str_replace("{{subscription_notes}}", $subscription['notes'], $payload);
+
+ // Initialize cURL for each subscription
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $webhook['url']);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $webhook['request_method']);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
+
+ // Add headers if they exist
+ if (!empty($webhook['headers'])) {
+ $customheaders = preg_split("/\r\n|\n|\r/", $webhook['headers']);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders);
+ }
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ // Handle SSL settings
+ if ($webhook['ignore_ssl']) {
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ }
+
+ // Execute the cURL request
+ $response = curl_exec($ch);
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+
+ if ($response === false || $httpCode >= 400) {
+ echo "Error sending cancellation notifications: " . curl_error($ch) . "<br />";
+ } else {
+ echo "Webhook Cancellation Notification sent for subscription: " . $subscription['name'] . "<br />";
+ }
+
+ usleep(1000000); // 1s delay between requests
+ }
+ }
+ }
+
+
} else {
if (php_sapi_name() !== 'cli') {
echo "Nothing to notify.<br />";
diff --git a/endpoints/cronjobs/sendnotifications.php b/endpoints/cronjobs/sendnotifications.php
index dd890d8..8acfb95 100644
--- a/endpoints/cronjobs/sendnotifications.php
+++ b/endpoints/cronjobs/sendnotifications.php
@@ -170,14 +170,6 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
$webhook['request_method'] = $row["request_method"];
$webhook['headers'] = $row["headers"];
$webhook['payload'] = $row["payload"];
- $webhook['iterator'] = $row["iterator"];
- if ($webhook['iterator'] === "") {
- $webhook['iterator'] = "{{subscriptions}}";
- } else {
- if (strpos($webhook['iterator'], "{{") === false) {
- $webhook['iterator'] = "{{" . $webhook['iterator'] . "}}";
- }
- }
$webhook['ignore_ssl'] = $row["ignore_ssl"];
}
@@ -605,140 +597,67 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
// Webhook notifications if enabled
if ($webhookNotificationsEnabled) {
-
- // Get webhook payload and turn it into a json object
-
- $payload = str_replace("{{days_until}}", $days, $webhook['payload']);
-
- $payload_json = json_decode($payload, true);
-
- // If the payload is valid json, iterate the object and replace the placeholders with the subscription data (all subscriptions in one payload)
- if ($payload_json !== null) {
- $subscription_template = $payload_json[$webhook['iterator']];
- $subscriptions = [];
-
- foreach ($notify as $userId => $perUser) {
- // Get name of user from household table
- $stmt = $db->prepare('SELECT * FROM household WHERE id = :userId');
- $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
- $result = $stmt->execute();
- $user = $result->fetchArray(SQLITE3_ASSOC);
-
- if ($user['name']) {
- $payer = $user['name'];
- }
-
- foreach ($perUser as $k => $subscription) {
- $temp_subscription = $subscription_template[0];
-
- foreach ($temp_subscription as $key => $value) {
- if (is_string($value)) {
- $temp_subscription[$key] = str_replace("{{subscription_name}}", $subscription['name'], $value);
- $temp_subscription[$key] = str_replace("{{subscription_price}}", $subscription['formatted_price'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_currency}}", $subscription['currency'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_category}}", $subscription['category'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_payer}}", $subscription['payer'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_date}}", $subscription['date'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_days_until_payment}}", $subscription['days'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_url}}", $subscription['url'], $temp_subscription[$key]);
- $temp_subscription[$key] = str_replace("{{subscription_notes}}", $subscription['notes'], $temp_subscription[$key]);
- }
- }
- $subscriptions[] = $temp_subscription;
-
- }
- }
-
- // remove {{ and }} from the iterator
- $payload_iterator = str_replace("{{", "", $webhook['iterator']);
- $payload_iterator = str_replace("}}", "", $payload_iterator);
-
- $payload_json["{{subscriptions}}"] = $subscriptions;
- $payload_json[$payload_iterator] = $subscriptions;
- unset($payload_json["{{subscriptions}}"]);
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $webhook['url']);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $webhook['request_method']);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload_json));
- if (!empty($webhook['headers'])) {
- $customheaders = preg_split("/\r\n|\n|\r/", $webhook['headers']);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders);
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- if ($webhook['ignore_ssl']) {
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- }
-
- $response = curl_exec($ch);
- curl_close($ch);
-
- if ($response === false) {
- echo "Error sending notifications: " . curl_error($ch) . "<br />";
- } else {
- echo "Webhook Notifications sent<br />";
+ foreach ($notify as $userId => $perUser) {
+ // Get name of user from household table
+ $stmt = $db->prepare('SELECT * FROM household WHERE id = :userId');
+ $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
+ $result = $stmt->execute();
+ $user = $result->fetchArray(SQLITE3_ASSOC);
+
+ if ($user['name']) {
+ $payer = $user['name'];
}
- }
-
-
- // If the payload is not valid json, send it directly as a string, replacing the placeholders with the subscription data (one notification per subscription)
-
- if ($payload_json === null) {
- foreach ($notify as $userId => $perUser) {
- // Get name of user from household table
- $stmt = $db->prepare('SELECT * FROM household WHERE id = :userId');
- $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
- $result = $stmt->execute();
- $user = $result->fetchArray(SQLITE3_ASSOC);
-
- if ($user['name']) {
- $payer = $user['name'];
+
+ foreach ($perUser as $subscription) {
+ // Ensure the payload is reset for each subscription
+ $payload = $webhook['payload'];
+ $payload = str_replace("{{days_until}}", $days, $payload);
+ $payload = str_replace("{{subscription_name}}", $subscription['name'], $payload);
+ $payload = str_replace("{{subscription_price}}", $subscription['formatted_price'], $payload);
+ $payload = str_replace("{{subscription_currency}}", $subscription['currency'], $payload);
+ $payload = str_replace("{{subscription_category}}", $subscription['category'], $payload);
+ $payload = str_replace("{{subscription_payer}}", $payer, $payload); // Use $payer instead of $subscription['payer']
+ $payload = str_replace("{{subscription_date}}", $subscription['date'], $payload);
+ $payload = str_replace("{{subscription_days_until_payment}}", $subscription['days'], $payload);
+ $payload = str_replace("{{subscription_url}}", $subscription['url'], $payload);
+ $payload = str_replace("{{subscription_notes}}", $subscription['notes'], $payload);
+
+ // Initialize cURL for each subscription
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $webhook['url']);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $webhook['request_method']);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
+
+ // Add headers if they exist
+ if (!empty($webhook['headers'])) {
+ $customheaders = preg_split("/\r\n|\n|\r/", $webhook['headers']);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders);
}
-
- foreach ($perUser as $k => $subscription) {
- // Ensure the payload is reset for each subscription
- $payload = $webhook['payload'];
- $payload = str_replace("{{days_until}}", $days, $payload);
- $payload = str_replace("{{subscription_name}}", $subscription['name'], $payload);
- $payload = str_replace("{{subscription_price}}", $subscription['formatted_price'], $payload);
- $payload = str_replace("{{subscription_currency}}", $subscription['currency'], $payload);
- $payload = str_replace("{{subscription_category}}", $subscription['category'], $payload);
- $payload = str_replace("{{subscription_payer}}", $payer, $payload); // Use $payer instead of $subscription['payer']
- $payload = str_replace("{{subscription_date}}", $subscription['date'], $payload);
- $payload = str_replace("{{subscription_days_until_payment}}", $subscription['days'], $payload);
- $payload = str_replace("{{subscription_url}}", $subscription['url'], $payload);
- $payload = str_replace("{{subscription_notes}}", $subscription['notes'], $payload);
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $webhook['url']);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $webhook['request_method']);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
- if (!empty($webhook['headers'])) {
- $customheaders = preg_split("/\r\n|\n|\r/", $webhook['headers']);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders);
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- $response = curl_exec($ch);
- curl_close($ch);
-
- if ($response === false) {
- echo "Error sending notifications: " . curl_error($ch) . "<br />";
- } else {
- echo "Webhook Notification sent <br />";
- }
-
- // Delay for 200 milliseconds
- usleep(500000);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ // Handle SSL settings
+ if ($webhook['ignore_ssl']) {
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
+
+ // Execute the cURL request
+ $response = curl_exec($ch);
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+
+ if ($response === false || $httpCode >= 400) {
+ echo "Error sending notifications: " . curl_error($ch) . "<br />";
+ } else {
+ echo "Webhook Notification sent for subscription: " . $subscription['name'] . "<br />";
+ }
+
+ usleep(1000000); // 1s delay between requests
}
}
-
}
-
} else {
if (php_sapi_name() !== 'cli') {
echo "Nothing to notify.<br />";
diff --git a/endpoints/notifications/savewebhooknotifications.php b/endpoints/notifications/savewebhooknotifications.php
index e542d8e..6cb0791 100644
--- a/endpoints/notifications/savewebhooknotifications.php
+++ b/endpoints/notifications/savewebhooknotifications.php
@@ -13,8 +13,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$data = json_decode($postData, true);
if (
- !isset($data["webhook_url"]) || $data["webhook_url"] == "" ||
- !isset($data["payload"]) || $data["payload"] == ""
+ !isset($data["webhook_url"]) || $data["webhook_url"] == ""
) {
$response = [
"success" => false,
@@ -26,7 +25,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$url = $data["webhook_url"];
$headers = $data["headers"];
$payload = $data["payload"];
- $iterator = $data["iterator"];
+ $cancelation_payload = $data["cancelation_payload"];
$ignore_ssl = $data["ignore_ssl"];
$query = "SELECT COUNT(*) FROM webhook_notifications WHERE user_id = :userId";
@@ -44,11 +43,11 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$row = $result->fetchArray();
$count = $row[0];
if ($count == 0) {
- $query = "INSERT INTO webhook_notifications (enabled, url, headers, payload, iterator, user_id, ignore_ssl)
- VALUES (:enabled, :url, :headers, :payload, :iterator, :userId, :ignore_ssl)";
+ $query = "INSERT INTO webhook_notifications (enabled, url, headers, payload, cancelation_payload, user_id, ignore_ssl)
+ VALUES (:enabled, :url, :headers, :payload, :cancelation_payload, :userId, :ignore_ssl)";
} else {
$query = "UPDATE webhook_notifications
- SET enabled = :enabled, url = :url, headers = :headers, payload = :payload, iterator = :iterator, ignore_ssl = :ignore_ssl WHERE user_id = :userId";
+ SET enabled = :enabled, url = :url, headers = :headers, payload = :payload, cancelation_payload = :cancelation_payload, ignore_ssl = :ignore_ssl WHERE user_id = :userId";
}
$stmt = $db->prepare($query);
@@ -56,7 +55,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$stmt->bindValue(':url', $url, SQLITE3_TEXT);
$stmt->bindValue(':headers', $headers, SQLITE3_TEXT);
$stmt->bindValue(':payload', $payload, SQLITE3_TEXT);
- $stmt->bindValue(':iterator', $iterator, SQLITE3_TEXT);
+ $stmt->bindValue(':cancelation_payload', $cancelation_payload, SQLITE3_TEXT);
$stmt->bindValue(':ignore_ssl', $ignore_ssl, SQLITE3_INTEGER);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
diff --git a/endpoints/notifications/testwebhooknotifications.php b/endpoints/notifications/testwebhooknotifications.php
index 9e8fc24..075aa50 100644
--- a/endpoints/notifications/testwebhooknotifications.php
+++ b/endpoints/notifications/testwebhooknotifications.php
@@ -2,6 +2,20 @@
require_once '../../includes/connect_endpoint.php';
+// Variables available: {{days_until}}, {{subscription_name}}, {{subscription_price}}, {{subscription_currency}}, {{subscription_category}}, {{subscription_date}}, {{subscription_payer}}, {{subscription_days_until_payment}}, {{subscription_notes}}, {{subscription_url}}
+$fakeSubscription = [
+ "days_until" => 5,
+ "subscription_name" => "Test Subscription",
+ "subscription_price" => 10.00,
+ "subscription_currency" => "USD",
+ "subscription_category" => "Test Category",
+ "subscription_date" => date("Y-m-d H:i:s"),
+ "subscription_payer" => "Test Payer",
+ "subscription_days_until_payment" => 30,
+ "subscription_notes" => "Test Notes",
+ "subscription_url" => "https://example.com/test-subscription"
+];
+
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
die(json_encode([
"success" => false,
@@ -27,6 +41,13 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
$requestmethod = $data["requestmethod"];
$url = $data["url"];
$payload = $data["payload"];
+
+ // Replace placeholders in the payload with fake subscription data
+ foreach ($fakeSubscription as $key => $value) {
+ $placeholder = "{{" . $key . "}}";
+ $payload = str_replace($placeholder, $value, $payload);
+ }
+
$customheaders = json_decode($data["customheaders"], true);
$ignore_ssl = $data["ignore_ssl"];
@@ -48,13 +69,13 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
// Execute the request
$response = curl_exec($ch);
-
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Close the cURL session
curl_close($ch);
// Check if the message was sent successfully
- if ($response === false) {
+ if ($response === false || $httpCode >= 400) {
die(json_encode([
"success" => false,
"message" => translate('notification_failed', $i18n),
diff --git a/includes/i18n/cs.php b/includes/i18n/cs.php
index 9fef294..49eca52 100644
--- a/includes/i18n/cs.php
+++ b/includes/i18n/cs.php
@@ -181,7 +181,8 @@ $i18n = [
"request_method" => "Metoda požadavku",
"custom_headers" => "Vlastní hlavičky",
"webhook_payload" => "Zatížení webhooku",
- "webhook_iterator_key" => "Nahradit {{subscriptions}} názvem klíče",
+ "payment_notifications_payload" => "Zatížení oznámení o platbě",
+ "cancelation_notification_payload" => "Zatížení oznámení o zrušení",
"variables_available" => "Dostupné proměnné",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/de.php b/includes/i18n/de.php
index 74146ed..d98cb40 100644
--- a/includes/i18n/de.php
+++ b/includes/i18n/de.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Request Methode",
"custom_headers" => "Benutzerdefinierte Kopfzeilen",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Ersetze {{subscriptions}} durch den Schlüsselnamen",
+ "payment_notifications_payload" => "Zahlungsbenachrichtigung Payload",
+ "cancelation_notification_payload" => "Kündigungsbenachrichtigung Payload",
"variables_available" => "Verfügbare Variablen",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/el.php b/includes/i18n/el.php
index 1022a57..86cad74 100644
--- a/includes/i18n/el.php
+++ b/includes/i18n/el.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Μέθοδος αίτησης",
"custom_headers" => "Προσαρμοσμένες κεφαλίδες",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Αντικαταστήστε {{subscriptions}} με το όνομα του κλειδιού",
+ "payment_notifications_payload" => "Ειδοποίηση πληρωμής Payload",
+ "cancelation_notification_payload" => "Ακύρωση ειδοποίησης Payload",
"variables_available" => "Διαθέσιμες μεταβλητές",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/en.php b/includes/i18n/en.php
index eda9295..87afd2d 100644
--- a/includes/i18n/en.php
+++ b/includes/i18n/en.php
@@ -181,7 +181,8 @@ $i18n = [
"request_method" => "Request Method",
"custom_headers" => "Custom Headers",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Replace {{subscriptions}} with key name",
+ "payment_notifications_payload" => "Payment Notification Payload",
+ "cancelation_notification_payload" => "Cancelation Notification Payload",
"variables_available" => "Variables available",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/es.php b/includes/i18n/es.php
index bcfa8ca..27e9921 100644
--- a/includes/i18n/es.php
+++ b/includes/i18n/es.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Método de Solicitud",
"custom_headers" => "Cabeceras Personalizadas",
"webhook_payload" => "Carga del Webhook",
- "webhook_iterator_key" => "Sustituye {{subscriptions}} por el nombre de la clave",
+ "payment_notifications_payload" => "Carga de la Notificación de Pago",
+ "cancelation_notification_payload" => "Carga de la Notificación de Cancelación",
"variables_available" => "Variables disponibles",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/fr.php b/includes/i18n/fr.php
index cc59eab..d60695e 100644
--- a/includes/i18n/fr.php
+++ b/includes/i18n/fr.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Méthode de requête",
"custom_headers" => "En-têtes personnalisés",
"webhook_payload" => "Charge utile du webhook",
- "webhook_iterator_key" => "Remplacer {{subscriptions}} par le nom de la clé",
+ "payment_notifications_payload" => "Charge utile de la notification de paiement",
+ "cancelation_notification_payload" => "Charge utile de la notification d'annulation",
"variables_available" => "Variables disponibles",
"gotify" => "Gotify",
"token" => "Jeton",
diff --git a/includes/i18n/it.php b/includes/i18n/it.php
index ed75b81..03823b9 100644
--- a/includes/i18n/it.php
+++ b/includes/i18n/it.php
@@ -187,7 +187,8 @@ $i18n = [
"request_method" => "Metodo di richiesta",
"custom_headers" => "Intestazioni personalizzate",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Sostituisci {{subscriptions}} con il nome della chiave",
+ "payment_notifications_payload" => "Carica il payload della notifica di pagamento",
+ "cancelation_notification_payload" => "Carica il payload della notifica di cancellazione",
"variables_available" => "Variabili disponibili",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/jp.php b/includes/i18n/jp.php
index f35ef6b..40e2d98 100644
--- a/includes/i18n/jp.php
+++ b/includes/i18n/jp.php
@@ -181,7 +181,8 @@ $i18n = [
"request_method" => "リクエストメソッド",
"custom_headers" => "カスタムヘッダー",
"webhook_payload" => "Webhookペイロード",
- "webhook_iterator_keu" => "{{subscriptions}}をキー名に置き換える」",
+ "payment_notifications_payload" => "支払い通知ペイロード",
+ "cancelation_notification_payload" => "キャンセル通知ペイロード",
"variables_available" => "利用可能な変数",
"gotify" => "Gotify",
"token" => "トークン",
diff --git a/includes/i18n/ko.php b/includes/i18n/ko.php
index f0f330d..f4a5d9b 100644
--- a/includes/i18n/ko.php
+++ b/includes/i18n/ko.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "요청 메서드",
"custom_headers" => "커스텀 헤더",
"webhook_payload" => "웹훅 페이로드",
- "webhook_iterator_key" => "{{subscriptions}}을 키 이름으로 바꾸기",
+ "payment_notifications_payload" => "결제 알림 페이로드",
+ "cancelation_notification_payload" => "구독 취소 알림 페이로드",
"variables_available" => "사용 가능한 변수",
"gotify" => "Gotify",
"token" => "토큰",
diff --git a/includes/i18n/nl.php b/includes/i18n/nl.php
index e42029c..4fd7939 100644
--- a/includes/i18n/nl.php
+++ b/includes/i18n/nl.php
@@ -181,7 +181,8 @@ $i18n = [
"request_method" => "Request Methode",
"custom_headers" => "Aangepaste Headers",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Vervang {{subscriptions}} met sleutelnaam",
+ "payment_notifications_payload" => "Betalingsnotificatie Payload",
+ "cancelation_notification_payload" => "Opzegnotificatie Payload",
"variables_available" => "Beschikbare variabelen",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/pl.php b/includes/i18n/pl.php
index dabc4ba..6f25cb6 100644
--- a/includes/i18n/pl.php
+++ b/includes/i18n/pl.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Metoda żądania",
"custom_headers" => "Niestandardowe nagłówki",
"webhook_payload" => "Dane webhooka",
- "webhook_iterator_key" => "Zastąp {{subscriptions}} nazwą klucza",
+ "payment_notifications_payload" => "Dane powiadomienia o płatności",
+ "cancelation_notification_payload" => "Dane powiadomienia o anulowaniu subskrypcji",
"variables_available" => "Dostępne zmienne",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/pt.php b/includes/i18n/pt.php
index 4ebad89..f388bb0 100644
--- a/includes/i18n/pt.php
+++ b/includes/i18n/pt.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Método de Pedido",
"custom_headers" => "Cabeçalhos Personalizados",
"webhook_payload" => "Payload do Webhook",
- "webhook_iterator_key" => "Substituir {{subscriptions}} pelo nome da chave",
+ "payment_notifications_payload" => "Payload da notificação de pagamento",
+ "cancelation_notification_payload" => "Payload da notificação de cancelamento",
"variables_available" => "Variáveis Disponíveis",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.php
index a4af5eb..de95957 100644
--- a/includes/i18n/pt_br.php
+++ b/includes/i18n/pt_br.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Método de requisição",
"custom_headers" => "Cabeçalhos personalizados",
"webhook_payload" => "Payload do Webhook",
- "webhook_iterator_key" => "Substituir {{subscriptions}} pelo nome da chave",
+ "payment_notifications_payload" => "Payload da notificação de pagamento",
+ "cancelation_notification_payload" => "Payload da notificação de cancelamento",
"variables_available" => "Variáveis disponíveis",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/ru.php b/includes/i18n/ru.php
index 7faac1f..e9693e1 100644
--- a/includes/i18n/ru.php
+++ b/includes/i18n/ru.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Метод запроса",
"custom_headers" => "Пользовательские заголовки",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Заменить {{subscriptions}} именем ключа.",
+ "payment_notifications_payload" => "Payload уведомлений о платеже",
+ "cancelation_notification_payload" => "Уведомление об отмене подписки Payload",
"variables_available" => "Доступные переменные",
"gotify" => "Gotify",
"token" => "Токен",
diff --git a/includes/i18n/sl.php b/includes/i18n/sl.php
index 1cee991..75a2673 100644
--- a/includes/i18n/sl.php
+++ b/includes/i18n/sl.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Metoda zahteve",
"custom_headers" => "Glave po meri",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Zamenjaj {{subscriptions}} z imenom ključa",
+ "payment_notifications_payload" => "Obvestilo o plačilu",
+ "cancelation_notification_payload" => "Obvestilo o preklicu",
"variables_available" => "Spremenljivke, ki so na voljo",
"gotify" => "Gotify",
"token" => "Žeton",
diff --git a/includes/i18n/sr.php b/includes/i18n/sr.php
index f546f83..9f370c5 100644
--- a/includes/i18n/sr.php
+++ b/includes/i18n/sr.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Метод захтева",
"custom_headers" => "Прилагођени заглавља",
"webhook_payload" => "Вебхук Пајлоад",
- "webhook_iterator_key" => "{{subscriptions}} замени кључним итератором",
+ "payment_notifications_payload" => "Обавештење о плаћању Пејлоад",
+ "cancelation_notification_payload" => "Отказивање обавештење Пејлоад",
"variables_available" => "Доступне променљиве",
"gotify" => "Готифи",
"token" => "Токен",
diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.php
index 9fcd508..b53664e 100644
--- a/includes/i18n/sr_lat.php
+++ b/includes/i18n/sr_lat.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Metod zahteva",
"custom_headers" => "Prilagođeni zaglavlja",
"webhook_payload" => "Webhook payload",
- "webhook_iterator_key" => "Zameni {{subscriptions}} sa ključem",
+ "payment_notifications_payload" => "Obaveštenje o uplati payload",
+ "cancelation_notification_payload" => "Obaveštenje o otkazivanju payload",
"variables_available" => "Dostupne promenljive",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/tr.php b/includes/i18n/tr.php
index 85371bb..ae58958 100644
--- a/includes/i18n/tr.php
+++ b/includes/i18n/tr.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "İstek Metodu",
"custom_headers" => "Özel Başlıklar",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "{{subscriptions}}'yi anahtar olarak değiştir",
+ "payment_notifications_payload" => "Ödeme Bildirimi Payload",
+ "cancelation_notification_payload" => "İptal Bildirimi Payload",
"variables_available" => "Kullanılabilir Değişkenler",
"gotify" => "Gotify",
"token" => "Token",
diff --git a/includes/i18n/uk.php b/includes/i18n/uk.php
index 640d40e..05fa4da 100644
--- a/includes/i18n/uk.php
+++ b/includes/i18n/uk.php
@@ -180,7 +180,8 @@ $i18n = [
"request_method" => "Метод запиту",
"custom_headers" => "Користувацькі заголовки",
"webhook_payload" => "Webhook Payload",
- "webhook_iterator_key" => "Замінити {{subscriptions}} ім'ям ключа.",
+ "payment_notifications_payload" => "Payload для сповіщення про платіж",
+ "cancelation_notification_payload" => "Payload для сповіщення про скасування",
"variables_available" => "Доступні змінні",
"gotify" => "Gotify",
"token" => "Токен",
diff --git a/includes/i18n/vi.php b/includes/i18n/vi.php
index ddeebce..403025c 100644
--- a/includes/i18n/vi.php
+++ b/includes/i18n/vi.php
@@ -181,7 +181,8 @@ $i18n = [
"request_method" => "Phương thức yêu cầu",
"custom_headers" => "Tiêu đề tùy chỉnh",
"webhook_payload" => "Payload Webhook",
- "webhook_iterator_key" => "Thay thế {{subscriptions}} bằng tên khóa",
+ "payment_notifications_payload" => "Payload thông báo thanh toán",
+ "cancelation_notification_payload" => "Payload thông báo hủy",
"variables_available" => "Các biến khả dụng",
"gotify" => "Gotify",
"token" => "Mã thông báo",
diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.php
index d681842..77e086f 100644
--- a/includes/i18n/zh_cn.php
+++ b/includes/i18n/zh_cn.php
@@ -188,7 +188,8 @@ $i18n = [
"request_method" => "请求方法",
"custom_headers" => "自定义标头",
"webhook_payload" => "Webhook 负载",
- "webhook_iterator_key" => "替换 {{subscriptions}} 为键名",
+ "payment_notifications_payload" => "付款通知负载",
+ "cancelation_notification_payload" => "取消通知负载",
"variables_available" => "可用变量",
"gotify" => "Gotify",
"token" => "令牌",
diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.php
index 4937f73..1bc9226 100644
--- a/includes/i18n/zh_tw.php
+++ b/includes/i18n/zh_tw.php
@@ -181,7 +181,8 @@ $i18n = [
"request_method" => "請求方法",
"custom_headers" => "自訂標頭",
"webhook_payload" => "Webhook 內容",
- "webhook_iterator_key" => "取代 {{subscriptions}} 為金鑰名稱",
+ "payment_notifications_payload" => "付款通知內容",
+ "cancelation_notification_payload" => "取消通知內容",
"variables_available" => "可用變數",
"gotify" => "Gotify",
"token" => "令牌",
diff --git a/includes/version.php b/includes/version.php
index d6cff60..f02e300 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
-$version = "v2.52.2";
+$version = "v3.0.0";
?>
\ No newline at end of file
diff --git a/migrations/000036.php b/migrations/000036.php
new file mode 100644
index 0000000..855da73
--- /dev/null
+++ b/migrations/000036.php
@@ -0,0 +1,19 @@
+<?php
+
+// This migration adds a new column to the webhook_notifications table to store the cancelation payload
+// Also removes the iterator column as it is not used anymore.
+// The cancelation payload will be used to send cancelation notifications to the webhook
+
+/** @noinspection PhpUndefinedVariableInspection */
+$columnQuery = $db->query("SELECT * FROM pragma_table_info('webhook_notifications') where name='cancelation_payload'");
+$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
+
+if ($columnRequired) {
+ $db->exec("ALTER TABLE webhook_notifications ADD COLUMN cancelation_payload TEXT DEFAULT ''");
+}
+
+$columnQuery = $db->query("SELECT * FROM pragma_table_info('webhook_notifications') where name='iterator'");
+$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) !== false;
+if ($columnRequired) {
+ $db->exec("ALTER TABLE webhook_notifications DROP COLUMN iterator");
+}
diff --git a/scripts/notifications.js b/scripts/notifications.js
index ae9ca5d..ec16edc 100644
--- a/scripts/notifications.js
+++ b/scripts/notifications.js
@@ -112,7 +112,7 @@ function saveNotificationsWebhookButton() {
const webhook_url = document.getElementById("webhookurl").value;
const headers = document.getElementById("webhookcustomheaders").value;
const payload = document.getElementById("webhookpayload").value;
- const iterator = document.getElementById("webhookiteratorkey").value;
+ const cancelation_payload = document.getElementById("webhookcancelationpayload").value;
const ignore_ssl = document.getElementById("webhookignoressl").checked ? 1 : 0;
const data = {
@@ -120,7 +120,7 @@ function saveNotificationsWebhookButton() {
webhook_url: webhook_url,
headers: headers,
payload: payload,
- iterator: iterator,
+ cancelation_payload: cancelation_payload,
ignore_ssl: ignore_ssl
};
@@ -136,7 +136,7 @@ function testNotificationsWebhookButton() {
const url = document.getElementById("webhookurl").value;
const customheaders = document.getElementById("webhookcustomheaders").value;
const payload = document.getElementById("webhookpayload").value;
- const iterator = document.getElementById("webhookiteratorkey").value;
+ const cancelation_payload = document.getElementById("webhookcancelationpayload").value;
const ignore_ssl = document.getElementById("webhookignoressl").checked ? 1 : 0;
const data = {
@@ -145,7 +145,7 @@ function testNotificationsWebhookButton() {
url: url,
customheaders: customheaders,
payload: payload,
- iterator: iterator,
+ cancelation_payload: cancelation_payload,
ignore_ssl: ignore_ssl
};
diff --git a/settings.php b/settings.php
index 0a2e073..88ef65c 100644
--- a/settings.php
+++ b/settings.php
@@ -257,7 +257,7 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];
$notificationsWebhook['request_method'] = $row['request_method'];
$notificationsWebhook['headers'] = $row['headers'];
$notificationsWebhook['payload'] = $row['payload'];
- $notificationsWebhook['iterator'] = $row['iterator'];
+ $notificationsWebhook['cancelation_payload'] = $row['cancelation_payload'];
$notificationsWebhook['ignore_ssl'] = $row['ignore_ssl'];
$rowCount++;
}
@@ -267,25 +267,19 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];
$notificationsWebhook['url'] = "";
$notificationsWebhook['request_method'] = "POST";
$notificationsWebhook['headers'] = "";
- $notificationsWebhook['iterator'] = "";
$notificationsWebhook['payload'] = '
{
- "days_until": "{{days_until}}",
- "{{subscriptions}}": [
- {
- "name": "{{subscription_name}}",
- "price": "{{subscription_price}}",
- "currency": "{{subscription_currency}}",
- "category": "{{subscription_category}}",
- "date": "{{subscription_date}}",
- "payer": "{{subscription_payer}}",
- "days": "{{subscription_days_until_payment}}",
- "notes": "{{subscription_notes}}",
- "url": "{{subscription_url}}"
- }
- ]
-
+ "name": "{{subscription_name}}",
+ "price": "{{subscription_price}}",
+ "currency": "{{subscription_currency}}",
+ "category": "{{subscription_category}}",
+ "date": "{{subscription_date}}",
+ "payer": "{{subscription_payer}}",
+ "days": "{{subscription_days_until_payment}}",
+ "notes": "{{subscription_notes}}",
+ "url": "{{subscription_url}}"
}';
+ $notificationsWebhook['cancelation_payload'] = "";
$notificationsWebhook['ignore_ssl'] = 0;
}
@@ -626,12 +620,11 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];
</div>
<div class="form-group-inline">
<textarea name="webhookpayload" id="webhookpayload"
- placeholder="<?= translate('webhook_payload', $i18n) ?>"><?= $notificationsWebhook['payload'] ?></textarea>
+ placeholder="<?= translate('payment_notifications_payload', $i18n) ?>"><?= $notificationsWebhook['payload'] ?></textarea>
</div>
<div class="form-group-inline">
- <input type="text" name="webhookiteratorkey" id="webhookiteratorkey"
- placeholder="<?= translate('webhook_iterator_key', $i18n) ?>"
- value="<?= $notificationsWebhook['iterator'] ?>" />
+ <textarea name="webhookcancelationpayload" id="webhookcancelationpayload"
+ placeholder="<?= translate('cancelation_notification_payload', $i18n) ?>"><?= $notificationsWebhook['cancelation_payload'] ?></textarea>
</div>
<div class="form-group-inline">
<input type="checkbox" id="webhookignoressl" name="webhookignoressl"
@@ -1243,4 +1236,4 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];
<?php
require_once 'includes/footer.php';
-?>
+?>
\ No newline at end of file
diff --git a/styles/dark-theme.css b/styles/dark-theme.css
index 2a6bb92..813edb1 100644
--- a/styles/dark-theme.css
+++ b/styles/dark-theme.css
@@ -93,6 +93,7 @@ input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
+textarea,
select {
background-color: #555;
border: 1px solid #666;
@@ -104,6 +105,7 @@ input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="date"]::placeholder,
input[type="number"]::placeholder,
+textarea::placeholder,
select::placeholder {
color: #BBB;
}
@@ -113,6 +115,7 @@ input[type="email"]:disabled,
input[type="password"]:disabled,
input[type="date"]:disabled,
input[type="number"]:disabled,
+textarea:disabled,
select:disabled {
background-color: #999;
border-color: #666;
@@ -135,12 +138,6 @@ input[type="color"] {
background-color: #F2F2F2;
}
-textarea {
- background-color: #555;
- border: 1px solid #666;
- color: #E0E0E0;
-}
-
.avatar-select .avatar-list .remove-avatar {
background-color: #222;
}
diff --git a/styles/styles.css b/styles/styles.css
index 1b086fc..3b2dab3 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -1017,7 +1017,7 @@ header #avatar {
}
.account-notification-section-settings.is-open {
- max-height: 1000px;
+ max-height: 1500px;
/* Set to a value larger than the content's natural height */
}
@@ -2542,45 +2542,62 @@ input[type="checkbox"] {
input[type="checkbox"]+label {
position: relative;
- padding-left: 35px;
+ padding-left: 54px;
cursor: pointer;
- display: inline-block;
- line-height: 22px;
+ display: inline-flex;
+ align-items: center;
}
input[type="checkbox"]+label::before {
content: '';
position: absolute;
left: 0;
- top: 0;
- width: 22px;
- height: 22px;
- background: #fafafa;
+ top: 50%;
+ transform: translateY(-50%);
+ width: 44px;
+ height: 24px;
+ background-color: #e9e9eb;
+ border-radius: 12px;
+ transition: background-color 0.3s ease;
border: 1px solid #ccc;
- border-radius: 3px;
+}
+
+input[type="checkbox"]+label::after {
+ content: '';
+ position: absolute;
+ left: 3px;
+ top: 50%;
+ transform: translateY(-50%);
+ width: 20px;
+ height: 20px;
+ background-color: #fff;
+ border-radius: 50%;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
+ transition: transform 0.3s ease;
}
input[type="checkbox"]:focus+label::before {
- border-color: var(--main-color);
- box-shadow: 0 0 0 2px rgba(--main-color-rgb, 0.5);
+ box-shadow: 0 0 0 2px rgba(var(--main-color-rgb, 100, 149, 237), 0.5);
}
input[type="checkbox"]:disabled+label::before {
- background-color: #F5F5F5;
- border-color: #F5F5F5;
- cursor: not-allowed;
+ background-color: #d3d3d3;
+}
+
+input[type="checkbox"]:disabled+label::after {
+ background-color: #f0f0f0;
+}
+
+input[type="checkbox"]:checked+label::before {
+ background-color: var(--main-color);
}
input[type="checkbox"]:checked+label::after {
- content: '';
- position: absolute;
- left: 8px;
- top: 2px;
- width: 4px;
- height: 12px;
- border: solid var(--main-color);
- border-width: 0 4px 4px 0;
- transform: rotate(45deg);
+ transform: translate(20px, -50%);
+}
+
+input[type="checkbox"]:focus+label::after {
+ outline: 2px solid rgba(var(--main-color-rgb, 100, 149, 237), 0.5);
}
/* Radio */