mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 08:04:40 -04:00
Passing data about campaign into billing components
This commit is contained in:
parent
c7739e64ec
commit
f64b0b3d19
@ -162,6 +162,13 @@ class BillingPortalPurchase extends Component
|
|||||||
*/
|
*/
|
||||||
public $passwordless_login_btn = false;
|
public $passwordless_login_btn = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Campaign reference.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
public $campaign;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->price = $this->subscription->price;
|
$this->price = $this->subscription->price;
|
||||||
@ -182,8 +189,8 @@ class BillingPortalPurchase extends Component
|
|||||||
$this->validate();
|
$this->validate();
|
||||||
|
|
||||||
$contact = ClientContact::where('email', $this->email)
|
$contact = ClientContact::where('email', $this->email)
|
||||||
->where('company_id', $this->subscription->company_id)
|
->where('company_id', $this->subscription->company_id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($contact && $this->steps['existing_user'] === false) {
|
if ($contact && $this->steps['existing_user'] === false) {
|
||||||
return $this->steps['existing_user'] = true;
|
return $this->steps['existing_user'] = true;
|
||||||
@ -273,7 +280,7 @@ class BillingPortalPurchase extends Component
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((int)$this->subscription->price == 0)
|
if ((int)$this->subscription->price == 0)
|
||||||
$this->steps['payment_required'] = false;
|
$this->steps['payment_required'] = false;
|
||||||
else
|
else
|
||||||
$this->steps['fetched_payment_methods'] = true;
|
$this->steps['fetched_payment_methods'] = true;
|
||||||
@ -332,7 +339,7 @@ class BillingPortalPurchase extends Component
|
|||||||
|
|
||||||
$is_eligible = $this->subscription->service()->isEligible($this->contact);
|
$is_eligible = $this->subscription->service()->isEligible($this->contact);
|
||||||
|
|
||||||
if ($is_eligible['exception']['message'] != 'Success') {
|
if (is_array($is_eligible) && $is_eligible['exception']['message'] != 'Success') {
|
||||||
$this->steps['not_eligible'] = true;
|
$this->steps['not_eligible'] = true;
|
||||||
$this->steps['not_eligible_message'] = $is_eligible['exception']['message'];
|
$this->steps['not_eligible_message'] = $is_eligible['exception']['message'];
|
||||||
$this->steps['show_loading_bar'] = false;
|
$this->steps['show_loading_bar'] = false;
|
||||||
@ -341,13 +348,13 @@ class BillingPortalPurchase extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cache::put($this->hash, [
|
Cache::put($this->hash, [
|
||||||
'subscription_id' => $this->subscription->id,
|
'subscription_id' => $this->subscription->id,
|
||||||
'email' => $this->email ?? $this->contact->email,
|
'email' => $this->email ?? $this->contact->email,
|
||||||
'client_id' => $this->contact->client->id,
|
'client_id' => $this->contact->client->id,
|
||||||
'invoice_id' => $this->invoice->id,
|
'invoice_id' => $this->invoice->id,
|
||||||
'context' => 'purchase',
|
'context' => 'purchase',
|
||||||
now()->addMinutes(60)]
|
'campaign' => $this->campaign,
|
||||||
);
|
], now()->addMinutes(60));
|
||||||
|
|
||||||
$this->emit('beforePaymentEventsCompleted');
|
$this->emit('beforePaymentEventsCompleted');
|
||||||
}
|
}
|
||||||
@ -370,7 +377,7 @@ class BillingPortalPurchase extends Component
|
|||||||
public function handlePaymentNotRequired()
|
public function handlePaymentNotRequired()
|
||||||
{
|
{
|
||||||
|
|
||||||
$is_eligible = $this->subscription->service()->isEligible($this->contact);
|
$is_eligible = $this->subscription->service()->isEligible($this->contact);
|
||||||
|
|
||||||
if ($is_eligible['status_code'] != 200) {
|
if ($is_eligible['status_code'] != 200) {
|
||||||
$this->steps['not_eligible'] = true;
|
$this->steps['not_eligible'] = true;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
@section('meta_title', ctrans('texts.purchase'))
|
@section('meta_title', ctrans('texts.purchase'))
|
||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
@livewire('billing-portal-purchase', ['subscription' => $subscription, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data])
|
@livewire('billing-portal-purchase', ['subscription' => $subscription, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'campaign' => request()->query('campaign') ?? null])
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@push('footer')
|
@push('footer')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user