diff --git a/app/Helpers/Bank/Yodlee/Yodlee.php b/app/Helpers/Bank/Yodlee/Yodlee.php index 24826b04dd5a..c781a7086ac3 100644 --- a/app/Helpers/Bank/Yodlee/Yodlee.php +++ b/app/Helpers/Bank/Yodlee/Yodlee.php @@ -53,6 +53,8 @@ class Yodlee $this->admin_name = config('ninja.yodlee.admin_name'); + $this->test_mode = config('ninja.yodlee.test_mode'); + } public function getFastTrackUrl() diff --git a/app/Http/Controllers/Bank/YodleeController.php b/app/Http/Controllers/Bank/YodleeController.php index 1de1e6e13c77..63af12cfcca9 100644 --- a/app/Http/Controllers/Bank/YodleeController.php +++ b/app/Http/Controllers/Bank/YodleeController.php @@ -25,36 +25,39 @@ class YodleeController extends BaseController // create a user at this point // use the one time token here to pull in the actual user - - //store the user_account_id on the accounts table + // store the user_account_id on the accounts table $yodlee = new Yodlee(); - $yodlee->setTestMode(); $company = $request->getCompany(); if($company->account->bank_integration_account_id){ + $flow = 'edit'; + $token = $company->account->bank_integration_account_id; + } else{ + $flow = 'add'; + $response = $yodlee->createUser($company); $token = $response->user->loginName; $company->account->bank_integration_account_id = $token; + $company->push(); } $yodlee = new Yodlee($token); - $yodlee->setTestMode(); $data = [ 'access_token' => $yodlee->getAccessToken(), 'fasttrack_url' => $yodlee->getFastTrackUrl(), - 'config_name' => 'testninja', + 'config_name' => config('ninja.yodlee.config_name'), 'flow' => $flow, 'company' => $company, 'account' => $company->account, @@ -64,5 +67,4 @@ class YodleeController extends BaseController } - } diff --git a/app/Http/Controllers/BankIntegrationController.php b/app/Http/Controllers/BankIntegrationController.php index 4bcb7bde27e8..40fa14392f03 100644 --- a/app/Http/Controllers/BankIntegrationController.php +++ b/app/Http/Controllers/BankIntegrationController.php @@ -541,7 +541,6 @@ class BankIntegrationController extends BaseController return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400); $yodlee = new Yodlee($bank_account_id); - $yodlee->setTestMode(); $accounts = $yodlee->getAccounts(); @@ -622,7 +621,6 @@ class BankIntegrationController extends BaseController $bi = BankIntegration::withTrashed()->where('bank_account_id', $acc_id)->where('company_id', auth()->user()->company()->id)->firstOrFail(); $yodlee = new Yodlee($bank_account_id); - $yodlee->setTestMode(); $res = $yodlee->deleteAccount($acc_id); $this->bank_integration_repo->delete($bi); @@ -680,7 +678,6 @@ class BankIntegrationController extends BaseController return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400); $yodlee = new Yodlee($bank_account_id); - $yodlee->setTestMode(); $data = [ 'top' => 500, @@ -689,7 +686,7 @@ class BankIntegrationController extends BaseController $transactions = $yodlee->getTransactions($data); - BankService::dispatch(auth()->user()->company()->id, auth()->user()->company()->db)); + BankService::dispatch(auth()->user()->company()->id, auth()->user()->company()->db); return response()->json(['message' => 'Fetching transactions....'], 200); diff --git a/app/Http/Controllers/BankTransactionController.php b/app/Http/Controllers/BankTransactionController.php index 6409837dc0d1..6df1a403cc90 100644 --- a/app/Http/Controllers/BankTransactionController.php +++ b/app/Http/Controllers/BankTransactionController.php @@ -505,7 +505,6 @@ class BankTransactionController extends BaseController return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400); $yodlee = new Yodlee($bank_account_id); - $yodlee->setTestMode(); $data = [ 'CONTAINER' => 'bank', diff --git a/app/Jobs/Bank/ProcessBankTransactions.php b/app/Jobs/Bank/ProcessBankTransactions.php index a2b43bfaac1b..db100b98d31e 100644 --- a/app/Jobs/Bank/ProcessBankTransactions.php +++ b/app/Jobs/Bank/ProcessBankTransactions.php @@ -54,7 +54,6 @@ class ProcessBankTransactions implements ShouldQueue { $yodlee = new Yodlee($this->bank_integration_account_id); - $yodlee->setTestMode(); $data = [ 'baseType' => 'DEBIT', //CREDIT diff --git a/config/ninja.php b/config/ninja.php index 6cd5384648be..db86dd232fab 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -204,5 +204,7 @@ return [ 'client_id' => env('YODLEE_CLIENT_ID',false), 'client_secret' => env('YODLEE_CLIENT_SECRET', false), 'admin_name' => env('YODLEE_LOGIN_ADMIN_NAME', false), + 'test_mode' => env("YODLEE_TEST_MODE", false), + 'config_name' => env("YODLEE_CONFIG_NAME", false), ], ]; diff --git a/tests/Feature/Bank/YodleeApiTest.php b/tests/Feature/Bank/YodleeApiTest.php index 8a8a7d76a2e5..c5b45fbc8a73 100644 --- a/tests/Feature/Bank/YodleeApiTest.php +++ b/tests/Feature/Bank/YodleeApiTest.php @@ -85,7 +85,6 @@ class YodleeApiTest extends TestCase { $yodlee = new Yodlee(); - $yodlee->setTestMode(); $this->assertNotNull($yodlee); @@ -96,7 +95,6 @@ class YodleeApiTest extends TestCase { $yodlee = new Yodlee('sbMem62e1e69547bfb1'); - $yodlee->setTestMode(); $access_token = $yodlee->getAccessToken(); @@ -281,9 +279,7 @@ class YodleeApiTest extends TestCase public function testGetCategories() { - $yodlee = new Yodlee('sbMem62e1e69547bfb2'); - $yodlee->setTestMode(); $transactions = $yodlee->getTransactionCategories(); @@ -398,10 +394,9 @@ class YodleeApiTest extends TestCase { $yodlee = new Yodlee('sbMem62e1e69547bfb1'); - $yodlee->setTestMode(); $accounts = $yodlee->getAccounts(); -nlog($accounts); + $this->assertIsArray($accounts); } @@ -456,7 +451,6 @@ nlog($accounts); { $yodlee = new Yodlee('sbMem62e1e69547bfb1'); - $yodlee->setTestMode(); $transactions = $yodlee->getTransactions(['categoryId' => 2, 'fromDate' => '2000-01-01']); @@ -464,12 +458,10 @@ nlog($accounts); } - public function testGetTransactionsWithParams() { $yodlee = new Yodlee('sbMem62e1e69547bfb1'); - $yodlee->setTestMode(); $data = [ 'basetype' => 'DEBIT', //CREDIT @@ -484,7 +476,4 @@ nlog($accounts); nlog($accounts); } - - - }