2022-08-05 06:25:06 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2022-08-05 06:25:06 +02:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2022-08-05 11:05:59 +02:00
|
|
|
use App\Factory\BankIntegrationFactory;
|
2022-11-11 00:13:11 +01:00
|
|
|
use App\Filters\BankIntegrationFilters;
|
2022-08-08 00:26:27 +02:00
|
|
|
use App\Helpers\Bank\Yodlee\Yodlee;
|
2023-12-01 14:30:33 +01:00
|
|
|
use App\Helpers\Bank\Nordigen\Nordigen;
|
2022-08-08 00:26:27 +02:00
|
|
|
use App\Http\Requests\BankIntegration\AdminBankIntegrationRequest;
|
2023-01-22 04:49:15 +01:00
|
|
|
use App\Http\Requests\BankIntegration\BulkBankIntegrationRequest;
|
2022-08-05 11:05:59 +02:00
|
|
|
use App\Http\Requests\BankIntegration\CreateBankIntegrationRequest;
|
|
|
|
use App\Http\Requests\BankIntegration\DestroyBankIntegrationRequest;
|
|
|
|
use App\Http\Requests\BankIntegration\EditBankIntegrationRequest;
|
|
|
|
use App\Http\Requests\BankIntegration\ShowBankIntegrationRequest;
|
|
|
|
use App\Http\Requests\BankIntegration\StoreBankIntegrationRequest;
|
|
|
|
use App\Http\Requests\BankIntegration\UpdateBankIntegrationRequest;
|
2023-12-01 14:30:33 +01:00
|
|
|
use App\Jobs\Bank\ProcessBankTransactionsYodlee;
|
|
|
|
use App\Jobs\Bank\ProcessBankTransactionsNordigen;
|
|
|
|
use App\Models\Account;
|
2022-08-05 11:05:59 +02:00
|
|
|
use App\Models\BankIntegration;
|
2023-12-10 08:18:31 +01:00
|
|
|
use App\Models\User;
|
2022-08-05 11:05:59 +02:00
|
|
|
use App\Repositories\BankIntegrationRepository;
|
|
|
|
use App\Transformers\BankIntegrationTransformer;
|
2023-12-13 15:37:19 +01:00
|
|
|
use App\Utils\Ninja;
|
2022-08-11 09:05:33 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2023-10-26 04:57:44 +02:00
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
use Illuminate\Http\Response;
|
2022-11-09 21:49:45 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2022-08-05 06:25:06 +02:00
|
|
|
|
|
|
|
class BankIntegrationController extends BaseController
|
|
|
|
{
|
2022-08-11 09:05:33 +02:00
|
|
|
use MakesHash;
|
2022-08-11 09:13:40 +02:00
|
|
|
|
2022-08-05 06:25:06 +02:00
|
|
|
protected $entity_type = BankIntegration::class;
|
|
|
|
|
|
|
|
protected $entity_transformer = BankIntegrationTransformer::class;
|
|
|
|
|
2022-08-05 11:05:59 +02:00
|
|
|
protected $bank_integration_repo;
|
|
|
|
|
|
|
|
public function __construct(BankIntegrationRepository $bank_integration_repo)
|
2022-08-05 06:25:06 +02:00
|
|
|
{
|
|
|
|
parent::__construct();
|
2022-08-05 11:05:59 +02:00
|
|
|
|
|
|
|
$this->bank_integration_repo = $bank_integration_repo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-04-27 07:02:52 +02:00
|
|
|
* @param BankIntegrationFilters $filters
|
2023-07-26 01:27:16 +02:00
|
|
|
* @return Response
|
2022-08-05 11:05:59 +02:00
|
|
|
*/
|
2022-11-11 00:13:11 +01:00
|
|
|
public function index(BankIntegrationFilters $filters)
|
2022-08-05 11:05:59 +02:00
|
|
|
{
|
2022-11-11 00:13:11 +01:00
|
|
|
$bank_integrations = BankIntegration::filter($filters);
|
2022-08-05 11:05:59 +02:00
|
|
|
|
|
|
|
return $this->listResponse($bank_integrations);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param ShowBankIntegrationRequest $request
|
|
|
|
* @param BankIntegration $bank_integration
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function show(ShowBankIntegrationRequest $request, BankIntegration $bank_integration)
|
|
|
|
{
|
|
|
|
return $this->itemResponse($bank_integration);
|
2022-08-05 06:25:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-05 11:05:59 +02:00
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param EditBankIntegrationRequest $request
|
|
|
|
* @param BankIntegration $bank_integration
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function edit(EditBankIntegrationRequest $request, BankIntegration $bank_integration)
|
|
|
|
{
|
|
|
|
return $this->itemResponse($bank_integration);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param UpdateBankIntegrationRequest $request
|
|
|
|
* @param BankIntegration $bank_integration
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function update(UpdateBankIntegrationRequest $request, BankIntegration $bank_integration)
|
|
|
|
{
|
|
|
|
//stubs for updating the model
|
|
|
|
$bank_integration = $this->bank_integration_repo->save($request->all(), $bank_integration);
|
|
|
|
|
|
|
|
return $this->itemResponse($bank_integration->fresh());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @param CreateBankIntegrationRequest $request
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function create(CreateBankIntegrationRequest $request)
|
|
|
|
{
|
2023-04-27 05:35:25 +02:00
|
|
|
|
|
|
|
/** @var \App\Models\User $user */
|
|
|
|
$user = auth()->user();
|
|
|
|
|
|
|
|
$bank_integration = BankIntegrationFactory::create($user->company()->id, $user->id, $user->account_id);
|
2022-08-05 11:05:59 +02:00
|
|
|
|
|
|
|
return $this->itemResponse($bank_integration);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
|
|
|
* @param StoreBankIntegrationRequest $request
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function store(StoreBankIntegrationRequest $request)
|
|
|
|
{
|
2023-04-27 05:35:25 +02:00
|
|
|
|
|
|
|
/** @var \App\Models\User $user */
|
|
|
|
$user = auth()->user();
|
|
|
|
|
2022-08-05 11:05:59 +02:00
|
|
|
//stub to store the model
|
2023-04-27 05:35:25 +02:00
|
|
|
$bank_integration = $this->bank_integration_repo->save($request->all(), BankIntegrationFactory::create($user->company()->id, $user->id, $user->account_id));
|
2022-08-05 11:05:59 +02:00
|
|
|
|
|
|
|
return $this->itemResponse($bank_integration);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @param DestroyBankIntegrationRequest $request
|
|
|
|
* @param BankIntegration $bank_integration
|
|
|
|
* @return Response
|
|
|
|
*
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public function destroy(DestroyBankIntegrationRequest $request, BankIntegration $bank_integration)
|
|
|
|
{
|
|
|
|
$this->bank_integration_repo->delete($bank_integration);
|
|
|
|
|
|
|
|
return $this->itemResponse($bank_integration->fresh());
|
|
|
|
}
|
2022-08-08 00:26:27 +02:00
|
|
|
|
2022-08-11 09:05:33 +02:00
|
|
|
|
2022-08-11 09:13:40 +02:00
|
|
|
/**
|
2022-08-11 09:05:33 +02:00
|
|
|
* Perform bulk actions on the list view.
|
|
|
|
*
|
2023-04-28 03:39:41 +02:00
|
|
|
* @return Response
|
2022-08-11 09:05:33 +02:00
|
|
|
*
|
|
|
|
*/
|
2023-01-22 04:49:15 +01:00
|
|
|
public function bulk(BulkBankIntegrationRequest $request)
|
2022-08-11 09:05:33 +02:00
|
|
|
{
|
|
|
|
$action = request()->input('action');
|
|
|
|
|
|
|
|
$ids = request()->input('ids');
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2023-04-28 03:39:41 +02:00
|
|
|
BankIntegration::withTrashed()->whereIn('id', $this->transformKeys($ids))
|
2023-12-10 08:18:31 +01:00
|
|
|
->company()
|
|
|
|
->cursor()
|
|
|
|
->each(function ($bank_integration, $key) use ($action) {
|
|
|
|
$this->bank_integration_repo->{$action}($bank_integration);
|
|
|
|
});
|
2022-08-11 09:05:33 +02:00
|
|
|
|
|
|
|
/* Need to understand which permission are required for the given bulk action ie. view / edit */
|
|
|
|
|
|
|
|
return $this->listResponse(BankIntegration::withTrashed()->whereIn('id', $this->transformKeys($ids))->company());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-08 00:26:27 +02:00
|
|
|
/**
|
2022-08-11 09:13:40 +02:00
|
|
|
* Return the remote list of accounts stored on the third party provider.
|
2022-08-08 00:26:27 +02:00
|
|
|
*
|
2023-04-28 03:39:41 +02:00
|
|
|
* @return JsonResponse
|
2022-08-08 00:26:27 +02:00
|
|
|
*/
|
2022-08-11 06:19:35 +02:00
|
|
|
public function refreshAccounts(AdminBankIntegrationRequest $request)
|
2022-08-08 00:26:27 +02:00
|
|
|
{
|
2023-04-27 05:35:25 +02:00
|
|
|
/** @var \App\Models\User $user */
|
|
|
|
$user = auth()->user();
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2023-04-27 05:35:25 +02:00
|
|
|
$user_account = $user->account;
|
2022-08-08 00:26:27 +02:00
|
|
|
|
2023-12-10 08:18:31 +01:00
|
|
|
$this->refreshAccountsYodlee($user);
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2023-12-10 08:18:31 +01:00
|
|
|
$this->refreshAccountsNordigen($user);
|
|
|
|
|
2024-01-14 05:05:00 +01:00
|
|
|
if (Cache::get("throttle_polling:{$user_account->key}")) {
|
2023-12-13 16:57:51 +01:00
|
|
|
return response()->json(BankIntegration::query()->company(), 200);
|
2024-01-14 05:05:00 +01:00
|
|
|
}
|
2023-12-13 16:57:51 +01:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
// Processing transactions for each bank account
|
2024-01-14 05:05:00 +01:00
|
|
|
if (Ninja::isHosted() && $user->account->bank_integration_account_id) {
|
2023-12-20 18:17:08 +01:00
|
|
|
$user_account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_YODLEE)->each(function ($bank_integration) use ($user_account) {
|
2023-12-24 10:02:45 +01:00
|
|
|
ProcessBankTransactionsYodlee::dispatch($user_account->id, $bank_integration);
|
2023-12-11 09:15:41 +01:00
|
|
|
});
|
2024-01-14 05:05:00 +01:00
|
|
|
}
|
2022-08-08 00:26:27 +02:00
|
|
|
|
2024-01-14 05:05:00 +01:00
|
|
|
if (config('ninja.nordigen.secret_id') && config('ninja.nordigen.secret_key') && (Ninja::isSelfHost() || (Ninja::isHosted() && $user_account->isEnterprisePaidClient()))) {
|
2023-12-20 18:17:08 +01:00
|
|
|
$user_account->bank_integrations->where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->each(function ($bank_integration) {
|
2023-12-13 15:37:19 +01:00
|
|
|
ProcessBankTransactionsNordigen::dispatch($bank_integration);
|
2023-12-11 09:15:41 +01:00
|
|
|
});
|
2024-01-14 05:05:00 +01:00
|
|
|
}
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2023-12-10 08:18:31 +01:00
|
|
|
Cache::put("throttle_polling:{$user_account->key}", true, 300);
|
2023-12-01 14:30:33 +01:00
|
|
|
|
|
|
|
return response()->json(BankIntegration::query()->company(), 200);
|
|
|
|
}
|
|
|
|
|
2023-12-10 08:18:31 +01:00
|
|
|
private function refreshAccountsYodlee(User $user)
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
if (!Ninja::isHosted() || !$user->account->bank_integration_account_id) {
|
2023-12-11 09:15:41 +01:00
|
|
|
return;
|
2024-01-14 05:05:00 +01:00
|
|
|
}
|
2022-08-08 04:46:41 +02:00
|
|
|
|
2023-12-13 16:32:51 +01:00
|
|
|
$yodlee = new Yodlee($user->account->bank_integration_account_id);
|
2022-08-08 04:46:41 +02:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
$accounts = $yodlee->getAccounts();
|
2022-08-08 04:46:41 +02:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
foreach ($accounts as $account) {
|
2023-12-10 08:18:31 +01:00
|
|
|
if ($bi = BankIntegration::withTrashed()->where("integration_type", BankIntegration::INTEGRATION_TYPE_YODLEE)->where('bank_account_id', $account['id'])->where('company_id', $user->company()->id)->first()) {
|
2023-10-26 04:57:44 +02:00
|
|
|
$bi->balance = $account['current_balance'];
|
|
|
|
$bi->currency = $account['account_currency'];
|
|
|
|
$bi->save();
|
|
|
|
} else {
|
2022-08-11 06:19:35 +02:00
|
|
|
$bank_integration = new BankIntegration();
|
2023-04-27 05:35:25 +02:00
|
|
|
$bank_integration->company_id = $user->company()->id;
|
|
|
|
$bank_integration->account_id = $user->account_id;
|
|
|
|
$bank_integration->user_id = $user->id;
|
2022-08-11 06:19:35 +02:00
|
|
|
$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'];
|
2023-10-24 03:50:10 +02:00
|
|
|
$bank_integration->auto_sync = true;
|
2022-11-08 11:48:29 +01:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
$bank_integration->save();
|
2022-08-11 06:19:35 +02:00
|
|
|
}
|
|
|
|
}
|
2023-12-01 14:30:33 +01:00
|
|
|
}
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2023-12-10 08:18:31 +01:00
|
|
|
private function refreshAccountsNordigen(User $user)
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
if (!(config('ninja.nordigen.secret_id') && config('ninja.nordigen.secret_key'))) {
|
2023-12-11 09:15:41 +01:00
|
|
|
return;
|
2024-01-14 05:05:00 +01:00
|
|
|
}
|
2022-11-09 21:49:45 +01:00
|
|
|
|
2023-12-13 15:37:19 +01:00
|
|
|
$nordigen = new Nordigen();
|
2022-11-08 11:48:29 +01:00
|
|
|
|
2023-12-19 08:37:04 +01:00
|
|
|
BankIntegration::where("integration_type", BankIntegration::INTEGRATION_TYPE_NORDIGEN)->whereNotNull('nordigen_account_id')->each(function (BankIntegration $bank_integration) use ($nordigen) {
|
2024-03-26 18:39:46 +01:00
|
|
|
$is_account_active = $nordigen->isAccountActive($bank_integration->nordigen_account_id);
|
2023-12-11 09:23:35 +01:00
|
|
|
$account = $nordigen->getAccount($bank_integration->nordigen_account_id);
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2024-03-26 18:39:46 +01:00
|
|
|
if (!$is_account_active || !$account) {
|
|
|
|
$bank_integration->disabled_upstream = true;
|
2023-12-01 14:30:33 +01:00
|
|
|
$bank_integration->save();
|
2024-03-26 18:39:46 +01:00
|
|
|
|
|
|
|
$nordigen->disabledAccountEmail($bank_integration);
|
2023-12-11 09:15:41 +01:00
|
|
|
return;
|
2023-12-01 14:30:33 +01:00
|
|
|
}
|
2023-12-11 09:15:41 +01:00
|
|
|
|
2023-12-12 07:23:53 +01:00
|
|
|
$bank_integration->disabled_upstream = false;
|
2023-12-11 09:15:41 +01:00
|
|
|
$bank_integration->bank_account_status = $account['account_status'];
|
|
|
|
$bank_integration->balance = $account['current_balance'];
|
|
|
|
$bank_integration->currency = $account['account_currency'];
|
|
|
|
|
|
|
|
$bank_integration->save();
|
|
|
|
});
|
2022-08-11 06:19:35 +02:00
|
|
|
}
|
|
|
|
|
2022-08-11 06:47:08 +02:00
|
|
|
/**
|
2022-08-12 05:41:55 +02:00
|
|
|
* Return the remote list of accounts stored on the third party provider
|
|
|
|
* and update our local cache.
|
2022-08-11 06:47:08 +02:00
|
|
|
*
|
2023-07-26 01:27:16 +02:00
|
|
|
* @return Response | JsonResponse
|
2022-08-11 06:47:08 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-11 06:19:35 +02:00
|
|
|
public function removeAccount(AdminBankIntegrationRequest $request, $acc_id)
|
|
|
|
{
|
2023-04-27 05:35:25 +02:00
|
|
|
/** @var \App\Models\User $user */
|
|
|
|
$user = auth()->user();
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2023-04-27 05:35:25 +02:00
|
|
|
$account = $user->account;
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2023-12-26 04:31:03 +01:00
|
|
|
$bank_integration = BankIntegration::withTrashed()
|
2024-03-26 18:39:46 +01:00
|
|
|
->where('bank_account_id', $acc_id)
|
|
|
|
->orWhere('nordigen_account_id', $acc_id)
|
|
|
|
->company()
|
|
|
|
->firstOrFail();
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2024-01-14 05:05:00 +01:00
|
|
|
if ($bank_integration->integration_type == BankIntegration::INTEGRATION_TYPE_YODLEE) {
|
2023-12-01 14:30:33 +01:00
|
|
|
$this->removeAccountYodlee($account, $bank_integration);
|
2024-01-14 05:05:00 +01:00
|
|
|
}
|
2023-12-04 08:14:52 +01:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
$this->bank_integration_repo->delete($bank_integration);
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
return $this->itemResponse($bank_integration->fresh());
|
|
|
|
}
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2023-12-01 14:30:33 +01:00
|
|
|
private function removeAccountYodlee(Account $account, BankIntegration $bank_integration)
|
|
|
|
{
|
2023-12-13 16:32:51 +01:00
|
|
|
if (!$account->bank_integration_account_id) {
|
2023-12-01 14:30:33 +01:00
|
|
|
return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400);
|
2023-02-16 02:36:09 +01:00
|
|
|
}
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2023-12-13 16:32:51 +01:00
|
|
|
$yodlee = new Yodlee($account->bank_integration_account_id);
|
2023-12-01 14:30:33 +01:00
|
|
|
$yodlee->deleteAccount($bank_integration->bank_account_id);
|
|
|
|
}
|
2022-08-11 06:19:35 +02:00
|
|
|
|
2022-08-12 05:41:55 +02:00
|
|
|
/**
|
|
|
|
* Return the remote list of accounts stored on the third party provider
|
|
|
|
* and update our local cache.
|
|
|
|
*
|
2023-04-28 03:39:41 +02:00
|
|
|
* @return JsonResponse
|
2022-08-12 05:41:55 +02:00
|
|
|
*
|
|
|
|
*/
|
2022-08-08 04:46:41 +02:00
|
|
|
public function getTransactions(AdminBankIntegrationRequest $request)
|
|
|
|
{
|
2023-12-13 15:37:19 +01:00
|
|
|
/** @var \App\Models\Account $account */
|
2023-12-25 08:16:36 +01:00
|
|
|
$account = auth()->user()->account;
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2023-12-13 15:37:19 +01:00
|
|
|
if (Ninja::isHosted() && $account->isPaid() && $account->plan == 'enterprise') {
|
2023-12-19 08:37:04 +01:00
|
|
|
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->cursor()->each(function ($bank_integration) use ($account) {
|
2023-12-24 10:02:45 +01:00
|
|
|
(new ProcessBankTransactionsYodlee($account->id, $bank_integration))->handle();
|
2023-12-13 15:37:19 +01:00
|
|
|
});
|
|
|
|
}
|
2023-12-01 14:30:33 +01:00
|
|
|
|
2023-12-13 15:38:37 +01:00
|
|
|
if (config("ninja.nordigen.secret_id") && config("ninja.nordigen.secret_key") && (Ninja::isSelfHost() || (Ninja::isHosted() && $account->isPaid() && $account->plan == 'enterprise'))) {
|
2023-12-19 08:37:04 +01:00
|
|
|
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->cursor()->each(function ($bank_integration) {
|
2023-12-13 15:37:19 +01:00
|
|
|
(new ProcessBankTransactionsNordigen($bank_integration))->handle();
|
|
|
|
});
|
|
|
|
}
|
2022-08-08 11:07:35 +02:00
|
|
|
|
2022-08-12 05:41:55 +02:00
|
|
|
return response()->json(['message' => 'Fetching transactions....'], 200);
|
2022-08-08 00:26:27 +02:00
|
|
|
}
|
2023-12-01 14:30:33 +01:00
|
|
|
}
|