mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-13 00:44:39 -04:00
Add RFF functionality to BillingPortalPurchase class
This commit is contained in:
parent
e2eb53ed30
commit
ecefa336d2
@ -106,6 +106,7 @@ class BillingPortalPurchase extends Component
|
|||||||
public $steps = [
|
public $steps = [
|
||||||
'passed_email' => false,
|
'passed_email' => false,
|
||||||
'existing_user' => false,
|
'existing_user' => false,
|
||||||
|
'check_rff' => false,
|
||||||
'fetched_payment_methods' => false,
|
'fetched_payment_methods' => false,
|
||||||
'fetched_client' => false,
|
'fetched_client' => false,
|
||||||
'show_start_trial' => false,
|
'show_start_trial' => false,
|
||||||
@ -181,6 +182,12 @@ class BillingPortalPurchase extends Component
|
|||||||
*/
|
*/
|
||||||
public $campaign;
|
public $campaign;
|
||||||
|
|
||||||
|
public ?string $contact_first_name;
|
||||||
|
|
||||||
|
public ?string $contact_last_name;
|
||||||
|
|
||||||
|
public ?string $contact_email;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
MultiDB::setDb($this->db);
|
MultiDB::setDb($this->db);
|
||||||
@ -316,10 +323,14 @@ class BillingPortalPurchase extends Component
|
|||||||
*/
|
*/
|
||||||
protected function getPaymentMethods(ClientContact $contact): self
|
protected function getPaymentMethods(ClientContact $contact): self
|
||||||
{
|
{
|
||||||
Auth::guard('contact')->loginUsingId($contact->id, true);
|
|
||||||
|
|
||||||
$this->contact = $contact;
|
$this->contact = $contact;
|
||||||
|
|
||||||
|
if ($contact->showRff()) {
|
||||||
|
return $this->rff();
|
||||||
|
}
|
||||||
|
|
||||||
|
Auth::guard('contact')->loginUsingId($contact->id, true);
|
||||||
|
|
||||||
if ($this->subscription->trial_enabled) {
|
if ($this->subscription->trial_enabled) {
|
||||||
$this->heading_text = ctrans('texts.plan_trial');
|
$this->heading_text = ctrans('texts.plan_trial');
|
||||||
$this->steps['show_start_trial'] = true;
|
$this->steps['show_start_trial'] = true;
|
||||||
@ -340,6 +351,33 @@ class BillingPortalPurchase extends Component
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function rff()
|
||||||
|
{
|
||||||
|
$this->contact_first_name = $this->contact->first_name;
|
||||||
|
$this->contact_last_name = $this->contact->last_name;
|
||||||
|
$this->contact_email = $this->contact->email;
|
||||||
|
|
||||||
|
$this->steps['check_rff'] = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleRff()
|
||||||
|
{
|
||||||
|
$validated = $this->validate([
|
||||||
|
'contact_first_name' => ['required'],
|
||||||
|
'contact_last_name' => ['required'],
|
||||||
|
'contact_email' => ['required', 'email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->contact->first_name = $validated['contact_first_name'];
|
||||||
|
$this->contact->last_name = $validated['contact_last_name'];
|
||||||
|
$this->contact->email = $validated['contact_email'];
|
||||||
|
$this->contact->save();
|
||||||
|
|
||||||
|
return $this->getPaymentMethods($this->contact);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middle method between selecting payment method &
|
* Middle method between selecting payment method &
|
||||||
* submitting the from to the backend.
|
* submitting the from to the backend.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user