diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index b2b63c0cea9e..72747bc497c2 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -122,7 +122,12 @@ class PaymentController extends Controller /** @var \App\Models\CompanyGateway $gateway **/ $gateway = CompanyGateway::findOrFail($request->input('company_gateway_id')); $payment_hash = PaymentHash::where('hash', $request->payment_hash)->firstOrFail(); - $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); + + if($payment_hash) + $invoice = $payment_hash->fee_invoice; + else + $invoice = Invoice::with('client')->where('id',$payment_hash->fee_invoice_id)->orderBy('id','desc'); + $client = $invoice ? $invoice->client : auth()->guard('contact')->user()->client; // 09-07-2022 catch duplicate responses for invoices that already paid here.