diff --git a/app/Http/Livewire/WepaySignup.php b/app/Http/Livewire/WepaySignup.php
index 0b2636d60769..33951d020736 100644
--- a/app/Http/Livewire/WepaySignup.php
+++ b/app/Http/Livewire/WepaySignup.php
@@ -37,6 +37,7 @@ class WepaySignup extends Component
public $privacy_policy;
public $saved;
+ public $company;
protected $rules = [
'first_name' => ['required'],
@@ -51,8 +52,8 @@ class WepaySignup extends Component
public function mount()
{
$user = User::find($this->user_id);
- $company = Company::where('company_key', $this->company_key)->first();
-
+ $this->company = Company::where('company_key', $this->company_key)->firstOrFail();
+
$this->fill([
'wepay_payment_tos_agree' => '',
'ach' => '',
@@ -61,7 +62,7 @@ class WepaySignup extends Component
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'email' => $user->email,
- 'company_name' => $company->present()->name(),
+ 'company_name' => $this->company->present()->name(),
'saved' => ctrans('texts.confirm'),
'terms' => ''.ctrans('texts.terms_of_service').'',
'privacy_policy' => ''.ctrans('texts.privacy_policy').'',
@@ -106,29 +107,29 @@ class WepaySignup extends Component
$wepay = new WePay($access_token);
$account_details = [
- 'name' => $data['company_name']),
+ 'name' => $data['company_name'],
'description' => ctrans('texts.wepay_account_description'),
- 'theme_object' => json_decode({"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}),
+ 'theme_object' => json_decode('{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}'),
'callback_uri' => $accountGateway->getWebhookUrl(),
- 'rbits' => $account->present()->rBits,
+ 'rbits' => $this->company->present()->rBits,
'country' => $data['country'],
];
- if (Input::get('country') == 'CA') {
- $accountDetails['currencies'] = ['CAD'];
- $accountDetails['country_options'] = ['debit_opt_in' => boolval(Input::get('debit_cards'))];
- } elseif (Input::get('country') == 'GB') {
- $accountDetails['currencies'] = ['GBP'];
+ if ($data['country'] == 'CA') {
+ $account_details['currencies'] = ['CAD'];
+ $account_details['country_options'] = ['debit_opt_in' => boolval($data['debit_cards'])];
+ } elseif ($data['country'] == 'GB') {
+ $account_details['currencies'] = ['GBP'];
}
- $wepayAccount = $wepay->request('account/create/', $accountDetails);
+ $wepay_account = $wepay->request('account/create/', $account_details);
try {
$wepay->request('user/send_confirmation/', []);
- $confirmationRequired = true;
+ $confirmation_required = true;
} catch (\WePayException $ex) {
if ($ex->getMessage() == 'This access_token is already approved.') {
- $confirmationRequired = false;
+ $confirmation_required = false;
} else {
throw $ex;
}
diff --git a/app/Models/Company.php b/app/Models/Company.php
index c0ed357362dc..b262a63ba3f9 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -442,4 +442,24 @@ class Company extends BaseModel
{
return $this->slack_webhook_url;
}
+
+ public function rBits()
+ {
+ $account = $this->account;
+ $user = $this->owner();
+ $data = [];
+
+ $data[] = $this->createRBit('business_name', 'user', ['business_name' => $this->present()->name()]);
+ $data[] = $this->createRBit('industry_code', 'user', ['industry_detail' => $this->industry->name]);
+ $data[] = $this->createRBit('comment', 'partner_database', ['comment_text' => 'Logo image not present']);
+ $data[] = $this->createRBit('business_description', 'user', ['business_description' => $company->present()->size]);
+
+ $data[] = $this->createRBit('person', 'user', ['name' => $user->present()->getFullName()]);
+ $data[] = $this->createRBit('email', 'user', ['email' => $user->email]);
+ $data[] = $this->createRBit('phone', 'user', ['phone' => $user->phone]);
+ $data[] = $this->createRBit('website_uri', 'user', ['uri' => $this->settings->website]);
+ $data[] = $this->createRBit('external_account', 'partner_database', ['is_partner_account' => 'yes', 'account_type' => 'Invoice Ninja', 'create_time' => time()]);
+
+ return $data;
+ }
}
diff --git a/app/Models/Presenters/CompanyPresenter.php b/app/Models/Presenters/CompanyPresenter.php
index d7cb21a24b56..7251e7fd9f81 100644
--- a/app/Models/Presenters/CompanyPresenter.php
+++ b/app/Models/Presenters/CompanyPresenter.php
@@ -106,4 +106,8 @@ class CompanyPresenter extends EntityPresenter
"SPC\n0200\n1\n{$user_iban}\nK\n{$this->name}\n{$settings->address1}\n{$settings->postal_code} {$settings->city}\n\n\nCH\n\n\n\n\n\n\n\n{$balance_due_raw}\n{$client_currency}\n\n\n\n\n\n\n\nNON\n\n{$invoice_number}\nEPD\n";
}
+ public function size()
+ {
+ return $this->entity->size ? $this->entity->size->name : '';
+ }
}
diff --git a/app/Models/Presenters/UserPresenter.php b/app/Models/Presenters/UserPresenter.php
index f7c23d7699f4..b45220fa5512 100644
--- a/app/Models/Presenters/UserPresenter.php
+++ b/app/Models/Presenters/UserPresenter.php
@@ -26,4 +26,28 @@ class UserPresenter extends EntityPresenter
return $first_name.' '.$last_name;
}
+
+
+ public function getDisplayName()
+ {
+ if ($this->getFullName()) {
+ return $this->getFullName();
+ } elseif ($this->entity->email) {
+ return $this->entity->email;
+ } else {
+ return ctrans('texts.guest');
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function getFullName()
+ {
+ if ($this->entity->first_name || $this->entity->last_name) {
+ return $this->entity->first_name.' '.$this->entity->last_name;
+ } else {
+ return '';
+ }
+ }
}