mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Subscriptions v2
This commit is contained in:
parent
9a0a55d356
commit
21bec86fda
@ -192,9 +192,8 @@ class BillingPortalPurchasev2 extends Component
|
||||
public $discount;
|
||||
public $sub_total;
|
||||
public $authenticated = false;
|
||||
public $otp;
|
||||
public $login;
|
||||
public $value;
|
||||
public $float_amount_total;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
@ -202,6 +201,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
|
||||
$this->discount = 0;
|
||||
$this->sub_total = 0;
|
||||
$this->float_amount_total = 0;
|
||||
|
||||
$this->data = [];
|
||||
|
||||
@ -257,6 +257,10 @@ class BillingPortalPurchasev2 extends Component
|
||||
$this->createClientContact();
|
||||
}
|
||||
|
||||
$this->authenticated = true;
|
||||
|
||||
$this->getPaymentMethods();
|
||||
|
||||
}
|
||||
|
||||
public function showClientRequiredFields()
|
||||
@ -264,6 +268,11 @@ class BillingPortalPurchasev2 extends Component
|
||||
|
||||
}
|
||||
|
||||
public function resetEmail()
|
||||
{
|
||||
$this->email = null;
|
||||
}
|
||||
|
||||
public function handleEmail()
|
||||
{
|
||||
$this->validateOnly('email', ['email' => 'required|bail|email:rfc']);
|
||||
@ -415,6 +424,7 @@ class BillingPortalPurchasev2 extends Component
|
||||
|
||||
$this->total = Number::formatMoney(($this->bundle->sum('total') - $discount), $this->subscription->company);
|
||||
|
||||
$this->float_amount_total = ($this->bundle->sum('total') - $discount);
|
||||
}
|
||||
|
||||
|
||||
@ -479,39 +489,39 @@ class BillingPortalPurchasev2 extends Component
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle user authentication
|
||||
*
|
||||
* @return $this|bool|void
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
$this->validate();
|
||||
// /**
|
||||
// * Handle user authentication
|
||||
// *
|
||||
// * @return $this|bool|void
|
||||
// */
|
||||
// public function authenticate()
|
||||
// {
|
||||
// $this->validate();
|
||||
|
||||
$contact = ClientContact::where('email', $this->email)
|
||||
->where('company_id', $this->subscription->company_id)
|
||||
->first();
|
||||
// $contact = ClientContact::where('email', $this->email)
|
||||
// ->where('company_id', $this->subscription->company_id)
|
||||
// ->first();
|
||||
|
||||
if ($contact && $this->steps['existing_user'] === false) {
|
||||
return $this->steps['existing_user'] = true;
|
||||
}
|
||||
// if ($contact && $this->steps['existing_user'] === false) {
|
||||
// return $this->steps['existing_user'] = true;
|
||||
// }
|
||||
|
||||
if ($contact && $this->steps['existing_user']) {
|
||||
$attempt = Auth::guard('contact')->attempt(['email' => $this->email, 'password' => $this->password, 'company_id' => $this->subscription->company_id]);
|
||||
// if ($contact && $this->steps['existing_user']) {
|
||||
// $attempt = Auth::guard('contact')->attempt(['email' => $this->email, 'password' => $this->password, 'company_id' => $this->subscription->company_id]);
|
||||
|
||||
return $attempt
|
||||
? $this->getPaymentMethods($contact)
|
||||
: session()->flash('message', 'These credentials do not match our records.');
|
||||
}
|
||||
// return $attempt
|
||||
// ? $this->getPaymentMethods($contact)
|
||||
// : session()->flash('message', 'These credentials do not match our records.');
|
||||
// }
|
||||
|
||||
$this->steps['existing_user'] = false;
|
||||
// $this->steps['existing_user'] = false;
|
||||
|
||||
$contact = $this->createBlankClient();
|
||||
// $contact = $this->createBlankClient();
|
||||
|
||||
if ($contact && $contact instanceof ClientContact) {
|
||||
$this->getPaymentMethods($contact);
|
||||
}
|
||||
}
|
||||
// if ($contact && $contact instanceof ClientContact) {
|
||||
// $this->getPaymentMethods($contact);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -593,27 +603,26 @@ class BillingPortalPurchasev2 extends Component
|
||||
* @param ClientContact $contact
|
||||
* @return $this
|
||||
*/
|
||||
protected function getPaymentMethods(ClientContact $contact): self
|
||||
protected function getPaymentMethods(): self
|
||||
{
|
||||
Auth::guard('contact')->loginUsingId($contact->id, true);
|
||||
|
||||
$this->contact = $contact;
|
||||
$this->methods = $this->contact->client->service()->getPaymentMethods($this->float_amount_total);
|
||||
|
||||
if ($this->subscription->trial_enabled) {
|
||||
$this->heading_text = ctrans('texts.plan_trial');
|
||||
$this->steps['show_start_trial'] = true;
|
||||
// if ($this->subscription->trial_enabled) {
|
||||
// $this->heading_text = ctrans('texts.plan_trial');
|
||||
// $this->steps['show_start_trial'] = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
if ((int)$this->price == 0)
|
||||
$this->steps['payment_required'] = false;
|
||||
else
|
||||
$this->steps['fetched_payment_methods'] = true;
|
||||
// if ((int)$this->price == 0)
|
||||
// $this->steps['payment_required'] = false;
|
||||
// else
|
||||
// $this->steps['fetched_payment_methods'] = true;
|
||||
|
||||
$this->methods = $contact->client->service()->getPaymentMethods($this->price);
|
||||
// $this->methods = $contact->client->service()->getPaymentMethods($this->price);
|
||||
|
||||
$this->heading_text = ctrans('texts.payment_methods');
|
||||
// $this->heading_text = ctrans('texts.payment_methods');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ class Charge
|
||||
'payment_method' => $cgt->token,
|
||||
'customer' => $cgt->gateway_customer_reference,
|
||||
'confirm' => true,
|
||||
// 'off_session' => true,
|
||||
'description' => $description,
|
||||
'metadata' => [
|
||||
'payment_hash' => $payment_hash->hash,
|
||||
|
@ -231,8 +231,28 @@
|
||||
</div>
|
||||
|
||||
@if($authenticated)
|
||||
<button class="bg-white font-semibold hover:bg-gray-600 py-3 text-sm text-blue-500 uppercase w-full">Checkout</button>
|
||||
@else
|
||||
<div class=" mx-auto text-center mt-20 content-center">
|
||||
<h2 class="text-2xl font-bold tracking-wide border-b-2 pb-4">{{ $heading_text ?? ctrans('texts.checkout') }}</h2>
|
||||
@if (session()->has('message'))
|
||||
@component('portal.ninja2020.components.message')
|
||||
{{ session('message') }}
|
||||
@endcomponent
|
||||
@endif
|
||||
@if(count($methods) > 0)
|
||||
<div class="mt-4">
|
||||
@foreach($methods as $method)
|
||||
<button
|
||||
wire:click="handleMethodSelectingEvent('{{ $method['company_gateway_id'] }}', '{{ $method['gateway_type_id'] }}')"
|
||||
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">
|
||||
{{ $method['label'] }}
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(!$email || $errors->has('email'))
|
||||
<form wire:submit.prevent="handleEmail" class="">
|
||||
@csrf
|
||||
<div class="mt-4">
|
||||
@ -259,8 +279,9 @@
|
||||
</form>
|
||||
@endif
|
||||
|
||||
@if($email && !$errors->has('email'))
|
||||
<div class="py-6 px-6 w-80 border mx-auto text-center my-6">
|
||||
@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>
|
||||
<form wire:submit.prevent="handleLogin" class="" x-data="otpForm()">
|
||||
<p class="mb-4">{{ ctrans('texts.otp_code_message')}}</p>
|
||||
<div class="flex justify-between">
|
||||
@ -276,6 +297,7 @@
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@error("login")
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
|
||||
@ -283,6 +305,9 @@
|
||||
<span class="absolute top-0 bottom-0 right-0 px-4 py-3">
|
||||
</div>
|
||||
@enderror
|
||||
<div class="flex w-full place-content-end mb-0 mt-4">
|
||||
<button wire:click="resetEmail" class="relative -ml-px inline-flex items-center space-x-1 rounded border border-gray-300 bg-gray-50 px-1 py-1 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.reset') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user