diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index da6327963b07..1bf0f3c15ac7 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -3,18 +3,20 @@ use ninja\repositories\PaymentRepository; use ninja\repositories\InvoiceRepository; use ninja\repositories\AccountRepository; +use ninja\mailers\ContactMailer; class PaymentController extends \BaseController { protected $creditRepo; - public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo) + public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo, ContactMailer $contactMailer) { parent::__construct(); $this->paymentRepo = $paymentRepo; $this->invoiceRepo = $invoiceRepo; $this->accountRepo = $accountRepo; + $this->contactMailer = $contactMailer; } public function index() @@ -423,6 +425,9 @@ class PaymentController extends \BaseController 'hideHeader' => true ]; + $name = "{$license->first_name} {$license->last_name}"; + $this->contactMailer->sendLicensePaymentConfirmation($name, $license->email, LICENSE_PRICE, $license->license_key); + return View::make('public.license', $data); //return Redirect::away(Session::get('return_url') . "?license_key={$license->license_key}"); diff --git a/app/ninja/mailers/ContactMailer.php b/app/ninja/mailers/ContactMailer.php index 6dc1369e888e..271edef7adb6 100755 --- a/app/ninja/mailers/ContactMailer.php +++ b/app/ninja/mailers/ContactMailer.php @@ -73,4 +73,21 @@ class ContactMailer extends Mailer { $user = $payment->invitation->user; $this->sendTo($payment->contact->email, $user->email, $user->getDisplayName(), $subject, $view, $data); } + + public function sendLicensePaymentConfirmation($name, $email, $amount, $license) + { + $view = 'payment_confirmation'; + $subject = trans('texts.payment_subject'); + + $data = [ + 'accountName' => trans('texts.email_from'), + 'clientName' => $name, + 'emailFooter' => false, + 'paymentAmount' => Utils::formatMoney($amount, 1), + 'showNinjaFooter' => false, + 'emailMessage' => "Your license: $license", + ]; + + $this->sendTo($email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); + } } \ No newline at end of file diff --git a/app/views/emails/payment_confirmation_html.blade.php b/app/views/emails/payment_confirmation_html.blade.php index c1dffbac19a0..115478c45e56 100644 --- a/app/views/emails/payment_confirmation_html.blade.php +++ b/app/views/emails/payment_confirmation_html.blade.php @@ -9,6 +9,10 @@ {{ trans('texts.payment_message', ['amount' => $paymentAmount]) }}

+ @if (isset($emailMessage) && $emailMessage) + {{ $emailMessage }}

+ @endif + @if ($emailFooter) {{ nl2br($emailFooter) }} @else diff --git a/app/views/emails/payment_confirmation_text.blade.php b/app/views/emails/payment_confirmation_text.blade.php index 0d2b7a1c5438..15f94c3b8bf9 100644 --- a/app/views/emails/payment_confirmation_text.blade.php +++ b/app/views/emails/payment_confirmation_text.blade.php @@ -2,6 +2,10 @@ {{ trans('texts.payment_message', ['amount' => $paymentAmount]) }} +@if (isset($emailMessage) && $emailMessage) +{{ $emailMessage }} +@endif + @if ($emailFooter) {{ $emailFooter }} @else