From d05b41e4520059e4f65d15493882625c75c6638c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 29 Apr 2023 11:10:52 +1000 Subject: [PATCH] Add UTM to billing portal purchase --- app/Http/Livewire/BillingPortalPurchase.php | 3 +++ app/PaymentDrivers/BaseDriver.php | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 89931982db93..75b74cf28dde 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -405,6 +405,8 @@ class BillingPortalPurchase extends Component $context = 'whitelabel'; } + $utm = isset($this->request_data['utm']) ? $this->request_data['utm'] : null; + Cache::put($this->hash, [ 'subscription_id' => $this->subscription->hashed_id, 'email' => $this->email ?? $this->contact->email, @@ -412,6 +414,7 @@ class BillingPortalPurchase extends Component 'invoice_id' => $this->invoice->hashed_id, 'context' => $context, 'campaign' => $this->campaign, + 'utm' => $utm, ], now()->addMinutes(60)); $this->emit('beforePaymentEventsCompleted'); diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 5d40f1c143c1..4ac61df44875 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -381,7 +381,6 @@ class BaseDriver extends AbstractPaymentDriver * When a successful payment is made, we need to append the gateway fee * to an invoice. * - * @param PaymentResponseRequest $request The incoming payment request * @return void Success/Failure */ public function confirmGatewayFee() :void @@ -395,7 +394,7 @@ class BaseDriver extends AbstractPaymentDriver /*Hydrate invoices*/ $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->withTrashed()->get(); - $invoices->each(function ($invoice) use ($fee_total) { + $invoices->each(function ($invoice) { if (collect($invoice->line_items)->contains('type_id', '3')) { $invoice->service()->toggleFeesPaid()->save(); } @@ -421,7 +420,6 @@ class BaseDriver extends AbstractPaymentDriver /** * Return the contact if possible. * - * @return ClientContact The ClientContact object */ public function getContact() {