From c0dbd9b0ba4cb98871a989adaf96fc7893a088ef Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 29 Apr 2023 12:32:57 +1000 Subject: [PATCH] Updates for billing profiles --- app/Http/Livewire/BillingPortalPurchase.php | 2 ++ app/Models/Account.php | 2 +- app/Services/Subscription/SubscriptionService.php | 4 ++++ app/Services/Subscription/ZeroCostProduct.php | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 75b74cf28d..02f4158c83 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -447,6 +447,7 @@ class BillingPortalPurchase extends Component return; } + $utm = isset($this->request_data['utm']) ? $this->request_data['utm'] : null; return $this->subscription->service()->handleNoPaymentRequired([ 'email' => $this->email ?? $this->contact->email, @@ -454,6 +455,7 @@ class BillingPortalPurchase extends Component 'contact_id' => $this->contact->id, 'client_id' => $this->contact->client->id, 'coupon' => $this->coupon, + 'utm' => $utm ]); } diff --git a/app/Models/Account.php b/app/Models/Account.php index 7eb5f80e1e..711987043c 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -68,7 +68,7 @@ use Laracasts\Presenter\PresentableTrait; * @property int $is_verified_account * @property string|null $account_sms_verification_code * @property string|null $account_sms_verification_number - * @property int $account_sms_verified + * @property bool $account_sms_verified * @property string|null $bank_integration_account_id * @property int $is_trial * @property-read int|null $bank_integrations_count diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 5c24374032..50fca10a4d 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -121,6 +121,10 @@ class SubscriptionService 'account_key' => $recurring_invoice->client->custom_value2, ]; + if (!property_exists($payment_hash->data->billing_context, 'utm') && $payment_hash->data->billing_context->utm) { + $context['utm'] = $payment_hash->data->billing_context->utm; + } + $response = $this->triggerWebhook($context); return $this->handleRedirect('/client/recurring_invoices/'.$recurring_invoice->hashed_id); diff --git a/app/Services/Subscription/ZeroCostProduct.php b/app/Services/Subscription/ZeroCostProduct.php index 2350428894..9dfe2f3182 100644 --- a/app/Services/Subscription/ZeroCostProduct.php +++ b/app/Services/Subscription/ZeroCostProduct.php @@ -79,6 +79,9 @@ class ZeroCostProduct extends AbstractService 'redirect_url' => "/client/recurring_invoices/{$recurring_invoice->hashed_id}", ]; + if(isset($this->data['utm'])) + $context['utm'] = $this->data['utm']; + return $context; }