1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Create payment after payment and mark invitations as paid

This commit is contained in:
David Bomba 2019-09-25 16:23:51 +10:00
parent 362f197fbb
commit 0687817ae8
5 changed files with 29 additions and 3 deletions

View File

@ -86,8 +86,6 @@ class InvoiceController extends Controller
*/
public function show(ShowInvoiceRequest $request, Invoice $invoice)
{
$data = [
'invoice' => $invoice,
];

View File

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

View File

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

View File

@ -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');