diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index 3a1172a765..b4d3de7753 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -110,6 +110,13 @@ class PaymentNotification implements ShouldQueue if (($key = array_search('mail', $methods)) !== false) { unset($methods[$key]); + //new check, IF the payment is on a recurring invoice AND the user had notifications disabled for recurring invoices. then we disable the notification for this payment. + $disabled_recurring_invoice_notifications = $this->findUserEntityNotificationType($payment, $company_user,['disable_recurring_payment_notification']); + + if ($payment->invoices->first()->recurring_id && (array_search('mail', $disabled_recurring_invoice_notifications) !== false)) { + continue; + } + $nmo = new NinjaMailerObject(); $nmo->mailable = new NinjaMailer((new EntityPaidObject($payment, $company_user->portalType()))->build()); $nmo->company = $event->company; diff --git a/lang/en/texts.php b/lang/en/texts.php index 9624a18aa4..d4c2059496 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5591,6 +5591,8 @@ $lang = array( 'docuninja_disable_warning' => 'This will remove all access to your DocuNinja account.', 'docuninja_downgrade_info' => 'Your user limit will automatically be reduced at the end of the current billing cycle.', 'recurring_invoice_item' => 'Recurring Invoice Item', + 'disable_recurring_payment_notification' => 'Disable Recurring Payment Notification', + 'disable_recurring_payment_notification_help' => 'Successful recurring invoice payment notifications will not be sent.', ); return $lang;