From 06233240ce45006ca77f62bdef1de99a28abc6af Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 23 Jun 2024 16:11:13 +1000 Subject: [PATCH] Updates for harvesting fee invoice --- .../Controllers/ClientPortal/PaymentController.php | 13 ++++++++----- app/Listeners/Invoice/UpdateInvoiceActivity.php | 1 + app/Services/ClientPortal/InstantPayment.php | 2 +- app/Services/Payment/RefundPayment.php | 4 ---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 72747bc497c2..7efd13510a56 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -121,12 +121,15 @@ 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(); + $payment_hash = PaymentHash::with('fee_invoice')->where('hash', $request->payment_hash)->firstOrFail(); + + // if($payment_hash) + $invoice = $payment_hash->fee_invoice; + // else + // $invoice = Invoice::with('client')->where('id',$payment_hash->fee_invoice_id)->orderBy('id','desc')->first(); + + // $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; diff --git a/app/Listeners/Invoice/UpdateInvoiceActivity.php b/app/Listeners/Invoice/UpdateInvoiceActivity.php index 1b346b2bbf44..cce12ba40fd9 100644 --- a/app/Listeners/Invoice/UpdateInvoiceActivity.php +++ b/app/Listeners/Invoice/UpdateInvoiceActivity.php @@ -53,5 +53,6 @@ class UpdateInvoiceActivity implements ShouldQueue $fields->invoice_id = $event->invoice->id; $this->activity_repo->save($fields, $event->invoice, $event->event_vars); + } } diff --git a/app/Services/ClientPortal/InstantPayment.php b/app/Services/ClientPortal/InstantPayment.php index aea285866945..d46052fafb03 100644 --- a/app/Services/ClientPortal/InstantPayment.php +++ b/app/Services/ClientPortal/InstantPayment.php @@ -245,7 +245,7 @@ class InstantPayment $hash_data['billing_context'] = Cache::get($this->request->query('hash')); } elseif ($this->request->hash) { $hash_data['billing_context'] = Cache::get($this->request->hash); - } elseif ($old_hash = PaymentHash::query()->where('fee_invoice_id', $first_invoice->id)->whereNull('payment_id')->first()) { + } elseif ($old_hash = PaymentHash::query()->where('fee_invoice_id', $first_invoice->id)->whereNull('payment_id')->orderBy('id','desc')->first()) { if (isset($old_hash->data->billing_context)) { $hash_data['billing_context'] = $old_hash->data->billing_context; } diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index ec2a02d20d47..144abff2068c 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -27,10 +27,6 @@ class RefundPayment private float $credits_used = 0; - private $gateway_refund_status; - - private $activity_repository; - private bool $refund_failed = false; private string $refund_failed_message = '';