mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:34:30 -04:00
Subscriptions v2 - handle trial
This commit is contained in:
parent
1e72989a1a
commit
d6aedeef91
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -166,7 +166,11 @@ class SubscriptionService
|
||||
//create recurring invoice with start date = trial_duration + 1 day
|
||||
$recurring_invoice_repo = new RecurringInvoiceRepository();
|
||||
|
||||
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 */
|
||||
|
@ -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',
|
||||
|
@ -207,7 +207,7 @@
|
||||
<div id="summary" class="px-4 text-white">
|
||||
<h1 class="font-semibold text-2xl border-b-2 border-gray-200 border-opacity-50 pb-2 text-white">{{ ctrans('texts.order') }}</h1>
|
||||
|
||||
@foreach($bundle as $item)
|
||||
@foreach($bundle->toArray() as $item)
|
||||
<div class="flex justify-between mt-1 mb-1">
|
||||
<span class="font-light text-sm uppercase">{{$item['product']}} x {{$item['qty']}}</span>
|
||||
<span class="font-semibold text-sm">{{ $item['price'] }}</span>
|
||||
@ -257,7 +257,14 @@
|
||||
{{ session('message') }}
|
||||
@endcomponent
|
||||
@endif
|
||||
@if(count($methods) > 0)
|
||||
@if($subscription->trial_enabled)
|
||||
<form wire:submit.prevent="handleTrial" class="mt-8">
|
||||
@csrf
|
||||
<button class="relative -ml-px inline-flex items-center space-x-2 rounded border border-gray-300 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
{{ ctrans('texts.trial_call_to_action') }}
|
||||
</button>
|
||||
</form>
|
||||
@elseif(count($methods) > 0)
|
||||
<div class="mt-4" x-show.important="!toggle" x-transition>
|
||||
@foreach($methods as $method)
|
||||
<button
|
||||
@ -268,6 +275,13 @@
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@elseif(intval($float_amount_total) == 0)
|
||||
<form wire:submit.prevent="handlePaymentNotRequired" class="mt-8">
|
||||
@csrf
|
||||
<button class="relative -ml-px inline-flex items-center space-x-2 rounded border border-gray-300 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
{{ ctrans('texts.click_to_continue') }}
|
||||
</button>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
<div class="mt-4 container mx-auto flex w-full justify-center" x-show.important="toggle" x-transition>
|
||||
@ -312,10 +326,12 @@
|
||||
@endif
|
||||
|
||||
@if($email && !$errors->has('email') && !$authenticated)
|
||||
<div class="py-6 px-6 w-80 mx-auto text-center my-6">
|
||||
<p class="w-full p-2">{{$email}}</p>
|
||||
<div class="w-full mx-auto text-center my-2">
|
||||
<p class="w-full p-2">{{ ctrans('texts.otp_code_message', ['email' => $email])}}</p>
|
||||
</div>
|
||||
<div class="pb-6 px-6 w-80 mx-auto text-center">
|
||||
<form wire:submit.prevent="handleLogin" class="" x-data="otpForm()">
|
||||
<p class="mb-4">{{ ctrans('texts.otp_code_message')}}</p>
|
||||
<p class="mb-4"></p>
|
||||
<div class="flex justify-between">
|
||||
<template x-for="(input, index) in length" :key="index">
|
||||
<input
|
||||
|
Loading…
x
Reference in New Issue
Block a user