diff --git a/guest/guest_pay_invoice_stripe.php b/guest/guest_pay_invoice_stripe.php
index c9ca5478..2b3065bb 100644
--- a/guest/guest_pay_invoice_stripe.php
+++ b/guest/guest_pay_invoice_stripe.php
@@ -279,7 +279,7 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
// Add Payment to History
mysqli_query($mysqli, "INSERT INTO payments SET payment_date = '$pi_date', payment_amount = $pi_amount_paid, payment_currency_code = '$pi_currency', payment_account_id = $config_stripe_account, payment_method = 'Stripe', payment_reference = 'Stripe - $pi_id', payment_invoice_id = $invoice_id");
- mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Paid', history_description = 'Payment added - $ip - $os - $browser', history_invoice_id = $invoice_id");
+ mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Paid', history_description = 'Online Payment added (client) - $ip - $os - $browser', history_invoice_id = $invoice_id");
// Notify
appNotify("Invoice Paid", "Invoice $invoice_prefix$invoice_number has been paid by $client_name - $ip - $os - $browser", "invoice.php?invoice_id=$invoice_id", $pi_client_id);
@@ -313,7 +313,7 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
if (!empty($config_smtp_host)) {
$subject = "Payment Received - Invoice $invoice_prefix$invoice_number";
- $body = "Hello $contact_name,
We have received your payment in the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, '0', $invoice_currency_code) . "
Thank you for your business!
~
$company_name - Billing
$config_invoice_from_email
$company_phone";
+ $body = "Hello $contact_name,
We have received online payment for the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Thank you for your business!
~
$company_name - Billing
$config_invoice_from_email
$company_phone";
$data = [
[
@@ -330,7 +330,7 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
// Email the internal notification address too
if (!empty($config_invoice_paid_notification_email)) {
$subject = "Payment Received - $client_name - Invoice $invoice_prefix$invoice_number";
- $body = "Hello,
This is a notification that an invoice has been paid in ITFlow. Below is a copy of the receipt sent to the client:-
--------
Hello $contact_name,
We have received your payment in the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Balance: " . numfmt_format_currency($currency_format, '0', $invoice_currency_code) . "
Thank you for your business!
~
$company_name - Billing
$config_invoice_from_email
$company_phone";
+ $body = "Hello,
This is a notification that an invoice has been paid in ITFlow. Below is a copy of the receipt sent to the client:-
--------
Hello $contact_name,
We have received online payment for the amount of " . $pi_currency . $pi_amount_paid . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount: " . numfmt_format_currency($currency_format, $pi_amount_paid, $invoice_currency_code) . "
Thank you for your business!
~
$company_name - Billing
$config_invoice_from_email
$company_phone";
$data[] = [
'from' => $config_invoice_from_email,
diff --git a/invoice.php b/invoice.php
index 3736f6fd..ed41c9c9 100644
--- a/invoice.php
+++ b/invoice.php
@@ -141,6 +141,17 @@ if (isset($_GET['invoice_id'])) {
$json_products = json_encode($products);
}
+ // Payment with saved card (auto-pay)
+ if ($config_stripe_enable) {
+ $stripe_client_details = mysqli_fetch_array(mysqli_query($mysqli, "SELECT * FROM client_stripe WHERE client_id = $client_id LIMIT 1"));
+ if ($stripe_client_details) {
+ $stripe_id = sanitizeInput($stripe_client_details['stripe_id']);
+ $stripe_pm = sanitizeInput($stripe_client_details['stripe_pm']);
+ }
+ }
+
+
+
?>
@@ -193,6 +204,11 @@ if (isset($_GET['invoice_id'])) {
Add Payment
+
+
+ Pay via saved card
+
+
diff --git a/portal/portal_post.php b/portal/portal_post.php
index 53dda1b6..16d670b2 100644
--- a/portal/portal_post.php
+++ b/portal/portal_post.php
@@ -512,7 +512,7 @@ if (isset($_GET['create_stripe_checkout'])) {
$stripe = new \Stripe\StripeClient($config_stripe_secret);
// Define return URL that user is redirected to once payment method is verified by Stripe
- $return_url = "$config_base_url/portal/portal_post.php?stripe_save_card&session_id={CHECKOUT_SESSION_ID}";
+ $return_url = "https://$config_base_url/portal/portal_post.php?stripe_save_card&session_id={CHECKOUT_SESSION_ID}";
// Create checkout session (server side)
$checkout_session = $stripe->checkout->sessions->create([
diff --git a/post/user/invoice.php b/post/user/invoice.php
index 847a096b..64c9a3f8 100644
--- a/post/user/invoice.php
+++ b/post/user/invoice.php
@@ -815,14 +815,17 @@ if (isset($_POST['add_payment'])) {
$email_data[] = $email;
+ // Add email to queue
+ if (!empty($email)) {
+ addToMailQueue($mysqli, $email_data);
+ }
+
// Get Email ID for reference
$email_id = mysqli_insert_id($mysqli);
// Email Logging
-
- $_SESSION['alert_message'] = "Email queued successfully! Check Admin > Mail queue";
-
- mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Email Receipt Queued', history_invoice_id = $invoice_id");
+ mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Payment Receipt sent to mail queue ID: $email_id!', history_invoice_id = $invoice_id");
+ logAction("Invoice", "Payment", "Payment receipt for invoice $invoice_prefix$invoice_number queued to $contact_email Email ID: $email_id", $client_id, $invoice_id);
}
@@ -847,26 +850,22 @@ if (isset($_POST['add_payment'])) {
$email_data[] = $email;
+ // Add email to queue
+ if (!empty($email)) {
+ addToMailQueue($mysqli, $email_data);
+ }
+
// Get Email ID for reference
$email_id = mysqli_insert_id($mysqli);
// Email Logging
-
- $_SESSION['alert_message'] = "Test email queued successfully! Check Admin > Mail queue";
-
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Payment Receipt sent to mail queue ID: $email_id!', history_invoice_id = $invoice_id");
-
logAction("Invoice", "Payment", "Payment receipt for invoice $invoice_prefix$invoice_number queued to $contact_email Email ID: $email_id", $client_id, $invoice_id);
}
}
- // Add emails to queue
- if (!empty($email)) {
- addToMailQueue($mysqli, $email_data);
- }
-
//Update Invoice Status
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = '$invoice_status' WHERE invoice_id = $invoice_id");
@@ -884,6 +883,192 @@ if (isset($_POST['add_payment'])) {
}
}
+if (isset($_GET['add_payment_stripe'])) {
+
+ enforceUserPermission('module_sales', 2);
+ validateCSRFToken($_GET['csrf_token']);
+
+ $invoice_id = intval($_GET['invoice_id']);
+
+ // Get invoice details
+ $sql = mysqli_query($mysqli,"SELECT * FROM invoices
+ LEFT JOIN clients ON invoice_client_id = client_id
+ LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
+ WHERE invoice_id = $invoice_id"
+ );
+ $row = mysqli_fetch_array($sql);
+ $invoice_number = intval($row['invoice_number']);
+ $invoice_status = sanitizeInput($row['invoice_status']);
+ $invoice_amount = floatval($row['invoice_amount']);
+ $invoice_prefix = sanitizeInput($row['invoice_prefix']);
+ $invoice_number = intval($row['invoice_number']);
+ $invoice_url_key = sanitizeInput($row['invoice_url_key']);
+ $invoice_currency_code = sanitizeInput($row['invoice_currency_code']);
+ $client_id = intval($row['client_id']);
+ $client_name = sanitizeInput($row['client_name']);
+ $contact_name = sanitizeInput($row['contact_name']);
+ $contact_email = sanitizeInput($row['contact_email']);
+ $contact_phone = sanitizeInput(formatPhoneNumber($row['contact_phone']));
+ $contact_extension = preg_replace("/[^0-9]/", '',$row['contact_extension']);
+ $contact_mobile = sanitizeInput(formatPhoneNumber($row['contact_mobile']));
+
+ // Get ITFlow company details
+ $sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1");
+ $row = mysqli_fetch_array($sql);
+ $company_name = sanitizeInput($row['company_name']);
+ $company_country = sanitizeInput($row['company_country']);
+ $company_address = sanitizeInput($row['company_address']);
+ $company_city = sanitizeInput($row['company_city']);
+ $company_state = sanitizeInput($row['company_state']);
+ $company_zip = sanitizeInput($row['company_zip']);
+ $company_phone = sanitizeInput(formatPhoneNumber($row['company_phone']));
+ $company_email = sanitizeInput($row['company_email']);
+ $company_website = sanitizeInput($row['company_website']);
+
+ // Sanitize Config vars from get_settings.php
+ $config_invoice_from_name = sanitizeInput($config_invoice_from_name);
+ $config_invoice_from_email = sanitizeInput($config_invoice_from_email);
+
+ // Get Client Stripe details
+ $stripe_client_details = mysqli_fetch_array(mysqli_query($mysqli, "SELECT * FROM client_stripe WHERE client_id = $client_id LIMIT 1"));
+ $stripe_id = sanitizeInput($stripe_client_details['stripe_id']);
+ $stripe_pm = sanitizeInput($stripe_client_details['stripe_pm']);
+
+ // Sanity checks
+ if (!$config_stripe_enable || !$stripe_id || !$stripe_pm) {
+ $_SESSION['alert_type'] = "error";
+ $_SESSION['alert_message'] = "Stripe not enabled or no client card saved";
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+ exit();
+ } elseif ($invoice_status !== 'Sent' && $invoice_status !== 'Viewed') {
+ $_SESSION['alert_type'] = "error";
+ $_SESSION['alert_message'] = "Invalid invoice state (draft/partial/paid/not billable)";
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+ exit();
+ } elseif ($invoice_amount == 0) {
+ $_SESSION['alert_type'] = "error";
+ $_SESSION['alert_message'] = "Invalid invoice amount";
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+ exit();
+ }
+
+ // Initialize Stripe
+ require_once __DIR__ . '/../../vendor/stripe-php-10.5.0/init.php';
+ $stripe = new \Stripe\StripeClient($config_stripe_secret);
+
+ $balance_to_pay = round($invoice_amount, 2);
+ $pi_description = "ITFlow: $client_name payment of $invoice_currency_code $balance_to_pay for $invoice_prefix$invoice_number";
+
+ // Create a payment intent
+ try {
+ $payment_intent = $stripe->paymentIntents->create([
+ 'amount' => intval($balance_to_pay * 100), // Times by 100 as Stripe expects values in cents
+ 'currency' => $invoice_currency_code,
+ 'customer' => $stripe_id,
+ 'payment_method' => $stripe_pm,
+ 'off_session' => true,
+ 'confirm' => true,
+ 'description' => $pi_description,
+ 'metadata' => [
+ 'itflow_client_id' => $client_id,
+ 'itflow_client_name' => $client_name,
+ 'itflow_invoice_number' => $invoice_prefix . $invoice_number,
+ 'itflow_invoice_id' => $invoice_id,
+ ]
+ ]);
+
+ // Get details from PI
+ $pi_id = sanitizeInput($payment_intent->id);
+ $pi_date = date('Y-m-d', $payment_intent->created);
+ $pi_amount_paid = floatval(($payment_intent->amount_received / 100));
+ $pi_currency = strtoupper(sanitizeInput($payment_intent->currency));
+ $pi_livemode = $payment_intent->livemode;
+
+ } catch (Exception $e) {
+ error_log("Stripe payment error - encountered exception during payment intent for invoice ID $invoice_id / $invoice_prefix$invoice_number:-");
+ error_log($e->getMessage());
+ }
+
+ if ($payment_intent->status == "succeeded" && intval($balance_to_pay) == intval($pi_amount_paid)) {
+
+ // Update Invoice Status
+ mysqli_query($mysqli, "UPDATE invoices SET invoice_status = 'Paid' WHERE invoice_id = $invoice_id");
+
+ // Add Payment to History
+ mysqli_query($mysqli, "INSERT INTO payments SET payment_date = '$pi_date', payment_amount = $pi_amount_paid, payment_currency_code = '$pi_currency', payment_account_id = $config_stripe_account, payment_method = 'Stripe', payment_reference = 'Stripe - $pi_id', payment_invoice_id = $invoice_id");
+ mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Paid', history_description = 'Online Payment added (agent)', history_invoice_id = $invoice_id");
+
+ // Email receipt
+ if (!empty($config_smtp_host)) {
+ $subject = "Payment Received - Invoice $invoice_prefix$invoice_number";
+ $body = "Hello $contact_name,
We have received online payment for the amount of " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount Paid: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Thank you for your business!
--
$company_name - Billing Department
$config_invoice_from_email
$company_phone";
+
+ // Queue Mail
+ $data = [
+ [
+ 'from' => $config_invoice_from_email,
+ 'from_name' => $config_invoice_from_name,
+ 'recipient' => $contact_email,
+ 'recipient_name' => $contact_name,
+ 'subject' => $subject,
+ 'body' => $body,
+ ]
+ ];
+
+ // Email the internal notification address too
+ if (!empty($config_invoice_paid_notification_email)) {
+ $subject = "Payment Received - $client_name - Invoice $invoice_prefix$invoice_number";
+ $body = "Hello,
This is a notification that an invoice has been paid in ITFlow. Below is a copy of the receipt sent to the client:-
--------
Hello $contact_name,
We have received online payment for the amount of " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount Paid: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Thank you for your business!
--
$company_name - Billing Department
$config_invoice_from_email
$company_phone";
+
+ $data[] = [
+ 'from' => $config_invoice_from_email,
+ 'from_name' => $config_invoice_from_name,
+ 'recipient' => $config_invoice_paid_notification_email,
+ 'recipient_name' => $contact_name,
+ 'subject' => $subject,
+ 'body' => $body,
+ ];
+ }
+
+ $mail = addToMailQueue($mysqli, $data);
+
+ // Email Logging
+ $email_id = mysqli_insert_id($mysqli);
+ mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Payment Receipt sent to mail queue ID: $email_id!', history_invoice_id = $invoice_id");
+ logAction("Invoice", "Payment", "Payment receipt for invoice $invoice_prefix$invoice_number queued to $contact_email Email ID: $email_id", $client_id, $invoice_id);
+ }
+
+ // Log info
+ $extended_log_desc = '';
+ if (!$pi_livemode) {
+ $extended_log_desc = '(DEV MODE)';
+ }
+
+ // Create Stripe payment gateway fee as an expense (if configured)
+ if ($config_stripe_expense_vendor > 0 && $config_stripe_expense_category > 0) {
+ $gateway_fee = round($invoice_amount * $config_stripe_percentage_fee + $config_stripe_flat_fee, 2);
+ mysqli_query($mysqli,"INSERT INTO expenses SET expense_date = '$pi_date', expense_amount = $gateway_fee, expense_currency_code = '$invoice_currency_code', expense_account_id = $config_stripe_account, expense_vendor_id = $config_stripe_expense_vendor, expense_client_id = $client_id, expense_category_id = $config_stripe_expense_category, expense_description = 'Stripe Transaction for Invoice $invoice_prefix$invoice_number In the Amount of $balance_to_pay', expense_reference = 'Stripe - $pi_id $extended_log_desc'");
+ }
+
+ // Notify/log
+ appNotify("Invoice Paid", "Invoice $invoice_prefix$invoice_number automatically paid", "invoice.php?invoice_id=$invoice_id", $client_id);
+ logAction("Invoice", "Payment", "$session_name initiated Stripe payment amount of " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . " added to invoice $invoice_prefix$invoice_number - $pi_id $extended_log_desc", $client_id, $invoice_id);
+ customAction('invoice_pay', $invoice_id);
+
+ $_SESSION['alert_message'] .= "Payment amount " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . " added";
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+
+ } else {
+ mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Payment failed', history_description = 'Stripe pay failed due to payment error', history_invoice_id = $invoice_id");
+ logAction("Invoice", "Payment", "Failed online payment amount of invoice $invoice_prefix$invoice_number due to Stripe payment error", $client_id, $invoice_id);
+ $_SESSION['alert_type'] = "error";
+ $_SESSION['alert_message'] = "Payment failed";
+ header("Location: " . $_SERVER["HTTP_REFERER"]);
+ exit();
+ }
+
+}
+
if (isset($_POST['add_bulk_payment'])) {
$client_id = intval($_POST['client_id']);
diff --git a/scripts/cron.php b/scripts/cron.php
index f5aba6b6..89ed505f 100644
--- a/scripts/cron.php
+++ b/scripts/cron.php
@@ -489,7 +489,7 @@ if ($config_send_invoice_reminders == 1) {
$subject = "Overdue Invoice $invoice_prefix$invoice_number";
$body = "Hello $contact_name,
Our records indicate that we have not yet received payment for the invoice $invoice_prefix$invoice_number. We kindly request that you submit your payment as soon as possible. If you have any questions or concerns, please do not hesitate to contact us at $company_email or $company_phone.
- Kindly review the invoice details mentioned below.
Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Due Date: $invoice_due
Over Due By: $day Days
To view your invoice, please click here.
--
$company_name - Billing
$config_invoice_from_email
$company_phone";
+ Kindly review the invoice details mentioned below.
Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $invoice_currency_code) . "
Due Date: $invoice_due
Over Due By: $day Days
To view your invoice, please click here.
--
$company_name - Billing
$config_invoice_from_email
$company_phone";
$mail = addToMailQueue($mysqli, [
[
@@ -622,7 +622,7 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
if ($config_recurring_auto_send_invoice == 1 && $recurring_invoice_email_notify == 1) {
$subject = "Invoice $invoice_prefix$invoice_number";
- $body = "Hello $contact_name,
An invoice regarding \"$invoice_scope\" has been generated. Please view the details below.
Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_currency_code) . "
Due Date: $invoice_due
To view your invoice, please click here.
--
$company_name - Billing
$config_invoice_from_email
$company_phone";
+ $body = "Hello $contact_name,
An invoice regarding \"$invoice_scope\" has been generated. Please view the details below.
Invoice: $invoice_prefix$invoice_number
Issue Date: $invoice_date
Total: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_currency_code) . "
Due Date: $invoice_due
To view your invoice, please click here.
--
$company_name - Billing
$config_invoice_from_email
$company_phone";
$mail = addToMailQueue($mysqli, [
[
@@ -734,9 +734,47 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
// Add Payment to History
mysqli_query($mysqli, "INSERT INTO payments SET payment_date = '$pi_date', payment_amount = $pi_amount_paid, payment_currency_code = '$pi_currency', payment_account_id = $recurring_payment_account_id, payment_method = 'Stripe', payment_reference = 'Stripe - $pi_id', payment_invoice_id = $new_invoice_id");
- mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Paid', history_description = 'Payment automatically added', history_invoice_id = $new_invoice_id");
+ mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Paid', history_description = 'Online Payment added (autopay)', history_invoice_id = $new_invoice_id");
- //TODO: Email receipt
+ // Email receipt
+ if (!empty($config_smtp_host)) {
+ $subject = "Payment Received - Invoice $invoice_prefix$invoice_number";
+ $body = "Hello $contact_name,
We have received online payment for the amount of " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_payment_currency_code) . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount Paid: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_payment_currency_code) . "
Thank you for your business!
--
$company_name - Billing Department
$config_invoice_from_email
$company_phone";
+
+ // Queue Mail
+ $data = [
+ [
+ 'from' => $config_invoice_from_email,
+ 'from_name' => $config_invoice_from_name,
+ 'recipient' => $contact_email,
+ 'recipient_name' => $contact_name,
+ 'subject' => $subject,
+ 'body' => $body,
+ ]
+ ];
+
+ // Email the internal notification address too
+ if (!empty($config_invoice_paid_notification_email)) {
+ $subject = "Payment Received - $client_name - Invoice $invoice_prefix$invoice_number";
+ $body = "Hello,
This is a notification that an invoice has been paid in ITFlow. Below is a copy of the receipt sent to the client:-
--------
Hello $contact_name,
We have received online payment for the amount of " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_payment_currency_code) . " for invoice $invoice_prefix$invoice_number. Please keep this email as a receipt for your records.
Amount Paid: " . numfmt_format_currency($currency_format, $invoice_amount, $recurring_payment_currency_code) . "
Thank you for your business!
--
$company_name - Billing Department
$config_invoice_from_email
$company_phone";
+
+ $data[] = [
+ 'from' => $config_invoice_from_email,
+ 'from_name' => $config_invoice_from_name,
+ 'recipient' => $config_invoice_paid_notification_email,
+ 'recipient_name' => $contact_name,
+ 'subject' => $subject,
+ 'body' => $body,
+ ];
+ }
+
+ $mail = addToMailQueue($mysqli, $data);
+
+ // Email Logging
+ $email_id = mysqli_insert_id($mysqli);
+ mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Payment Receipt sent to mail queue ID: $email_id!', history_invoice_id = $new_invoice_id");
+ logAction("Invoice", "Payment", "Payment receipt for invoice $invoice_prefix$invoice_number queued to $contact_email Email ID: $email_id", $client_id, $new_invoice_id);
+ }
// Log info
$extended_log_desc = '';
@@ -767,6 +805,8 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
} else {
// Else: Cash/Bank payment
+ //TODO: Should we send a receipt for auto bank payments, even when nobody actually confirms receipt?
+
mysqli_query($mysqli,"INSERT INTO payments SET payment_date = CURDATE(), payment_amount = $recurring_amount, payment_currency_code = '$recurring_payment_currency_code', payment_account_id = $recurring_payment_account_id, payment_method = '$recurring_payment_method', payment_reference = 'Paid via AutoPay', payment_invoice_id = $new_invoice_id");
// Get Payment ID for reference