From cdb65a8a958f1b39091b7084671a5b1b8369ca3d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 4 May 2024 10:28:59 +1000 Subject: [PATCH] FDS Reviews --- app/PaymentDrivers/Authorize/FDSReview.php | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/PaymentDrivers/Authorize/FDSReview.php b/app/PaymentDrivers/Authorize/FDSReview.php index 05b9c8851da1..bf35b4201715 100644 --- a/app/PaymentDrivers/Authorize/FDSReview.php +++ b/app/PaymentDrivers/Authorize/FDSReview.php @@ -11,9 +11,13 @@ namespace App\PaymentDrivers\Authorize; +use App\Libraries\MultiDB; use App\Models\PaymentHash; +use App\Services\Email\Email; use Illuminate\Bus\Queueable; +use App\Services\Email\EmailObject; use Illuminate\Support\Facades\App; +use Symfony\Component\Mime\Address; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; @@ -37,5 +41,30 @@ class FDSReview implements ShouldQueue public function handle() { + + MultiDB::setDB($this->db); + + $company = $this->payment_hash->fee_invoice->company; + + App::setLocale($company->getLocale()); + + $invoices_string = \implode(', ', collect($this->payment_hash->invoices())->pluck('invoice_number')->toArray()) ?: ''; + + $body = "Transaction {$this->transaction_reference} has been held for your review in Auth.net based on your Fraud Detection Settings.\n We have marked invoices {$invoices_string} as paid in Invoice Ninja.\n Please review these transaction in your auth.net account, and authorize them if they are correct to ensure the transactions are processed as expected. If these charges need to be cancelled, you will need to delete the payments that have been created in Invoice Ninja to reverse those payments."; + + $mo = new EmailObject(); + $mo->subject = "Transaction {$this->transaction_reference} held for review by auth.net"; + $mo->body = $body; + $mo->text_body = $body; + $mo->company_key = $company->company_key; + $mo->html_template = 'email.template.generic'; + $mo->to = [new Address($company->owner()->email, $company->owner()->present()->name())]; + // $mo->email_template_body = 'nordigen_requisition_body'; + // $mo->email_template_subject = 'nordigen_requisition_subject'; + + Email::dispatch($mo, $company); + + } + }