From 2c8d3e2013526381c55521992f5c484b713fd31c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 3 Feb 2016 21:06:49 +1100 Subject: [PATCH] Added Payments to API --- app/Http/Controllers/PaymentApiController.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/PaymentApiController.php b/app/Http/Controllers/PaymentApiController.php index 2d4d45fa788c..aacd744d6def 100644 --- a/app/Http/Controllers/PaymentApiController.php +++ b/app/Http/Controllers/PaymentApiController.php @@ -1,5 +1,6 @@ paymentRepo = $paymentRepo; + $this->contactMailer = $contactMailer; + } /** @@ -107,12 +111,20 @@ class PaymentApiController extends BaseAPIController return $error; } - $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')); $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); }