mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Attempt to refresh account list from auth page
This commit is contained in:
parent
3542e35da0
commit
d6039cec3a
@ -31,6 +31,7 @@ class YodleeController extends BaseController
|
|||||||
|
|
||||||
$company = $request->getCompany();
|
$company = $request->getCompany();
|
||||||
|
|
||||||
|
|
||||||
if($company->account->bank_integration_account_id){
|
if($company->account->bank_integration_account_id){
|
||||||
|
|
||||||
$flow = 'edit';
|
$flow = 'edit';
|
||||||
@ -54,6 +55,9 @@ class YodleeController extends BaseController
|
|||||||
|
|
||||||
$yodlee = new Yodlee($token);
|
$yodlee = new Yodlee($token);
|
||||||
|
|
||||||
|
if($request->has('window_closed') && $request->input("window_closed") == "true")
|
||||||
|
$this->getAccounts($company, $token);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'access_token' => $yodlee->getAccessToken(),
|
'access_token' => $yodlee->getAccessToken(),
|
||||||
'fasttrack_url' => $yodlee->getFastTrackUrl(),
|
'fasttrack_url' => $yodlee->getFastTrackUrl(),
|
||||||
@ -61,10 +65,43 @@ class YodleeController extends BaseController
|
|||||||
'flow' => $flow,
|
'flow' => $flow,
|
||||||
'company' => $company,
|
'company' => $company,
|
||||||
'account' => $company->account,
|
'account' => $company->account,
|
||||||
|
'completed' => $request->has('window_closed') ? true : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('bank.yodlee.auth', $data);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,37 +43,32 @@
|
|||||||
<div class="flex flex-col justify-center items-center mt-10" id="container-fastlink">
|
<div class="flex flex-col justify-center items-center mt-10" id="container-fastlink">
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
@if($account && !$account->isPaid())
|
@if($account && !$account->isPaid())
|
||||||
<div>
|
<div>
|
||||||
<img src="{{ asset('images/invoiceninja-black-logo-2.png') }}"
|
<img src="{{ asset('images/invoiceninja-black-logo-2.png') }}"
|
||||||
class="border-b border-gray-100 h-18 pb-4" alt="Invoice Ninja logo">
|
class="border-b border-gray-100 h-18 pb-4" alt="Invoice Ninja logo">
|
||||||
</div>
|
</div>
|
||||||
@elseif(isset($company) && !is_null($company))
|
@elseif(isset($company) && !is_null($company))
|
||||||
<div>
|
<div>
|
||||||
<img src="{{ $company->present()->logo() }}"
|
<img src="{{ $company->present()->logo() }}"
|
||||||
class="mx-auto border-b border-gray-100 h-18 pb-4" alt="{{ $company->present()->name() }} logo">
|
class="mx-auto border-b border-gray-100 h-18 pb-4" alt="{{ $company->present()->name() }} logo">
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="cta" class="mb-4" x-data="{ open: false }">
|
<div id="cta" class="mb-4" x-data="{ open: false }">
|
||||||
|
|
||||||
<button @click="open = !open" x-show="!open" type="submit" class="button button-primary bg-blue-600 my-4" id="btn-fastlink">{{ ctrans('texts.add_bank_account') }}
|
<button @click="open = !open" x-show="!open" type="submit" class="button button-primary bg-blue-600 my-4" id="btn-fastlink">{{ ctrans('texts.add_bank_account') }}</button>
|
||||||
</button>
|
|
||||||
|
|
||||||
<div x-show="open" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-700 opacity-75 flex flex-col items-center justify-center">
|
<div x-show="open" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-700 opacity-75 flex flex-col items-center justify-center">
|
||||||
<div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 mb-4"></div>
|
<div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 mb-4"></div>
|
||||||
<h2 class="text-center text-gray text-xl font-semibold">Loading...</h2>
|
<h2 class="text-center text-gray text-xl font-semibold">Loading...</h2>
|
||||||
<p class="w-1/3 text-center text-gray">This may take a few seconds, please don't close this page.</p>
|
<p class="w-1/3 text-center text-gray">This may take a few seconds, please don't close this page.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="completed" class="mb-4">
|
<div id="completed" class="mb-4">
|
||||||
<a class="button button-primary bg-blue-600 my-4" href="https://invoicing.co">Return to admin portal.</a>
|
<a class="button button-primary bg-blue-600 my-4" href="{{ config('ninja.app_url') }}">Return to admin portal.</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -84,53 +79,67 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var completed = document.getElementById('completed');
|
var completed = document.getElementById('completed');
|
||||||
completed.style.display = "none"; //block
|
completed.style.display = "none"; //block
|
||||||
|
|
||||||
(function (window) {
|
(function (window) {
|
||||||
//Open FastLink
|
//Open FastLink
|
||||||
var fastlinkBtn = document.getElementById('btn-fastlink');
|
|
||||||
fastlinkBtn.addEventListener(
|
|
||||||
'click',
|
|
||||||
function() {
|
|
||||||
window.fastlink.open({
|
|
||||||
flow: '{{ $flow }}',//flow changes depending on what we are doing sometimes it could be add/edit etc etc
|
|
||||||
fastLinkURL: '{{ $fasttrack_url }}',
|
|
||||||
accessToken: 'Bearer {{ $access_token }}',
|
|
||||||
params: {
|
|
||||||
configName : '{{ $config_name }}'
|
|
||||||
},
|
|
||||||
onSuccess: function (data) {
|
|
||||||
// will be called on success. For list of possible message, refer to onSuccess(data) Method.
|
|
||||||
console.log('success');
|
|
||||||
console.log(data);
|
|
||||||
},
|
|
||||||
onError: function (data) {
|
|
||||||
// will be called on error. For list of possible message, refer to onError(data) Method.
|
|
||||||
console.log('error');
|
|
||||||
|
|
||||||
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('onclose');
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
var completed = document.getElementById('completed');
|
@if($completed)
|
||||||
completed.style.display = "block"; //block
|
|
||||||
},
|
var completed = document.getElementById('completed');
|
||||||
onEvent: function (data) {
|
completed.style.display = "block"; //block
|
||||||
// will be called on intermittent status update.
|
var hideme = document.getElementById('cta');
|
||||||
console.log('on event');
|
hideme.style.display = "none";
|
||||||
var hideme = document.getElementById('cta');
|
|
||||||
hideme.style.display = "none";
|
@endif
|
||||||
console.log(data);
|
|
||||||
}
|
var fastlinkBtn = document.getElementById('btn-fastlink');
|
||||||
|
fastlinkBtn.addEventListener(
|
||||||
|
'click',
|
||||||
|
function() {
|
||||||
|
window.fastlink.open({
|
||||||
|
flow: '{{ $flow }}',//flow changes depending on what we are doing sometimes it could be add/edit etc etc
|
||||||
|
fastLinkURL: '{{ $fasttrack_url }}',
|
||||||
|
accessToken: 'Bearer {{ $access_token }}',
|
||||||
|
params: {
|
||||||
|
configName : '{{ $config_name }}'
|
||||||
},
|
},
|
||||||
'container-fastlink');
|
onSuccess: function (data) {
|
||||||
|
// will be called on success. For list of possible message, refer to onSuccess(data) Method.
|
||||||
|
console.log('success');
|
||||||
|
console.log(data);
|
||||||
|
},
|
||||||
|
onError: function (data) {
|
||||||
|
// will be called on error. For list of possible message, refer to onError(data) Method.
|
||||||
|
console.log('error');
|
||||||
|
|
||||||
|
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('onclose');
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
var completed = document.getElementById('completed');
|
||||||
|
completed.style.display = "block"; //block
|
||||||
|
|
||||||
|
window.location.href = window.location.pathname+"?"+$.param({'window_closed':'true'})
|
||||||
|
|
||||||
|
},
|
||||||
|
onEvent: function (data) {
|
||||||
|
// will be called on intermittent status update.
|
||||||
|
console.log('on event');
|
||||||
|
var hideme = document.getElementById('cta');
|
||||||
|
hideme.style.display = "none";
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
false);
|
'container-fastlink');
|
||||||
}(window));
|
},
|
||||||
|
false);
|
||||||
|
}(window));
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@endpush
|
@endpush
|
Loading…
x
Reference in New Issue
Block a user