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.
This commit is contained in:
parent
480794bb76
commit
2501ca17c9
|
|
@ -61,14 +61,22 @@ class Nordigen
|
|||
}
|
||||
|
||||
// requisition-section
|
||||
public function createRequisition(string $redirect, array $institution, string $reference, string $userLanguage)
|
||||
{
|
||||
public function createRequisition(
|
||||
string $redirect,
|
||||
array $institution,
|
||||
int $transactionDays,
|
||||
string $reference,
|
||||
string $userLanguage,
|
||||
): array {
|
||||
if ($this->test_mode && $institution['id'] != $this->sandbox_institutionId) {
|
||||
throw new \Exception('invalid institutionId while in test-mode');
|
||||
}
|
||||
|
||||
$txDays = $transactionDays < 30 ? 30 : $transactionDays;
|
||||
$max = $institution['transaction_total_days'];
|
||||
|
||||
$eua = $this->client->endUserAgreement->createEndUserAgreement(
|
||||
maxHistoricalDays: $institution['transaction_total_days'],
|
||||
maxHistoricalDays: $txDays > $max ? $max : $txDays,
|
||||
institutionId: $institution['id'],
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,13 @@ class NordigenController extends BaseController
|
|||
|
||||
// redirect to requisition flow
|
||||
try {
|
||||
$requisition = $nordigen->createRequisition(config('ninja.app_url') . '/nordigen/confirm', $institution, $request->token, $lang);
|
||||
$requisition = $nordigen->createRequisition(
|
||||
config('ninja.app_url') . '/nordigen/confirm',
|
||||
$institution,
|
||||
(int) ($data['tx_days'] ?? 0),
|
||||
$request->token,
|
||||
$lang,
|
||||
);
|
||||
} catch (NordigenException $e) { // TODO: property_exists returns null in these cases... => why => therefore we just get unknown error everytime $responseBody is typeof GuzzleHttp\Psr7\Stream
|
||||
$responseBody = (string) $e->getResponse()->getBody();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue