diff --git a/app/Jobs/Mail/PaymentFailedMailer.php b/app/Jobs/Mail/PaymentFailedMailer.php index 5512c4b1a986..9d84a7459502 100644 --- a/app/Jobs/Mail/PaymentFailedMailer.php +++ b/app/Jobs/Mail/PaymentFailedMailer.php @@ -15,6 +15,7 @@ use App\Jobs\Mail\NinjaMailer; use App\Jobs\Mail\NinjaMailerJob; use App\Jobs\Mail\NinjaMailerObject; use App\Libraries\MultiDB; +use App\Mail\Admin\ClientPaymentFailureObject; use App\Mail\Admin\EntityNotificationMailer; use App\Mail\Admin\PaymentFailureObject; use App\Models\Client; @@ -102,6 +103,24 @@ class PaymentFailedMailer implements ShouldQueue }); //add client payment failures here. + nlog("pre client failure email"); + + if($contact = $this->client->primary_contact()->first()) + { + + nlog("inside failure"); + + $mail_obj = (new ClientPaymentFailureObject($this->client, $this->error, $this->company, $this->payment_hash))->build(); + + $nmo = new NinjaMailerObject; + $nmo->mailable = new NinjaMailer($mail_obj); + $nmo->company = $this->company; + $nmo->to_user = $contact; + $nmo->settings = $settings; + + NinjaMailerJob::dispatch($nmo); + } + } diff --git a/app/Mail/Admin/ClientPaymentFailureObject.php b/app/Mail/Admin/ClientPaymentFailureObject.php index c18101b2edae..df13ad8a5049 100644 --- a/app/Mail/Admin/ClientPaymentFailureObject.php +++ b/app/Mail/Admin/ClientPaymentFailureObject.php @@ -14,7 +14,6 @@ namespace App\Mail\Admin; use App\Models\Invoice; use App\Utils\HtmlEngine; use App\Utils\Ninja; -use App\Utils\Number; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\App; use stdClass; @@ -91,7 +90,7 @@ class ClientPaymentFailureObject return ctrans( 'texts.notification_invoice_payment_failed_subject', - ['invoice' => $this->client->present()->name()] + ['invoice' => implode(",", $this->invoices->pluck('number')->toArray())] ); } @@ -110,7 +109,7 @@ class ClientPaymentFailureObject ] ), 'greeting' => ctrans('texts.email_salutation', ['name' => $this->client->present()->name]), - 'message' => $this->error, + 'message' => ctrans('texts.client_payment_failure_body', ['invoice' => implode(",", $this->invoices->pluck('number')->toArray()), 'amount' => $this->getAmount()]), 'signature' => $signature, 'logo' => $this->company->present()->logo(), 'settings' => $this->client->getMergedSettings(), diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 441e7382691c..101c949af91d 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1400,7 +1400,7 @@ $LANG = array( 'more_options' => 'More options', 'credit_card' => 'Credit Card', 'bank_transfer' => 'Bank Transfer', - 'no_transaction_reference' => 'We did not recieve a payment transaction reference from the gateway.', + 'no_transaction_reference' => 'We did not receive a payment transaction reference from the gateway.', 'use_bank_on_file' => 'Use Bank on File', 'auto_bill_email_message' => 'This invoice will automatically be billed to the payment method on file on the due date.', 'bitcoin' => 'Bitcoin', @@ -4334,7 +4334,8 @@ $LANG = array( 'clone_to_expense' => 'Clone to expense', 'checkout' => 'Checkout', 'acss' => 'Pre-authorized debit payments', - 'invalid_amount' => 'Invalid amount. Number/Decimal values only.' + 'invalid_amount' => 'Invalid amount. Number/Decimal values only.', + 'client_payment_failure_body' => 'Payment for Invoice :invoice for amount :amount failed.', ); return $LANG;