Commit Graph

55 Commits

Author SHA1 Message Date
Dave Shoreman bea4ea3387
Show history selection screen instead of guessing
Removes all the guesswork for requisition renewals, instead opting for
the manual approach of simply redirecting to the form and updating its
handling such that it jumps straight to history selection when needed.

When the institution is preloaded (so we skip country/bank selection)
the cloned element is a country and not the bank so we need to replace
athe flag with its logo, but otherwise the code was all moved as-is.
2024-12-24 03:20:40 +00:00
Dave Shoreman 691478d3e7
Support setting custom Nordigen access duration
If agreements are already available and no custom `access_days` is
passed, it will simply take the first match regardless of duration.

When a new agreement is needed, it defaults to the max supported.
2024-12-23 20:31:31 +00:00
Dave Shoreman 5f75b6a9e1
Attempt to reuse existing agreements
Implements changes from #10410 but using `Arr::first()` rather than a
foreach loop to fix bugs returning invalid or expired agreements.

If an agreement exists with at least the requested `$txDays` then that
is used, otherwise a new one is created with the given parameters. If it
fails, we error out because `createRequisition()` would fail regardless.

Skips accepting EUAs: seems it's done automatically during requisition.
2024-12-23 20:09:52 +00:00
Dave Shoreman 3bac46d83f
Cleanup, add return types, normalise quotes 2024-12-22 17:38:54 +00:00
Dave Shoreman b9464c0c25
Fix error on token-invalid failure when expired
The cache data is set to expire after an hour, at which point the call
to `$request->getCompany()` will fail because it depends internally on
the `company_key` in the response of `getTokenContent()` which is null.

By moving the company *after* the context check, we avoid the exception
but need to manually set lang as there's no context for company data.
2024-12-22 17:38:54 +00:00
Dave Shoreman 88149bc39f
Find old EUA to get tx_days for new agreement
The end user agreement ID isn't stored with the bank integration, but it
*is* returned as part of the error for an expired account which works
perfectly for the case of renewing an expired requisition.

When `tx_days` isn't set in the request (i.e. it's a renewal) we instead
extract the EUA ID from the account error after getting the integration,
then once we have the EUA we're able to restore the old tx_days setting.

Since the BankIntegration query is used in both endpoints, this moves it
to a method with `firstOrFail()` rather than `first()` which also allows
for a cleanup of the integration saving code with try/catch/finally to
make it a little clearer which values apply to both new+existing cases.
2024-12-22 17:38:54 +00:00
Dave Shoreman 74344d1b88
Improve Nordigen error-handling code
All failures boil down to about 3 variations - one with reason/lang, one
that has context defined but no company data, and a full variant that
also fills the company and account keys in the view.

The only other difference is redirect url coming from config when it's
not available in the context, so to simplify things this commit merges
all the failure view responses into one unified `failed` method.
2024-12-22 17:38:54 +00:00
Dave Shoreman 6fde8c8f13
Allow setting number of days of transactions
If e.g. `&tx_days=365` is added to the URL, this will use it to set the
amount of history that's fetched from Nordigen on sync, with basic
safeguards to prevent it being set too low or above the bank's max.
2024-12-22 17:38:54 +00:00
Dave Shoreman fa54ef9830
Nordigen: Use institution max for bank integration
While we set the days in the agreement, how many we fetch when
processing transactions depends on the `from_date` of the bank
integration. We could call `getInstitution($id)` on the API, but
consistency would dictate adding a wrapper in the Nordigen class and
it's already being called within `$nordigen->getAccount()` so it makes
more sense to extract the data in the account transformer instead.

App\Jobs\Bank\ProcessBankTransactionsNordigen also sets a from date, but
that's only used when not set on the bank integration so it can be left
at the Nordigen default of 90 days worth of transaction history.
2024-12-22 17:38:54 +00:00
Dave Shoreman b723c9e16a
Nordigen: Pass custom agreement with max history
In order to change the total days of transactions we can request, a
custom end user agreement is needed. There *are* methods to find
existing agreements, but assuming nothing else breaks it's probably
fairly safe to just go ahead and create one.

If it works, it only runs once... as far as I can tell.
2024-12-22 17:38:50 +00:00
Dave Shoreman 73166f422a
Fix nordigen account failsafe
This check was added at a time when `getAccount` would return `false`
for failures, but at some point it was updated to always return arrays.

This fixes the check to avoid issues like #10396 where the following
line triggers a missing 'id' key error.
2024-12-18 00:05:32 +00:00
Dave Shoreman 365a908b20
Fix ref to wrong type of `$account`
There was a time when `$account` served two purposes depending how far
through the code you got. Commit e349f151 changed that, introducing a
dedicated `$nordigen_account` variable, but it missed some references.

This commit fixes them so they no longer point to the *company* account.
2024-12-17 23:59:28 +00:00
David Bomba 552d596eae Style fixes 2024-11-20 11:15:49 +11:00
David Bomba cccb9de170 nordigen error handling when account not found 2024-11-12 06:27:07 +11:00
Dave Shoreman 6757edf5d1
Trim regional locales to two-letter country codes
GoCardless' Bank Account Data API requires two-letter ISO 639-1 country
codes. IN passes the full locale such as *en_GB* or *pt_BR*, which
causes an "unknown error" when selecting banks in Connect Accounts.

Note: Norwegian will use the Bokmål (`nb`) form over Nynorsk (`nn`).

Fixes #9566
2024-05-31 21:04:51 +01:00
David Bomba f65567a637 Update copyright 2024-04-12 14:15:41 +10:00
David Bomba 40086db271 cs fixer 2024-01-14 15:05:00 +11:00
paulwer a8b8680447 fix related to not ractivating deleted bank_integrations 2024-01-10 15:34:25 +01:00
David Bomba b83669d0b0 minor cleanup for nordigen 2023-12-29 14:19:27 +11:00
David Bomba b69e9a3ae1 Fixes for passing Nordigen locales 2023-12-27 14:05:19 +11:00
David Bomba d0358086fc bank integration cleanup 2023-12-26 14:31:03 +11:00
David Bomba 34067e490f Static Analysis 2023-12-26 10:19:48 +11:00
paulwer d7daca49d4 language is now persistent over whole flow + fixes 2023-12-20 17:58:06 +01:00
paulwer cb311c52f8 cleanups 2023-12-20 16:42:29 +01:00
paulwer c43c85022b reactivate softDeleted Accounts & revoke where deleted_at query
- softDelete, when reconnecting to avoid double transactions
- remove deleted_at query because unnecessary
2023-12-19 08:37:04 +01:00
paulwer 5b4dfe38fe minor cleanup 2023-12-18 16:16:20 +01:00
paulwer e4aa8f72bc some changes related to logging & cleanup 2023-12-18 16:08:41 +01:00
paulwer e4d0c9f901 update deps, fixes & stop processing archived bank_integrations 2023-12-18 15:48:25 +01:00
paulwer 10050d567b translations 2023-12-15 14:45:52 +01:00
paulwer 3735845c44 display occured errors in flow with a view 2023-12-15 13:10:45 +01:00
paulwer dbbde047e9 fixes 2023-12-13 16:57:51 +01:00
paulwer 8ba64bd435 fix spelling 2023-12-13 15:38:37 +01:00
paulwer da6488adac remove credentials on account level + remove ApiException + fixes 2023-12-13 15:37:19 +01:00
paulwer dcdd9112d0 fixes 2023-12-12 07:52:53 +01:00
paulwer 16378d551d fixes 2023-12-11 21:21:42 +01:00
paulwer a364bc24de fix: missing context error 2023-12-11 19:18:32 +01:00
paulwer 3a8bb30425 fixes 2023-12-11 17:16:14 +01:00
paulwer 0593a57e5c fixes 2023-12-11 16:13:26 +01:00
paulwer fab47bd08c introduce ENV-variables for nordigen 2023-12-11 13:23:28 +01:00
paulwer a937f5dcef fixes 2023-12-11 10:40:55 +01:00
paulwer 3229650858 dedicated keys for nordigen 2023-12-11 09:23:35 +01:00
paulwer cd4dbb897f dev-workaround for storing accountId + updates to transaction jobs + local fonts 2023-12-11 09:15:41 +01:00
paulwer f3dfdc4d80 introduce nordigen bank_selection ui 2023-12-09 15:13:00 +01:00
paulwer c138f2f211 rewrite connect/confirm for complete flow usage with only redirects 2023-12-09 09:27:59 +01:00
paulwer e349f1515d minor fixes 2023-12-08 19:05:49 +01:00
paulwer 701e5a9fec renaming again 2023-12-08 18:48:48 +01:00
paulwer 3393ba01aa renaming Request Dtos 2023-12-08 18:46:12 +01:00
paulwer 4d2425d96b feat: connect account 2023-12-08 18:42:06 +01:00
paulwer 9f062cc4f8 revert new table, some changes for endpoints, fixes 2023-12-06 08:27:18 +01:00
paulwer 5616da03c5 feat: refresh & getAccounts 2023-12-05 07:17:07 +01:00