diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index 103b5912f0db..dd2bf843e024 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -402,7 +402,6 @@ class BillingPortalPurchasev2 extends Component } - return $this; } @@ -450,6 +449,8 @@ class BillingPortalPurchasev2 extends Component $this->buildBundle(); +nlog($this->bundle); + return $this; } @@ -535,7 +536,16 @@ class BillingPortalPurchasev2 extends Component $this->emit('beforePaymentEventsCompleted'); } - + public function handleTrial() + { + return $this->subscription->service()->startTrial([ + 'email' => $this->email ?? $this->contact->email, + 'quantity' => $this->quantity, + 'contact_id' => $this->contact->id, + 'client_id' => $this->contact->client->id, + 'bundle' => $this->bundle, + ]); + } diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index db3dd6f5acec..f0c64316dffb 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -166,7 +166,11 @@ class SubscriptionService //create recurring invoice with start date = trial_duration + 1 day $recurring_invoice_repo = new RecurringInvoiceRepository(); - $recurring_invoice = $this->convertInvoiceToRecurring($client_contact->client_id); + if(isset($data['bundle'])) + $recurring_invoice = $this->convertInvoiceToRecurringBundle($client_contact->client_id, $data['bundle']->map(function ($bundle){ return (object) $bundle;})); + else + $recurring_invoice = $this->convertInvoiceToRecurring($client_contact->client_id); + $recurring_invoice->next_send_date = now()->addSeconds($this->subscription->trial_duration); $recurring_invoice->next_send_date_client = now()->addSeconds($this->subscription->trial_duration); $recurring_invoice->backup = 'is_trial'; @@ -181,7 +185,6 @@ class SubscriptionService $recurring_invoice->is_amount_discount = $this->subscription->is_amount_discount; } - $recurring_invoice = $recurring_invoice_repo->save($data, $recurring_invoice); /* Start the recurring service */ diff --git a/lang/en/texts.php b/lang/en/texts.php index e64bc61fabeb..03e365511598 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -4896,7 +4896,7 @@ $LANG = array( 'delete_bank_account' => 'Delete Bank Account', 'archive_transaction' => 'Archive Transaction', 'delete_transaction' => 'Delete Transaction', - 'otp_code_message' => 'Enter the code emailed.', + 'otp_code_message' => 'We have sent a code to :email enter this code to proceed.', 'otp_code_subject' => 'Your one time passcode code', 'otp_code_body' => 'Your one time passcode is :code', 'delete_tax_rate' => 'Delete Tax Rate', diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index a1f72cf5cecb..91a1a6ba559d 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -207,7 +207,7 @@
{{$email}}
+{{ ctrans('texts.otp_code_message', ['email' => $email])}}
+