diff --git a/app/Http/Controllers/Bank/YodleeController.php b/app/Http/Controllers/Bank/YodleeController.php index 63af12cfcca9..fa9d7889dd03 100644 --- a/app/Http/Controllers/Bank/YodleeController.php +++ b/app/Http/Controllers/Bank/YodleeController.php @@ -31,6 +31,7 @@ class YodleeController extends BaseController $company = $request->getCompany(); + if($company->account->bank_integration_account_id){ $flow = 'edit'; @@ -54,6 +55,9 @@ class YodleeController extends BaseController $yodlee = new Yodlee($token); + if($request->has('window_closed') && $request->input("window_closed") == "true") + $this->getAccounts($company, $token); + $data = [ 'access_token' => $yodlee->getAccessToken(), 'fasttrack_url' => $yodlee->getFastTrackUrl(), @@ -61,10 +65,43 @@ class YodleeController extends BaseController 'flow' => $flow, 'company' => $company, 'account' => $company->account, + 'completed' => $request->has('window_closed') ? true : false, ]; return view('bank.yodlee.auth', $data); } + private function getAccounts($company, $token) + { + $yodlee = new Yodlee($token); + + $accounts = $yodlee->getAccounts(); + + foreach($accounts as $account) + { + + if(!BankIntegration::where('bank_account_id', $account['id'])->where('company_id', $company->id)->exists()) + { + $bank_integration = new BankIntegration(); + $bank_integration->company_id = $company->id; + $bank_integration->account_id = $company->account_id; + $bank_integration->user_id = $company->owner()->id; + $bank_integration->bank_account_id = $account['id']; + $bank_integration->bank_account_type = $account['account_type']; + $bank_integration->bank_account_name = $account['account_name']; + $bank_integration->bank_account_status = $account['account_status']; + $bank_integration->bank_account_number = $account['account_number']; + $bank_integration->provider_id = $account['provider_id']; + $bank_integration->provider_name = $account['provider_name']; + $bank_integration->nickname = $account['nickname']; + $bank_integration->balance = $account['current_balance']; + $bank_integration->currency = $account['account_currency']; + + $bank_integration->save(); + } + + } + } + } diff --git a/resources/views/bank/yodlee/auth.blade.php b/resources/views/bank/yodlee/auth.blade.php index e2a6b5c87876..2479e2cacdc0 100644 --- a/resources/views/bank/yodlee/auth.blade.php +++ b/resources/views/bank/yodlee/auth.blade.php @@ -43,37 +43,32 @@
This may take a few seconds, please don't close this page.
-This may take a few seconds, please don't close this page.
+