Yodlee init

This commit is contained in:
David Bomba 2022-07-28 14:09:13 +10:00
parent 717a34aa99
commit f6821e9fcc
10 changed files with 227 additions and 6 deletions

View File

@ -0,0 +1,17 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Helpers\Bank;
interface BankExpenseInterface
{
}

View File

@ -0,0 +1,17 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Helpers\Bank;
interface BankRevenueInterface
{
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Helpers\Yodlee;
class Yodlee
{
public function getAccessToken()
{
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Controllers\Bank;
use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;
class YodleeController extends BaseController
{
public function auth(Request $request)
{
$yodlee = new Yodlee();
$data = [
'access_token' => $yodlee->getAccessToken()
];
return view('bank.yodlee.auth', $data);
}
}

View File

@ -105,7 +105,7 @@ class ImportController extends Controller
public function import(ImportRequest $request)
{
$data = $request->all();
nlog($data);
if (empty($data['hash'])) {
// Create a reference
$data['hash'] = $hash = Str::random(32);

View File

@ -35,9 +35,9 @@ class QueryLogging
{
// Enable query logging for development
if (! Ninja::isHosted() || ! config('beacon.enabled')) {
return $next($request);
}
// if (! Ninja::isHosted() || ! config('beacon.enabled')) {
// return $next($request);
// }
$timeStart = microtime(true);
DB::enableQueryLog();
@ -52,6 +52,7 @@ class QueryLogging
nlog("Query count = {$count}");
nlog($queries);
nlog($request->url());
if ($count > 175) {
nlog("Query count = {$count}");

View File

@ -0,0 +1,70 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Requests\Yodlee;
use App\Http\Requests\Request;
use App\Libraries\MultiDB;
use App\Models\Company;
use App\Models\User;
use Illuminate\Support\Facades\Cache;
class YodleeAuthRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [];
}
public function getTokenContent()
{
if ($this->state) {
$this->token = $this->state;
}
$data = Cache::get($this->token);
return $data;
}
public function getContact()
{
MultiDB::findAndSetDbByCompanyKey($this->getTokenContent()['company_key']);
return User::findOrFail($this->getTokenContent()['user_id']);
}
public function getCompany()
{
MultiDB::findAndSetDbByCompanyKey($this->getTokenContent()['company_key']);
return Company::where('company_key', $this->getTokenContent()['company_key'])->firstOrFail();
}
}

View File

@ -142,7 +142,7 @@ class BaseRepository
$invitation_class = sprintf('App\\Models\\%sInvitation', $resource);
$invitation = $invitation_class::where('key', $invitation['key'])->first();
$invitation = $invitation_class::with('company')->where('key', $invitation['key'])->first();
return $invitation;
}
@ -176,7 +176,7 @@ class BaseRepository
if(array_key_exists('client_id', $data))
$model->client_id = $data['client_id'];
$client = Client::where('id', $model->client_id)->withTrashed()->firstOrFail();
$client = Client::with('group_settings')->where('id', $model->client_id)->withTrashed()->firstOrFail();
$state = [];

View File

@ -0,0 +1,58 @@
@extends('layouts.ninja')
@section('meta_title', ctrans('texts.new_bank_account'))
@push('head')
<script type='text/javascript' src='https://cdn.yodlee.com/fastlink/v4/initialize.js'></script>
@endpush
@section('body')
<div id="container-fastlink">
<div style="text-align: center;">
<input type="submit" id="btn-fastlink" value="Link an Account">
</div>
</div>
@endsection
@push('footer')
<script>
(function (window) {
//Open FastLink
var fastlinkBtn = document.getElementById('btn-fastlink');
fastlinkBtn.addEventListener(
'click',
function() {
window.fastlink.open({
fastLinkURL: 'https://fl4.sandbox.yodlee.com/authenticate/restserver/fastlink',
accessToken: 'Bearer {{ $access_token }}',
params: {
configName : '<config-name-from-config-tool>'
},
onSuccess: function (data) {
// will be called on success. For list of possible message, refer to onSuccess(data) Method.
console.log(data);
},
onError: function (data) {
// will be called on error. For list of possible message, refer to onError(data) Method.
console.log(data);
},
onClose: function (data) {
// will be called called to close FastLink. For list of possible message, refer to onClose(data) Method.
console.log(data);
},
onEvent: function (data) {
// will be called on intermittent status update.
console.log(data);
}
},
'container-fastlink');
},
false);
}(window));
</script>
@endpush

View File

@ -3,6 +3,7 @@
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\Bank\YodleeController;
use App\Http\Controllers\BaseController;
use App\Http\Controllers\ClientPortal\ApplePayDomainController;
use App\Http\Controllers\Gateways\Checkout3dsController;
@ -52,6 +53,8 @@ Route::middleware('url_db')->group(function () {
Route::get('stripe/signup/{token}', [StripeConnectController::class, 'initialize'])->name('stripe_connect.initialization');
Route::get('stripe/completed', [StripeConnectController::class, 'completed'])->name('stripe_connect.return');
Route::get('yodlee/onboard/{token}', [YodleeController::class, 'auth'])->name('yodlee.auth');
Route::get('checkout/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', [Checkout3dsController::class, 'index'])->middleware('domain_db')->name('checkout.3ds_redirect');
Route::get('mollie/3ds_redirect/{company_key}/{company_gateway_id}/{hash}', [Mollie3dsController::class, 'index'])->middleware('domain_db')->name('mollie.3ds_redirect');
Route::get('gocardless/ibp_redirect/{company_key}/{company_gateway_id}/{hash}', [GoCardlessController::class, 'ibpRedirect'])->middleware('domain_db')->name('gocardless.ibp_redirect');