diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 8b5bd8b56f70..55fc5abbb3fa 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -75,11 +75,11 @@ class PaymentController extends Controller * The request will also contain the amount * and invoice ids for reference. * - * @return void + * @return \Illuminate\Http\RedirectResponse|mixed */ public function process() { - $invoices = Invoice::whereIn('id', $this->transformKeys(explode(",", request()->input('hashed_ids')))) + $invoices = Invoice::whereIn('id', $this->transformKeys(request()->invoices)) ->whereClientId(auth()->user()->client->id) ->get(); @@ -90,7 +90,9 @@ class PaymentController extends Controller }); if ($invoices->count() == 0) { - return back()->with(['warning' => 'No payable invoices selected']); + return redirect() + ->route('client.invoices.index') + ->with(['warning' => 'No payable invoices selected.']); } $invoices->map(function ($invoice) { @@ -99,6 +101,7 @@ class PaymentController extends Controller return $invoice; }); + $payment_methods = auth()->user()->client->getPaymentMethods($amount); //boot the payment gateway diff --git a/resources/js/clients/invoices/payment.js b/resources/js/clients/invoices/payment.js index 432d2ebe6587..40790312507c 100644 --- a/resources/js/clients/invoices/payment.js +++ b/resources/js/clients/invoices/payment.js @@ -16,6 +16,8 @@ class Payment { } handleMethodSelect(element) { + document.getElementById('company_gateway_id').value = element.dataset.companyGatewayId; + document.getElementById('payment_method_id').value = element.dataset.gatewayTypeId; if (this.shouldDisplaySignature && !this.shouldDisplayTerms) { this.displayTerms(); diff --git a/resources/views/portal/ninja2020/invoices/payment.blade.php b/resources/views/portal/ninja2020/invoices/payment.blade.php index dfadb0d74dcd..db6ab3729a58 100644 --- a/resources/views/portal/ninja2020/invoices/payment.blade.php +++ b/resources/views/portal/ninja2020/invoices/payment.blade.php @@ -10,7 +10,9 @@ @section('body')
@csrf - + @foreach($invoices as $invoice) + + @endforeach
@@ -51,7 +53,7 @@ - + @foreach($invoices as $invoice)