pkeidel/banktolaravel

Reads booking informations from an bank account and saves it to a local table in the database

v0.0.4 2017-09-14 17:33 UTC

README

Build Status

What it is

This package create a database table to store all bank bookings/statements. Also a artisan command for importing them directly from your bank is created with php artisan bank:import. New Entries are published as an event you can easily listen to, see Usage for more. This package supports HBCI/FinTS, a german standard for communicating with bank institutes.

Thank you

A ton of thanks to janfoerste/php-fints and mschindler83/fints-hbci-php for providing such a nice library where I could easily put my work on top of it!

Install

First add the composer dependency:

composer require pkeidel/banktolaravel

Then publish and run the migration to create the 'bookings' table:

php artisan vendor:publish --provider="PKeidel\BankToLaravel\Providers\BankToLaravelServiceProvider" --tag=migrations
php artisan migrate

Now add this to a good protected route group:

Route::resource('bookings', '\PKeidel\BankToLaravel\Controllers\BookingsController');

Finally create a task scheduler as described HERE:

$schedule->command('bank:import')->hourly();

Usage

Append these values to your .env file:

# https://www.hbci-zka.de/institute/institut_auswahl.htm (use the PIN/TAN URL)
# The page is in german, so: bank account=Bankleitzahl
FHP_BANK_URL=
FHP_BANK_PORT=
FHP_BANK_CODE=
FHP_ONLINE_BANKING_USE=RNAME=
FHP_ONLINE_BANKING_PIN=

Every time a new Entry is added to the database, an PKeidel\BankToLaravel\Events\NewEntry Event is fired.

In some ServiceProvides boot() function you could simply listen to the events and add some own logic like sending an E-Mail or notify you via some other way.

Event::listen('PKeidel\BankToLaravel\Events\Error', function (Error $entry) {
    echo "Error occured: $entry->exception\n";
});

Event::listen('PKeidel\BankToLaravel\Events\NewEntry', function (NewEntry $entry) {
    Users::where('username', 'admin')->first()->sendViaTelegram(view('telegram.newbankentry', ['entry' => $entry]));
});