1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* SAMPLE - Displays the statement of account for a specific time range and account. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
require '../vendor/autoload.php'; |
9
|
|
|
|
10
|
|
|
use Fhp\FinTs; |
11
|
|
|
use Fhp\Model\StatementOfAccount\Statement; |
12
|
|
|
use Fhp\Model\StatementOfAccount\Transaction; |
13
|
|
|
|
14
|
|
|
define('FHP_BANK_URL', ''); # HBCI / FinTS Url can be found here: https://www.hbci-zka.de/institute/institut_auswahl.htm (use the PIN/TAN URL) |
15
|
|
|
define('FHP_BANK_PORT', 443); # HBCI / FinTS Port can be found here: https://www.hbci-zka.de/institute/institut_auswahl.htm |
16
|
|
|
define('FHP_BANK_CODE', ''); # Your bank code / Bankleitzahl |
17
|
|
|
define('FHP_ONLINE_BANKING_USERNAME', ''); # Your online banking username / alias |
18
|
|
|
define('FHP_ONLINE_BANKING_PIN', ''); # Your online banking PIN (NOT! the pin of your bank card!) |
19
|
|
|
|
20
|
|
|
$fints = new FinTs( |
21
|
|
|
FHP_BANK_URL, |
22
|
|
|
FHP_BANK_PORT, |
23
|
|
|
FHP_BANK_CODE, |
24
|
|
|
FHP_ONLINE_BANKING_USERNAME, |
25
|
|
|
FHP_ONLINE_BANKING_PIN |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
$accounts = $fints->getSEPAAccounts(); |
29
|
|
|
|
30
|
|
|
$oneAccount = $accounts[0]; |
31
|
|
|
$from = new \DateTime('2016-01-01'); |
32
|
|
|
$to = new \DateTime(); |
33
|
|
|
$soa = $fints->getStatementOfAccount($oneAccount, $from, $to); |
34
|
|
|
|
35
|
|
|
foreach ($soa->getStatements() as $statement) { |
36
|
|
|
echo $statement->getDate()->format('Y-m-d') . ': Start Saldo: ' . ($statement->getCreditDebit() == Statement::CD_DEBIT ? '-' : '') . $statement->getStartBalance() . PHP_EOL; |
37
|
|
|
echo 'Transactions:' . PHP_EOL; |
38
|
|
|
echo '=======================================' . PHP_EOL; |
39
|
|
|
foreach ($statement->getTransactions() as $transaction) { |
40
|
|
|
echo 'Amount : ' . ($transaction->getCreditDebit() == Transaction::CD_DEBIT ? '-' : '') . $transaction->getAmount() . PHP_EOL; |
41
|
|
|
echo 'Booking text: ' . $transaction->getBookingText() . PHP_EOL; |
42
|
|
|
echo 'Name : ' . $transaction->getName() . PHP_EOL; |
43
|
|
|
echo 'Description : ' . $transaction->getDescription1() . PHP_EOL; |
44
|
|
|
echo '=======================================' . PHP_EOL . PHP_EOL; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
echo "Found " . count($soa->getStatements()) . ' statements.' . PHP_EOL; |
48
|
|
|
|
49
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.