Added payment confirmation email for license purchases

This commit is contained in:
Hillel Coren 2014-10-05 14:55:59 +03:00
parent 051aec19c0
commit a4e949daec
4 changed files with 31 additions and 1 deletions

View File

@ -3,18 +3,20 @@
use ninja\repositories\PaymentRepository; use ninja\repositories\PaymentRepository;
use ninja\repositories\InvoiceRepository; use ninja\repositories\InvoiceRepository;
use ninja\repositories\AccountRepository; use ninja\repositories\AccountRepository;
use ninja\mailers\ContactMailer;
class PaymentController extends \BaseController class PaymentController extends \BaseController
{ {
protected $creditRepo; protected $creditRepo;
public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo) public function __construct(PaymentRepository $paymentRepo, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo, ContactMailer $contactMailer)
{ {
parent::__construct(); parent::__construct();
$this->paymentRepo = $paymentRepo; $this->paymentRepo = $paymentRepo;
$this->invoiceRepo = $invoiceRepo; $this->invoiceRepo = $invoiceRepo;
$this->accountRepo = $accountRepo; $this->accountRepo = $accountRepo;
$this->contactMailer = $contactMailer;
} }
public function index() public function index()
@ -423,6 +425,9 @@ class PaymentController extends \BaseController
'hideHeader' => true '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 View::make('public.license', $data);
//return Redirect::away(Session::get('return_url') . "?license_key={$license->license_key}"); //return Redirect::away(Session::get('return_url') . "?license_key={$license->license_key}");

View File

@ -73,4 +73,21 @@ class ContactMailer extends Mailer {
$user = $payment->invitation->user; $user = $payment->invitation->user;
$this->sendTo($payment->contact->email, $user->email, $user->getDisplayName(), $subject, $view, $data); $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);
}
} }

View File

@ -9,6 +9,10 @@
{{ trans('texts.payment_message', ['amount' => $paymentAmount]) }}<p/> {{ trans('texts.payment_message', ['amount' => $paymentAmount]) }}<p/>
@if (isset($emailMessage) && $emailMessage)
{{ $emailMessage }}<p/>
@endif
@if ($emailFooter) @if ($emailFooter)
{{ nl2br($emailFooter) }} {{ nl2br($emailFooter) }}
@else @else

View File

@ -2,6 +2,10 @@
{{ trans('texts.payment_message', ['amount' => $paymentAmount]) }} {{ trans('texts.payment_message', ['amount' => $paymentAmount]) }}
@if (isset($emailMessage) && $emailMessage)
{{ $emailMessage }}
@endif
@if ($emailFooter) @if ($emailFooter)
{{ $emailFooter }} {{ $emailFooter }}
@else @else