invoice Mail, weitere Punkte
This commit is contained in:
parent
02e78e7255
commit
39ef16686a
10 changed files with 299 additions and 6 deletions
|
|
@ -76,7 +76,7 @@ class PayController extends Controller
|
|||
//make Payone payment
|
||||
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
|
||||
|
||||
$this->reference = substr(uniqid('m', false), 0, 16);
|
||||
$this->reference = $this->shopping_order->created_at->format('Ym').$this->shopping_order->id;//substr(uniqid('m', false), 0, 16);
|
||||
$this->setMethod($payment_method, $ret);
|
||||
|
||||
$this->prepayment = [
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ class CheckoutController extends Controller
|
|||
$ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)->where('reference', $reference)->first();
|
||||
if(!$ShoppingPayment){
|
||||
//TODO log this
|
||||
Util::setUserHistoryValue(['status'=>21]);
|
||||
Util::setUserHistoryValue(['status'=>21], $reference);
|
||||
|
||||
\Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference);
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
|
|
@ -363,13 +363,13 @@ class CheckoutController extends Controller
|
|||
return view('web.templates.checkout-final', $data);
|
||||
}
|
||||
if($status === "cancel"){
|
||||
Util::setUserHistoryValue(['status'=>22]);
|
||||
Util::setUserHistoryValue(['status'=>22], $reference);
|
||||
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
|
||||
}
|
||||
if($status === "error"){
|
||||
Util::setUserHistoryValue(['status'=>23]);
|
||||
Util::setUserHistoryValue(['status'=>23], $reference);
|
||||
\Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
|
||||
|
|
|
|||
50
app/Mail/MailInvoice.php
Normal file
50
app/Mail/MailInvoice.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use App\Services\Invoice;
|
||||
use App\Models\ShoppingOrder;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Storage;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailInvoice extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $shopping_order;
|
||||
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct(ShoppingOrder $shopping_order)
|
||||
{
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->subject = 'Rechnung zu Deiner Bestellung: '.$shopping_order->getLastShoppingPayment('reference') ;
|
||||
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$title = __('email.invoice_title');
|
||||
$copy1line = __('email.invoice_copy1line').$this->shopping_order->getLastShoppingPayment('reference');
|
||||
|
||||
$filename = Invoice::getFilename($this->shopping_order);
|
||||
$path = Invoice::getDownloadPath($this->shopping_order);
|
||||
if (!Storage::disk('public')->exists($path)) {
|
||||
return;
|
||||
}
|
||||
$file = Storage::disk('public')->path($path);
|
||||
$mime = Storage::disk('public')->mimeType($path);
|
||||
|
||||
return $this->view('emails.blank')->with([
|
||||
'title' => $title,
|
||||
'copy1line' => $copy1line,
|
||||
])->attach($file,[
|
||||
'as' => $filename,
|
||||
'mime' => $mime,
|
||||
]); // attach file;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ class InvoiceRepository extends BaseRepository {
|
|||
$invoice_number = isset($request['invoice_number']) ? $request['invoice_number'] : Invoice::getInvoiceNumber();
|
||||
$invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y");
|
||||
|
||||
$invoice_send_mail = isset($request['invoice_send_mail']) ? true: false;
|
||||
$invoice_number = Invoice::createInvoiceNumber($invoice_number, $invoice_date);
|
||||
|
||||
$data = [
|
||||
|
|
@ -55,6 +56,11 @@ class InvoiceRepository extends BaseRepository {
|
|||
];
|
||||
$this->model->invoice = $data_file;
|
||||
$this->model->save();
|
||||
|
||||
if($invoice_send_mail){
|
||||
Invoice::sendInvoiceMail($this->model);
|
||||
}
|
||||
|
||||
Invoice::makeNextInvoiceNumber();
|
||||
return true;
|
||||
//return $pdf->stream('invoice.pdf');
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Mail\MailInvoice;
|
||||
use App\Services\Util;
|
||||
use App\Models\Setting;
|
||||
use App\Models\ShoppingOrder;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class Invoice
|
||||
{
|
||||
|
|
@ -57,4 +59,22 @@ class Invoice
|
|||
}
|
||||
return \Storage::disk('public')->path($dir.$filename);
|
||||
}
|
||||
|
||||
public static function sendInvoiceMail($shopping_order){
|
||||
$bcc = [];
|
||||
$billing_email = $shopping_order->shopping_user->billing_email;
|
||||
if(!$billing_email){
|
||||
if($shopping_order->mode === 'test'){
|
||||
$billing_email = config('app.checkout_test_mail');
|
||||
}else{
|
||||
$billing_email = config('app.checkout_mail');
|
||||
}
|
||||
}
|
||||
if($shopping_order->mode === 'test'){
|
||||
$bcc[] = config('app.checkout_test_mail');
|
||||
}else{
|
||||
$bcc[] = config('app.checkout_mail');
|
||||
}
|
||||
Mail::to($billing_email)->bcc($bcc)->send(new MailInvoice($shopping_order));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue