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); }