Merge pull request #695 from turbo124/master

Payment API Bug Fixes
This commit is contained in:
David Bomba 2016-02-07 20:22:14 +11:00
commit 765a1484f0

View File

@ -2,6 +2,7 @@
use App\Ninja\Mailers\ContactMailer; use App\Ninja\Mailers\ContactMailer;
use Auth; use Auth;
use Illuminate\Support\Facades\Log;
use Input; use Input;
use Utils; use Utils;
use Response; use Response;
@ -90,18 +91,20 @@ class PaymentApiController extends BaseAPIController
{ {
$data = Input::all(); $data = Input::all();
$data['public_id'] = $publicId; $data['public_id'] = $publicId;
$invoice = Invoice::scope($data['invoice_id'])->with('client')->first();
$error = false; $error = false;
$payment = $this->paymentRepo->save($data); $payment = $this->paymentRepo->save($data);
if ($error) { if ($error) {
return $error; return $error;
} }
$invoice = Invoice::scope($payment->invoice_id)->with('client', 'invoice_items', 'invitations')->first(); $invoice = Invoice::scope($invoice->public_id)->with('client', 'invoice_items', 'invitations')->first();
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer')); $transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($invoice, $transformer, 'invoice'); $data = $this->createItem($invoice, $transformer, 'invoice');
return $this->response($data); return $this->response($data);
} }
/** /**
* @SWG\Post( * @SWG\Post(
* path="/payments", * path="/payments",
@ -160,7 +163,10 @@ class PaymentApiController extends BaseAPIController
$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(); $invoice = Invoice::scope($invoice->public_id)->with('client', 'invoice_items', 'invitations')->first();
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer')); $transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($invoice, $transformer, 'invoice'); $data = $this->createItem($invoice, $transformer, 'invoice');