mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
WePayg
This commit is contained in:
parent
24f935e277
commit
eff664a586
@ -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' => '<a href="https://go.wepay.com/terms-of-service" target="_blank">'.ctrans('texts.terms_of_service').'</a>',
|
||||
'privacy_policy' => '<a href="https://go.wepay.com/privacy-policy" target="_blank">'.ctrans('texts.privacy_policy').'</a>',
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 : '';
|
||||
}
|
||||
}
|
||||
|
@ -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 '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user