From 0687817ae8743cc466df75239bdf29316e4fe164 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 25 Sep 2019 16:23:51 +1000 Subject: [PATCH] Create payment after payment and mark invitations as paid --- .../ClientPortal/InvoiceController.php | 2 -- .../ClientPortal/PaymentController.php | 7 +++++- app/PaymentDrivers/StripePaymentDriver.php | 22 +++++++++++++++++++ .../portal/default/payments/show.blade.php | 0 routes/client.php | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 resources/views/portal/default/payments/show.blade.php diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index ac18c8ccbc4f..c34ec5d21492 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -86,8 +86,6 @@ class InvoiceController extends Controller */ public function show(ShowInvoiceRequest $request, Invoice $invoice) { - - $data = [ 'invoice' => $invoice, ]; diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 94c18469a8b3..88e740d80369 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -76,9 +76,14 @@ class PaymentController extends Controller * * @return \Illuminate\Http\Response */ - public function show(RecurringInvoice $invoice) + public function show(Request $request, Payment $payment) { + $payment->load('invoices'); + $data['payment'] = $payment; + + print_r($payment->toArray()); + //return view('portal.default.payments.show', $data); } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 083dbeb564ca..466c1f824289 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -359,6 +359,28 @@ class StripePaymentDriver extends BasePaymentDriver $payment->invoices()->sync($invoices); $payment->save(); + +//mark all invoices as paid +//$invoices->update(['status_id' => Payment::STATUS_COMPLETED]); + + // foreach($invoices as $invoice){ + // \Log::error('invite count = '.$invoices->invitations->count()); + // foreach($invoice->invitations as $invitation) + // { + // \Log::error($invitation); + // $invitations->update(['transaction_reference' => $payment->transaction_reference]); + // } + // } + +//mark all invitations with transaction reference +$invoices->each(function ($invoice) use($payment) { + + $invoice->update(['status_id' => Payment::STATUS_COMPLETED]); + $invoice->invitations()->update(['transaction_reference' => $payment->transaction_reference]); + +}); + return redirect()->route('client.payments.show', ['id' => $this->encodePrimaryKey($payment->id)]); + } } diff --git a/resources/views/portal/default/payments/show.blade.php b/resources/views/portal/default/payments/show.blade.php new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/routes/client.php b/routes/client.php index c8028fdf3600..b9ac33d9ffcf 100644 --- a/routes/client.php +++ b/routes/client.php @@ -24,6 +24,7 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index'); Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index'); + Route::get('payments/{payment}', 'ClientPortal\PaymentController@show')->name('payments.show'); Route::post('payments/process', 'ClientPortal\PaymentController@process')->name('payments.process'); Route::post('payments/process/response', 'ClientPortal\PaymentController@response')->name('payments.response');