This commit is contained in:
David Bomba 2021-05-07 17:07:49 +10:00
parent 3c9b096f01
commit bdda63a214
3 changed files with 23 additions and 8 deletions

View File

@ -104,7 +104,7 @@ class WepaySignup extends Component
$wepay_driver = new WePayPaymentDriver($cg, null, null); $wepay_driver = new WePayPaymentDriver($cg, null, null);
$wepay_driver->init(); $wepay = $wepay_driver->init()->wepay;
$user_details = [ $user_details = [
'client_id' => config('ninja.wepay.client_id'), 'client_id' => config('ninja.wepay.client_id'),
@ -119,7 +119,7 @@ class WepaySignup extends Component
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money', 'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
]; ];
$wepay_user = $wepay_driver->request('user/register/', $user_details); $wepay_user = $wepay->request('user/register/', $user_details);
$access_token = $wepay_user->access_token; $access_token = $wepay_user->access_token;
@ -132,7 +132,7 @@ class WepaySignup extends Component
'description' => ctrans('texts.wepay_account_description'), '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' => route('payment_webhook', ['company_key' => $this->company->company_key, 'company_gateway_id' => $cg->hashed_id]), 'callback_uri' => route('payment_webhook', ['company_key' => $this->company->company_key, 'company_gateway_id' => $cg->hashed_id]),
'rbits' => $this->company->present()->rBits, 'rbits' => $this->company->rBits(),
'country' => $data['country'], 'country' => $data['country'],
]; ];

View File

@ -445,21 +445,36 @@ class Company extends BaseModel
public function rBits() public function rBits()
{ {
$account = $this->account;
$user = $this->owner(); $user = $this->owner();
$data = []; $data = [];
$data[] = $this->createRBit('business_name', 'user', ['business_name' => $this->present()->name()]); $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('industry_code', 'user', ['industry_detail' => $this->industry ? $this->industry->name : '']);
$data[] = $this->createRBit('comment', 'partner_database', ['comment_text' => 'Logo image not present']); $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('business_description', 'user', ['business_description' => $this->present()->size()]);
$data[] = $this->createRBit('person', 'user', ['name' => $user->present()->getFullName()]); $data[] = $this->createRBit('person', 'user', ['name' => $user->present()->getFullName()]);
$data[] = $this->createRBit('email', 'user', ['email' => $user->email]); $data[] = $this->createRBit('email', 'user', ['email' => $user->email]);
$data[] = $this->createRBit('phone', 'user', ['phone' => $user->phone]); $data[] = $this->createRBit('phone', 'user', ['phone' => $user->phone]);
$data[] = $this->createRBit('website_uri', 'user', ['uri' => $this->entity->settings->website]); $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()]); $data[] = $this->createRBit('external_account', 'partner_database', ['is_partner_account' => 'yes', 'account_type' => 'Invoice Ninja', 'create_time' => time()]);
return $data; return $data;
} }
private function createRBit($type, $source, $properties)
{
$data = new \stdClass;
$data->receive_time = time();
$data->type = $type;
$data->source = $source;
$data->properties = new \stdClass;
foreach ($properties as $key => $val) {
$data->properties->$key = $val;
}
return $data;
}
} }

View File

@ -55,7 +55,7 @@ class WePayPaymentDriver extends BaseDriver
} }
if ($this->company_gateway) if ($this->company_gateway)
$this->wepay = new WePay($this->company_gateway->getConfig()->accessToken); $this->wepay = new WePay($this->company_gateway->getConfigField('accessToken'));
$this->wepay = new WePay(null); $this->wepay = new WePay(null);