Passing data about campaign into billing components

This commit is contained in:
Benjamin Beganović 2021-05-29 13:16:45 +02:00
parent c7739e64ec
commit f64b0b3d19
2 changed files with 21 additions and 14 deletions

View File

@ -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;
@ -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;
@ -346,8 +353,8 @@ class BillingPortalPurchase extends Component
'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');
} }

View File

@ -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')