mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added Payments to API
This commit is contained in:
parent
ead2b335d5
commit
2c8d3e2013
@ -1,5 +1,6 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Ninja\Mailers\ContactMailer;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Input;
|
use Input;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -9,16 +10,19 @@ use App\Models\Invoice;
|
|||||||
use App\Ninja\Repositories\PaymentRepository;
|
use App\Ninja\Repositories\PaymentRepository;
|
||||||
use App\Http\Controllers\BaseAPIController;
|
use App\Http\Controllers\BaseAPIController;
|
||||||
use App\Ninja\Transformers\PaymentTransformer;
|
use App\Ninja\Transformers\PaymentTransformer;
|
||||||
|
use App\Ninja\Transformers\InvoiceTransformer;
|
||||||
|
|
||||||
class PaymentApiController extends BaseAPIController
|
class PaymentApiController extends BaseAPIController
|
||||||
{
|
{
|
||||||
protected $paymentRepo;
|
protected $paymentRepo;
|
||||||
|
|
||||||
public function __construct(PaymentRepository $paymentRepo)
|
public function __construct(PaymentRepository $paymentRepo, ContactMailer $contactMailer)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->paymentRepo = $paymentRepo;
|
$this->paymentRepo = $paymentRepo;
|
||||||
|
$this->contactMailer = $contactMailer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,12 +111,20 @@ class PaymentApiController extends BaseAPIController
|
|||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$payment = $this->paymentRepo->save($data);
|
$payment = $this->paymentRepo->save($data);
|
||||||
$payment = Payment::scope($payment->public_id)->with('client', 'contact', 'user', 'invoice')->first();
|
|
||||||
|
|
||||||
|
if (Input::get('email_receipt')) {
|
||||||
|
$this->contactMailer->sendPaymentConfirmation($payment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
$payment = Payment::scope($payment->public_id)->with('client', 'contact', 'user', 'invoice')->first();
|
||||||
$transformer = new PaymentTransformer(Auth::user()->account, Input::get('serializer'));
|
$transformer = new PaymentTransformer(Auth::user()->account, Input::get('serializer'));
|
||||||
$data = $this->createItem($payment, $transformer, 'payment');
|
$data = $this->createItem($payment, $transformer, 'payment');
|
||||||
|
*/
|
||||||
|
$invoice = Invoice::scope($payment->invoice_id)->with('client', 'invoice_items', 'invitations')->first();
|
||||||
|
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||||
|
$data = $this->createItem($invoice, $transformer, 'invoice');
|
||||||
|
|
||||||
return $this->response($data);
|
return $this->response($data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user