forked from nemiah/phpFinTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbalance.php
More file actions
28 lines (24 loc) · 1.02 KB
/
balance.php
File metadata and controls
28 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php /** @noinspection PhpUnhandledExceptionInspection */
/**
* SAMPLE - Displays the current balance of all accounts.
*/
// See login.php, it returns a FinTs instance that is already logged in.
/** @var \Fhp\FinTs $fints */
$fints = require_once 'login.php';
$oneAccount = $fints->getAccounts()[0];
$getBalance = \Fhp\Action\GetBalance::create($oneAccount, true);
$fints->execute($getBalance);
if ($getBalance->needsTan()) {
handleStrongAuthentication($getBalance); // See login.php for the implementation.
}
/** @var \Fhp\Segment\SAL\HISAL $hisal */
foreach ($getBalance->getBalances() as $hisal) {
$accNo = $hisal->getAccountInfo()->getAccountNumber();
if ($hisal->getKontoproduktbezeichnung() !== null) {
$accNo .= ' (' . $hisal->getKontoproduktbezeichnung() . ')';
}
$amnt = $hisal->getGebuchterSaldo()->getAmount();
$curr = $hisal->getGebuchterSaldo()->getCurrency();
$date = $hisal->getGebuchterSaldo()->getTimestamp()->format('Y-m-d');
echo "On $accNo you have $amnt $curr as of $date.\n";
}