refactor test mode

This commit is contained in:
David Bomba 2022-08-16 06:03:12 +10:00
parent baf38e07d3
commit 1bfafbe24c
7 changed files with 14 additions and 24 deletions

View File

@ -53,6 +53,8 @@ class Yodlee
$this->admin_name = config('ninja.yodlee.admin_name'); $this->admin_name = config('ninja.yodlee.admin_name');
$this->test_mode = config('ninja.yodlee.test_mode');
} }
public function getFastTrackUrl() public function getFastTrackUrl()

View File

@ -25,36 +25,39 @@ class YodleeController extends BaseController
// create a user at this point // create a user at this point
// use the one time token here to pull in the actual user // 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 = new Yodlee();
$yodlee->setTestMode();
$company = $request->getCompany(); $company = $request->getCompany();
if($company->account->bank_integration_account_id){ if($company->account->bank_integration_account_id){
$flow = 'edit'; $flow = 'edit';
$token = $company->account->bank_integration_account_id; $token = $company->account->bank_integration_account_id;
} }
else{ else{
$flow = 'add'; $flow = 'add';
$response = $yodlee->createUser($company); $response = $yodlee->createUser($company);
$token = $response->user->loginName; $token = $response->user->loginName;
$company->account->bank_integration_account_id = $token; $company->account->bank_integration_account_id = $token;
$company->push(); $company->push();
} }
$yodlee = new Yodlee($token); $yodlee = new Yodlee($token);
$yodlee->setTestMode();
$data = [ $data = [
'access_token' => $yodlee->getAccessToken(), 'access_token' => $yodlee->getAccessToken(),
'fasttrack_url' => $yodlee->getFastTrackUrl(), 'fasttrack_url' => $yodlee->getFastTrackUrl(),
'config_name' => 'testninja', 'config_name' => config('ninja.yodlee.config_name'),
'flow' => $flow, 'flow' => $flow,
'company' => $company, 'company' => $company,
'account' => $company->account, 'account' => $company->account,
@ -64,5 +67,4 @@ class YodleeController extends BaseController
} }
} }

View File

@ -541,7 +541,6 @@ class BankIntegrationController extends BaseController
return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400); return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400);
$yodlee = new Yodlee($bank_account_id); $yodlee = new Yodlee($bank_account_id);
$yodlee->setTestMode();
$accounts = $yodlee->getAccounts(); $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(); $bi = BankIntegration::withTrashed()->where('bank_account_id', $acc_id)->where('company_id', auth()->user()->company()->id)->firstOrFail();
$yodlee = new Yodlee($bank_account_id); $yodlee = new Yodlee($bank_account_id);
$yodlee->setTestMode();
$res = $yodlee->deleteAccount($acc_id); $res = $yodlee->deleteAccount($acc_id);
$this->bank_integration_repo->delete($bi); $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); return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400);
$yodlee = new Yodlee($bank_account_id); $yodlee = new Yodlee($bank_account_id);
$yodlee->setTestMode();
$data = [ $data = [
'top' => 500, 'top' => 500,
@ -689,7 +686,7 @@ class BankIntegrationController extends BaseController
$transactions = $yodlee->getTransactions($data); $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); return response()->json(['message' => 'Fetching transactions....'], 200);

View File

@ -505,7 +505,6 @@ class BankTransactionController extends BaseController
return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400); return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400);
$yodlee = new Yodlee($bank_account_id); $yodlee = new Yodlee($bank_account_id);
$yodlee->setTestMode();
$data = [ $data = [
'CONTAINER' => 'bank', 'CONTAINER' => 'bank',

View File

@ -54,7 +54,6 @@ class ProcessBankTransactions implements ShouldQueue
{ {
$yodlee = new Yodlee($this->bank_integration_account_id); $yodlee = new Yodlee($this->bank_integration_account_id);
$yodlee->setTestMode();
$data = [ $data = [
'baseType' => 'DEBIT', //CREDIT 'baseType' => 'DEBIT', //CREDIT

View File

@ -204,5 +204,7 @@ return [
'client_id' => env('YODLEE_CLIENT_ID',false), 'client_id' => env('YODLEE_CLIENT_ID',false),
'client_secret' => env('YODLEE_CLIENT_SECRET', false), 'client_secret' => env('YODLEE_CLIENT_SECRET', false),
'admin_name' => env('YODLEE_LOGIN_ADMIN_NAME', false), 'admin_name' => env('YODLEE_LOGIN_ADMIN_NAME', false),
'test_mode' => env("YODLEE_TEST_MODE", false),
'config_name' => env("YODLEE_CONFIG_NAME", false),
], ],
]; ];

View File

@ -85,7 +85,6 @@ class YodleeApiTest extends TestCase
{ {
$yodlee = new Yodlee(); $yodlee = new Yodlee();
$yodlee->setTestMode();
$this->assertNotNull($yodlee); $this->assertNotNull($yodlee);
@ -96,7 +95,6 @@ class YodleeApiTest extends TestCase
{ {
$yodlee = new Yodlee('sbMem62e1e69547bfb1'); $yodlee = new Yodlee('sbMem62e1e69547bfb1');
$yodlee->setTestMode();
$access_token = $yodlee->getAccessToken(); $access_token = $yodlee->getAccessToken();
@ -281,9 +279,7 @@ class YodleeApiTest extends TestCase
public function testGetCategories() public function testGetCategories()
{ {
$yodlee = new Yodlee('sbMem62e1e69547bfb2'); $yodlee = new Yodlee('sbMem62e1e69547bfb2');
$yodlee->setTestMode();
$transactions = $yodlee->getTransactionCategories(); $transactions = $yodlee->getTransactionCategories();
@ -398,10 +394,9 @@ class YodleeApiTest extends TestCase
{ {
$yodlee = new Yodlee('sbMem62e1e69547bfb1'); $yodlee = new Yodlee('sbMem62e1e69547bfb1');
$yodlee->setTestMode();
$accounts = $yodlee->getAccounts(); $accounts = $yodlee->getAccounts();
nlog($accounts);
$this->assertIsArray($accounts); $this->assertIsArray($accounts);
} }
@ -456,7 +451,6 @@ nlog($accounts);
{ {
$yodlee = new Yodlee('sbMem62e1e69547bfb1'); $yodlee = new Yodlee('sbMem62e1e69547bfb1');
$yodlee->setTestMode();
$transactions = $yodlee->getTransactions(['categoryId' => 2, 'fromDate' => '2000-01-01']); $transactions = $yodlee->getTransactions(['categoryId' => 2, 'fromDate' => '2000-01-01']);
@ -464,12 +458,10 @@ nlog($accounts);
} }
public function testGetTransactionsWithParams() public function testGetTransactionsWithParams()
{ {
$yodlee = new Yodlee('sbMem62e1e69547bfb1'); $yodlee = new Yodlee('sbMem62e1e69547bfb1');
$yodlee->setTestMode();
$data = [ $data = [
'basetype' => 'DEBIT', //CREDIT 'basetype' => 'DEBIT', //CREDIT
@ -484,7 +476,4 @@ nlog($accounts);
nlog($accounts); nlog($accounts);
} }
} }