Code Monkey home page Code Monkey logo

fints-hbci-php's Introduction

FinTS HBCI PHP

Build Status Latest Stable Version Scrutinizer Code Quality Monthly Downloads License

A PHP library implementing the basics of the FinTS / HBCI protocol. It can be used to fetch the balance of connected bank accounts and for fetching bank statements of accounts.

Getting Started

Install via composer:

composer require mschindler83/fints-hbci-php

How to use it

You can have a look at the "Samples" folder in this repository. Just fill in the required data beginning from line 13 to 17 and run the script.

You can find the server information of your bank here: https://www.hbci-zka.de/institute/institut_auswahl.htm

Contribute

Bank compatibility

This library can only work stable with YOUR help! As I'm very limited in testing different banks it would be good to get some feedback from you all. Feel free to create PR's for the COMPATIBILITY.md file where you can update the list of working banks.

Code Style

If you plan to contribute to this library, please ensure that you stick with the PSR coding rules as close as you can (At least PSR-0 to PSR-4). You can find the PHP Standard Recommendations here

Have fun!

Looking for a PRO Version which is capable of doing transactions? Checkout http://fints-hbci-php.markus-schindler.de/pro.html

fints-hbci-php's People

Contributors

acmngmbh avatar andrenam avatar chrishenschel avatar chrisribal avatar chubidu avatar dsentker avatar funbug avatar gummibeer avatar jankal avatar kersten avatar larsgrau avatar metabor avatar meyway avatar mgrundkoetter avatar movabo avatar mschindler83 avatar napsio avatar nemiah avatar nogrod avatar philipp91 avatar promarcel avatar proudcommerce avatar psuet avatar rentmynick avatar scrutinizer-auto-fixer avatar sebastianleuters avatar sebwalk avatar simonhoenscheid avatar simontank avatar zigman79 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fints-hbci-php's Issues

@@ in data fields

What is the reason that I receive something like that as name by a transaction:

Wellfa@@irs GmbH
Martina @@Vermot-Petit-Outhenin
....

the same @@ occurs within the account_number and also in purpose, but it does not occur in each and every transaction.

i could cut off these both at-symbols, but I wonder where they come from?

Fetch Saldo from non SEPA Account

Hi is it possible to fetch the Saldo from a Creditcard in my Bankaccount ? I use Postbank i get the Saldo from the Sepa Accounts but if i try on the "VISA Card Classic" i get an Errormessage "Fhp\FinTs::getSaldo() must be an instance of Fhp\Model\SEPAAccount"

thanks for help

netbank AG not working - Uncaught Fhp\Dialog\Exception\FailedRequestException: Request Failed: Unknown error

PHP Fatal error: Uncaught Fhp\Dialog\Exception\FailedRequestException: Request Failed: Unknown error in /Users/dsippel/code/fints-hbci-php/lib/Fhp/Dialog/Dialog.php:129 Stack trace: #0 /Users/dsippel/code/fints-hbci-php/lib/Fhp/FinTs.php(135): Fhp\Dialog\Dialog->sendMessage(Object(Fhp\Message\Message)) #1 /Users/dsippel/code/fints-hbci-php/Samples/statement_of_account.php(28): Fhp\FinTs->getSEPAAccounts() #2 {main} thrown in /Users/dsippel/code/fints-hbci-php/lib/Fhp/Dialog/Dialog.php on line 129

Error response contains:
HIRMG:3:2+9050::Die Nachricht enthält Fehler.+9800::Dialog abgebrochen+9110::Ungültige Auftragsnachricht?: Unbekannter Aufbau.

It is the 4th response coming from FinTS server in this statement_of_account.php run.

Best,
Daniel

Transaction id

Thank you for this awesome library!

I was wondering if there is a unique key or something to identify a transaction?

Background: I would like to write all transactions of a bank account into a mysql database and I want to check, if a transaction already exists in the database. The best solution would be, if each transaction has something like an ID so I could check if this ID already exists in my database.

Thank's in advance.

FinTS registration data

Beginning 2019-08-01 all finTS dialog init requests need to include fints registered product name and version as institutes will no longer accept connections from unregistered products or libs/kernels. See fints.org for more details.
This functionality is urgently needed.

Commerzbank Compatibility

Hi!

First, thank you for providing such a great package! It looks stable and solid.

Second, how did Commerzbank make it one the compatibility list? It seems they don't support any access with Pin/Tan and they don't provide any Pin/Tan-Url @ https://www.hbci-zka.de/institute/institut_auswahl.htm. Do I miss something here or is Commerzbank not accessible?

I tried accessing Commerzbank anyway using hbci.commerbank.de and fints.commerzbank.de since some users said Commerzbank would just not offer access officially, but I had no success. Afterwards I talked to their customer service, confirming that they don't provide Pin/Tan Access.

Does anyone have different experience?

Thank you!

Doesn't work with PHP 5.3

The composer.json says this package requires PHP >= 5.3.2, but it can't work at all with PHP 5.3.

In lib/Fhp/Segment/AbstractSegment.php, you use the short array syntax which was only introduced in PHP 5.4.

If this is the only PHP 5.3 compatibility issue, I'd recommend not using the short array syntax. If there are other issues, it's probably easier to just incrase the minimum required version to 5.4.x in composer.json.

Error with 60M: instead 60F:

When 60M instead 60M in start balance string, error "unknown index 'start_balance'". And as result booking date of transaction is showing as actual date.

To correct the error string
} elseif (0 === strpos($day[$i], '60F:')) {
must be replaced with
} elseif (0 === strpos($day[$i], '60F:')||0 === strpos($day[$i], '60M:')) {

Missing 2. Login ("Kunden-ID")

A lot of banks use not only a login (="Benutzerkennung") + PIN, but have a kind of second loginname (="Kunden-ID"). One example is akf24-bank.

Here is a list of banks

Could this be implemented? If not - could you give a hint where this should be done?

Thanks and best regards!

Request Failed: Die Nachricht enthält Fehler. (TRE) 9050

Thank you for creating this great project!

I'm using the current fints-hbci-php library and got an Request Failed: Die Nachricht enthält Fehler. (TRE) 9050 error when my bank account has a lot of transactions by calling getStatementOfAccount(). This is because of touchdowns, which the result has. If I comment out line 179 in Fhp/FinTs.php, then the error is gone (= no touchdowns). I have one touchdown when the error occurs:

array(1) { ["HKKAZ"]=> string(32) "20171212000011+00000096717,81F V" }

So it seems that there is an error in the message, when the touchdown is added. I compared the normal message and the message of the touchdown:

Normal message:

HNSHK:2:4+PIN:2+942+*+1+1+1::*+1+1:20171227:102020+1:999:1+6:10:16+280:*:*:S:0:0'HKKAZ:3:7+*:*:*::280:*+N+20161227+20171227++'HNSHA:4:2+*++*

Touchdown message:

HNSHK:2:4+PIN:2+942+*+1+1+1::*+1+1:20171227:102021+1:999:1+6:10:16+280:*:*:S:0:0'HKKAZ:3:7+*:*:*::280:*+N+20161227+20171227++20171212000011+00000096717,81F

Is there maybe a part in the message missing?

Do you need more information?

Thank you and best!

Parsing of the transaction description: Missing information

Hi @mschindler83,

first of all: Great work! I really love this tool.

I used it with comdirect bank and found an issue with the MT940-parser. I some cases, the reponse contains a divider-string within the description section, although it is still the same transaction. As a result there are parts of the name and/or description missing. Here an example:

RAW-Response (divided and personal information taken out):

Array
(
[0] =>
[1] => 20:MT940-1701250150
[2] => 21:NONREF
[3] => 25:20041144/418311700EUR
[4] => 28C:0/1
[5] => 60F:C170123EUR1921,44
[6] => 61:1701230123DR139,63NMSCNONREF//POS 3393590253
[7] => 86:820?20ÃœBERTRAG/ÃœBERWEISUNG?21RECHNUNGSNR. 17/27?22END-TO-END-REF.
[8] => ?23NICHT ANGEGEBEN?24Ref. J9217021C1831775/2?30GENODEF1HTR?31DExxxxxxxxxxx?32DR. MEIER
[9] => 61:1701230123DR69,58NMSCNONREF//POS 3394043541
[10] => 62M:C170124EUR1199,64
)

The information from index 8 is completely lost, as the parser expects it to be part of index 7.

My workaround is as follows:

MT940.php:

protected function parseToArray()
    {
....
	$transaction = substr($day[$i], 3);
	$description = substr($day[$i + 1], 3);
	//WORKAROUND:
	if (substr($day[$i+2],0,1)=="?" && substr($day[$i+2],2,1)!=":") {
	    	//add missing line
	    	$description.=$day[$i+2];
	}

As I'm not a php-expert, I'm pretty sure that you can find a much more flexible and elegant solutions for this issue. I just wanted to show my workaround for better unterstanding. Also I'm not aware about problems which could arise from this code, when using it with other banks.

Thanks and best regards!

Edit:
It's even worse. The parser has a problem with the divider-string that comdirect returns. Comdirect is sometimes sending "\r\n" in the middle of a description. If then a "-" is accidently right behind it (as it belongs to the description), the parser threats it as a new transaction.

Nord/LB Hannover / BLSK not working, Response with status code 403

Hi,

i tested the API with a Nord-LB/BLSK account.
I used the following FinTS-URL:
https://banking-ni3.s-fints-pt-ni.de

I don't know if this url is correct, as i have no access to the mentioned list (https://www.hbci-zka.de/institute/institut_auswahl.htm).

Here is the output:

denno@backup:~/hbci-test/vendor/mschindler83/fints-hbci-php/Samples$ php saldo.php
PHP Fatal error: Uncaught Fhp\Adapter\Exception\CurlException: Bad response with status code 403 in /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/lib/Fhp/Adapter/Curl.php:91
Stack trace:
0 /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/lib/Fhp/Connection.php(36): Fhp\Adapter\Curl->send(Object(Fhp\Message\Message))
1 /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php(121): Fhp\Connection->send(Object(Fhp\Message\Message))
2 /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php(325): Fhp\Dialog\Dialog->sendMessage(Object(Fhp\Message\Message))
3 /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/lib/Fhp/FinTs.php(126): Fhp\Dialog\Dialog->syncDialog()
4 /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/Samples/saldo.php(27): Fhp\FinTs->getSEPAAccounts()
5 {main}
thrown in /home/denno/hbci-test/vendor/mschindler83/fints-hbci-php/lib/Fhp/Adapter/Curl.php on line 91

Usage of keys

It would be nice if public/private keys are useable with this library. Some banks (like Commerzbank) require them.

Parse MT940 loses data when new line ist between code-characters

166?00GUTSCHRIFT?109251?20SVWZ+Rechnung xxx?30DEUTDEDB276?3 1DE1127xxxxx40011xxxxxx?32Testfirma GmbH

This is the description in the MT940 Class as it enters the function protected function parseDescription($descr)

As you see, after the BIC the code for accountnumber is splitted by a newline: xxxx?3[new line]1
So the parser can't parse the accountnumber and it's displayed as empty.

I've added the following to line 155 ofMT940.php

//search for newlines in codes from 10-63 and remove them foreach($prepared as $key => $value){ $keystring = (string) $key; if(strlen ($keystring) == 2){ $first = substr($keystring,0,1); $last = substr($keystring,-1,1); $descr = str_replace("$first\r\n$last", "$first$last", $descr); } }
This will remove the newlines in all codes with two digits from 10 to 63.
As I'm not a php expert, this code is working for me and i'd like know wether it is suitable!

Verarbeitung Login/Benutzername fehlerhaft

Hallo,

wenn der Loginname/Benutzername eine Emailadresse ist, führt das "@" Zeichen darin zu einem Fehler. Es muss durch "?@" ersetzt werden, bevor die Message zum Bankserver geschickt wird.

Wirklich grossen Respekt, die Library ist eine ausserordentlich gute Leistung!

Vielen Dank!

Micha

Special Characters are not Invalidated Before Transmission

My bank sometimes issues dialog ids starting with a + sign.

The dialog id in the bank's response then looks like this:

HNHBK: ... +?+ABCDEFGHIJK ... (Bank -> fints-hbci-php)

As you can see, the + is escaped (invalidated) with a prefix ? in the message from the bank.
However, once this id gets used by fints-hbci-php in the next message, it is not properly escaped.

Therefore, two consecutive + signs occur in the message which gets rejected by the bank:

HNHBK: ... ++ABCDEFGHIJK ... (fints-hbci-php -> Bank)

when it should send:

HNHBK: ... +?+ABCDEFGHIJK ... (fints-hbci-php -> Bank)

I have fixed this on my end in the Dialog.php during the initial processing of the dialog id.

This is obviously not the proper place to put this fix, since it might also be relevant for other message elements.
When I tried a simple fix in the AbstractSegment.php I broke some parts because I apparently also escaped + signs that I should not have, but I currently have no time for a deeper investigation.

Script not giving any ouput

I followed the readme, installed the script using composer, modified lines 13-17 like:

define('FHP_BANK_URL', 'https://hbci-pintan-he.s-hbci.de/PinTanServlet');
define('FHP_BANK_PORT', 443); 
define('FHP_BANK_CODE', '50650023');
define('FHP_ONLINE_BANKING_USERNAME', 'online banking user name');
define('FHP_ONLINE_BANKING_PIN', 'online banking password');  

and ran the script. It loads very long and gave no output.
I'm running the script on my local host with active internet connection.

PSD2 / SCA

"Die Nachricht enthält Fehler.+9075::Starke Kundenauthentifizierung notwendig.+9800::Dialog abgebrochen+9340::Auftrag abgelehnt.’HNSHA:4:2+9144772’’HNHBS:5:1+1"

@mschindler83 Hast du eine Idee wie man deine Library mit PSD2/SCA zum Laufen bekommt? Ist hier eine Anpassung deinerseits angedacht?

Transactiondate wrong if valuta does not meet statement date.

Hi,

currently the parser does not parse the transactiondate from rawData which leads to wrong Transactiondates, if valutadate is different from the date of the Statement.

lib/Fhp/Response/GetStatementOfAccount.php (Line 70)

This simply sets the date to the same date as the statement, which could be terribly wrong.

Example from rawData:
Statement:
:60F:C160808

Transaction:
:61:1608090809CR000000000001,00N033NONREF//000000
:86:082?00Test?10?20ZWECK?30xxxxxxxx?31DExxxxxxxxxxxxxxxxxxx?32Payee

Regards

Michael

No available TAN mechanisms leads to error

In my case, the bank account at the Volksbank Wolfenbüttel had no active TAN mechanisms due to security reasons, which leads to an error in the INIT Message saying the message is missing one of the mandatory fields.

I found the error to be in building the message:

if (isset($options[static::OPT_PINTAN_MECH])) {
    if (!in_array('999', $this->options[static::OPT_PINTAN_MECH])) {
        $this->profileVersion = SecurityProfile::PROFILE_VERSION_2;
        $this->securityFunction = $this->options[static::OPT_PINTAN_MECH][0];
    }
}

In my case, the $options[static::OPT_PINTAN_MECH] array was empty, so there is no $this->options[static::OPT_PINTAN_MECH][0] to use instead. I just had to check additionally for an empty array and my script worked:

if (isset($options[static::OPT_PINTAN_MECH]) && !empty($this->options[static::OPT_PINTAN_MECH])) {
    if (!in_array('999', $this->options[static::OPT_PINTAN_MECH])) {
        $this->profileVersion = SecurityProfile::PROFILE_VERSION_2;
        $this->securityFunction = $this->options[static::OPT_PINTAN_MECH][0];
    }
}

Hope this helps somebody with the same problem.

how to detect uniqueness

Hello
the passed statement information do not include any unique identifier.
I want to store the information in an MySQL table. But how can I make sure not to store the same statement over and over again when calling the HBCI server?
Right now only the date offers a bit of uniqueness. But unfortunately the time is not given.
Juergen

SSL certificate error

My connection to the servers of GLS Bank and Berliner Sparkasse was working, but since a few days I m getting this errors:

An uncaught Exception was encountered
Type: Fhp\Adapter\Exception\CurlException
Message: Failed connection to https://hbci11.fiducia.de/cgi-bin/hbciservlet: SSL certificate problem: unable to get local issuer certificate
Filename: [..]\vendor\mschindler83\fints-hbci-php\lib\Fhp\Adapter\Curl.php
Line Number: 80

An uncaught Exception was encountered
Type: Fhp\Adapter\Exception\CurlException
Message: Failed connection to https://hbci-pintan.gad.de/cgi-bin/hbciservlet : SSL certificate problem: self signed certificate in certificate chain
Filename: [..]\vendor\mschindler83\fints-hbci-php\lib\Fhp\Adapter\Curl.php
Line Number: 80

Any ideas?

Uncaught Exception: Could not determine system id

I'm trying to connect to Deutsche Kreditbank Berlin (DKB) AG which is stated as compatible in your compatibility.md

According to DKB website the host address is banking-dkb.s-fints-pt-dkb.de/fints30 (Port 443).

As far as I understand, the connection is established, but I do not understand what the error is actually telling me

Can you help?

Only getting limited Number of Statements

Hi,
it could be that the bank is not providing more statements over the FINTS/HBCI link. But i can't find any information anywhere about this "limitation".

BBBank (VR-Bank Verbund) gives only 60 statements?? Is there any more information about this kind of limitations??

Transaction date is not retrieved correctly

Hello everybody!

My code so far:

<?php

require 'vendor/autoload.php';

use Fhp\FinTs;
use Fhp\Model\StatementOfAccount\Statement;
use Fhp\Model\StatementOfAccount\Transaction;

$fints = new FinTs(
    URL,
    PORT,
    CODE,
    USERNAME,
    PIN
);

$accounts = $fints->getSEPAAccounts();

$oneAccount = $accounts[0];

$from = new \DateTime('2016-01-01');
$to   = new \DateTime();

$soa = $fints->getStatementOfAccount($oneAccount, $from, $to);

foreach ($soa->getStatements() as $statement) {
    echo $statement->getDate()->format('Y-m-d') . ': Start Saldo: ' . ($statement->getCreditDebit() == Statement::CD_DEBIT ? '-' : '') . $statement->getStartBalance() . PHP_EOL;
    echo 'Transactions:' . PHP_EOL;
    echo '=======================================' . PHP_EOL;
    foreach ($statement->getTransactions() as $transaction) {
        echo 'Date        : ' . $transaction->getDate()->format('Y-m-d') . PHP_EOL;
        echo 'Amount      : ' . ($transaction->getCreditDebit() == Statement::CD_DEBIT ? '-' : '') . $transaction->getAmount() . PHP_EOL;
        echo 'Booking text: ' . $transaction->getBookingText() . PHP_EOL;
        echo 'Name        : ' . $transaction->getName() . PHP_EOL;
        echo 'Description : ' . $transaction->getDescription1() . PHP_EOL;
        echo '=======================================' . PHP_EOL . PHP_EOL;
    }
}
echo "Found " . count($soa->getStatements()) . ' statements.' . PHP_EOL;

Output:

2016-01-01: Start Saldo: 0
Transactions:
=======================================
Date        : 2016-01-01
Amount      : 43.56
Booking text: Gutschrift
Name        : Name
Description : Description
=======================================

Date        : 2016-01-01
Amount      : -43.56
Booking text: Überweisung
Name        : Name
Description : Description
=======================================

Date        : 2016-01-01
Amount      : 150
Booking text: Gutschrift
Name        : Name
Description : Description
=======================================

Found 1 statements.

The problem:
The date value of the transaction always equals the supplied $from date.

I'm not sure if this is a problem with my code or the library. I tried it with the german bank ING-Diba.

How can I get the "real" transaction date?

Thank you for reading this far!

Undefined offset in GetSaldo.php line 49

Hi,

many thanks for your great work. I have a problem receiving the saldo of a business account.

The problem seems to be an extra field in the response fields. Here is an example of what I receive:

Private Account:
HISAL:5:5:3+111111111::280:25050180+GiroBest+EUR+C:9999,99:EUR:20161018+C:0,:EUR:20161018+0,:EUR+9999,99,:EUR

Business Account:
HISAL:5:5:3+111111111::280:25050180+GiroBusiness?++EUR+C:9999,99:EUR:20161018+C:0,:EUR:20161018+0,:EUR+9999,99:EUR

Do u know why the business account puts in an extra field after the name? And why there is a question mark?

image

In the online banking this is not shown.

GLS getStatement -> Request Failed: Die Nachricht enthält Fehler

Hi,
I tried to get the statement from a GLS Account, but it throws an exception(ING-Diba works fine). I like to fix it, but I have no idea, wheres the specification for the messages.

PHP 7.0.22-0ubuntu0.16.04.1 Development Server started at Mon Nov 27 10:17:21 2017
Listening on http://localhost:8082
Document root is /home/user/NetBeansProjects/bankcheck
Press Ctrl-C to quit.
[Mon Nov 27 10:17:31 2017] PHP Fatal error: Uncaught Fhp\Dialog\Exception\FailedRequestException: Request Failed: Die Nachricht enthält Fehler. (TRE) in /home/user/NetBeansProjects/bankcheck/vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php:129
Stack trace:
#0 /home/user/NetBeansProjects/bankcheck/vendor/mschindler83/fints-hbci-php/lib/Fhp/FinTs.php(194): Fhp\Dialog\Dialog->sendMessage(Object(Fhp\Message\Message))
#1 /home/user/NetBeansProjects/bankcheck/index.php(45): Fhp\FinTs->getStatementOfAccount(Object(Fhp\Model\SEPAAccount), Object(DateTime), Object(DateTime))
#2 {main}
thrown in /home/user/NetBeansProjects/bankcheck/vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php on line 129
[Mon Nov 27 10:17:31 2017] 127.0.0.1:53440 [200]: / - Uncaught Fhp\Dialog\Exception\FailedRequestException: Request Failed: Die Nachricht enthält Fehler. (TRE) in /home/user/NetBeansProjects/bankcheck/vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php:129
Stack trace:
#0 /home/user/NetBeansProjects/bankcheck/vendor/mschindler83/fints-hbci-php/lib/Fhp/FinTs.php(194): Fhp\Dialog\Dialog->sendMessage(Object(Fhp\Message\Message))
#1 /home/user/NetBeansProjects/bankcheck/index.php(45): Fhp\FinTs->getStatementOfAccount(Object(Fhp\Model\SEPAAccount), Object(DateTime), Object(DateTime))
#2 {main}
thrown in /home/user/NetBeansProjects/bankcheck/vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php on line 129

Thank you for this library, kind regards Tanna

Parsing of the transaction description (SVZW, and other fields)

First of all: thank you for this great project, I have been looking for something like this for several years!

With my bank the description field of (some) transactions look like this:
EREF+...MREF+...CRED+...SVWZ+...

I would like to parse this data to extract the actual "Verwendungszweck" (after SVZW+) and the other fields. Since your MT940 parser merges fields 20 to 29 without any separator this becomes more difficult as necessary. As a workaround I added newlines: clorch/fints-hbci-php@2d27ba3

Nevertheless, I do not think this is the best or most elegant solution. Is there another possibility to access the raw field data? I am not that familiar with the world of banking data formats but maybe it is a good idea to add the parser for these fields to the library?

bookingDate is off by one year in some cases

The bookingDate can be off by one year if the valuta date (month part) is earlier than the booking date.

The error is located in MT940.php:126

$year = substr($transaction, 0, 2);
$valutaDate = $this->getDate($year . substr($transaction, 2, 4));

$bookingDate = substr($transaction, 6, 4);
if (preg_match('/^\d{4}$/', $bookingDate)) {
	// if valuta date is earlier than booking date, then it must be in the new year.
	$year = substr($transaction, 2, 2) < substr($transaction, 6, 2) ? --$year : $year;
	$bookingDate = $this->getDate($year . $bookingDate);
}

The relevant input data to reproduce the error looks like this.

:61:1604300502DR100,00N032NONREF
:86:106?00AUSZAHLUNG?109200?20SVWZ+2016-04-30T06.07.39 Ka?21rte1 

The assumption that the valuta date cant be earlier than the booking date is wrong. (See comment above)
An easy way would be to calculate both dates (same year and previous year) and take the date with the least difference to the valuta date.

I don't know whether this solution has some other drawbacks.

When customer have more than one account in the bank, data from first account is rewriting with data from second

When customer have more than one account in the bank and construction for getting accounts information is
$accounts = $fints->getSEPAAccounts();
foreach ($accounts as $account) {
then data from first account is rewriting with data from second.

Issue is in a string (lib/Fhp/FinTS.php)
$masterArray += $r->getStatementOfAccountArray();
For correct work must be
$masterArray = array_merge($masterArray,$r->getStatementOfAccountArray());

Direct debit (via SEPA XML) and key chain (as TAN)

Hello,
thanks for this great work!

Will it be possible to send direct debit (Lastschriften, ggf. via SEPA XML) and confirm this via key chain file (without classic TAN procedure)?

It would help a lot clubs and small business. Thanks.

Multiple accounts

Hi,

I'm using this Library for the Volksbank Rostock. It works nice but it grabs only the data from the first account. Have multiple accounts on it. How can I get this data. Greets

Transaction-ID missing

I sometimes have transactions with the same date, amount and purpose in my bank account, so I need a unique transactionID to avoid duplicates! Is there such an ID?

danke

wollte mich nur bedanken.
Postbank funktioniert.

Missing entries in StatementOfAccount

These lines
// remove not so important data
array_shift($day);
array_shift($day);
array_shift($day);
array_shift($day);
in Fhp/Parser/MT940.php can cause missing entries in StatementOfAccount.

Here a var_dump of $day before the array_shift:
array(102) {
[0]=>
string(90) "La?23uf?30DORTDE33XXX?31[...]?32[...]"
[1]=>
string(25) "61:160926C12,86NMSCNONREF"
[2]=>
string(134) "86:166?20EREF+NOTPROVIDED?21SVWZ+[...]?[...]?30BAWAATWWXXX?31[...]?32[...]"
[3]=>
string(25) "61:160926C12,98NMSCNONREF"
[4]=>
string(138) "86:166?20EREF+NOTPROVIDED?21SVWZ+Verwendungszweck: DFNH?2251860[...]?30SPKHDE2HXXX?31[...]?32[...]"
[5]=>
string(25) "61:160926C13,83NMSCNONREF"
[6]=>
string(149) "86:166?20EREF+SOF [...]?[...]?23alzdo rf?30WELADED1KLE?31[...]?32[...]"

$day[0], $day[1], $day[2] and $day[3] is relevant data.

I removed the lines what is working fine for me, but there probably was a reason for these lines.

Can't connect to Deutsche Bank

Great gist!

I believe my problem is related to my particular bank. I know that the URL is
https://fints.deutsche-bank.de and the username is made up of 3 components: the 3-digit subsidiary id ("Filialnummer"), the 7-digit account number and the 2-digit subaccount number.
However, I can't establish a connection.

Using your sample code here's what I get:

Fatal error: Uncaught exception 'Fhp\Adapter\Exception\CurlException' with message 'Failed connection to https://fints.deutsche-bank.de/' in /.../vendor/mschindler83/fints-hbci-php/lib/Fhp/Adapter/Curl.php:80 Stack trace: #0 /.../vendor/mschindler83/fints-hbci-php/lib/Fhp/Connection.php(36): Fhp\Adapter\Curl->send(Object(Fhp\Message\Message)) #1 /.../vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php(121): Fhp\Connection->send(Object(Fhp\Message\Message)) #2 /.../vendor/mschindler83/fints-hbci-php/lib/Fhp/Dialog/Dialog.php(325): Fhp\Dialog\Dialog->sendMessage(Object(Fhp\Message\Message)) #3 /.../vendor/mschindler83/fints-hbci-php/lib/Fhp/FinTs.php(126): Fhp\Dialog\Dialog->syncDialog() #4 /.../test/account-statement.php(21): Fhp\FinTs->getSEPAAccounts() #5 {main} thrown in /.../vendor/mschindler83/fints-hbci-php/lib/Fhp/Adapter/Curl.php on line 80

Any idea? Thanks!

cd mark not found in: 180518RD5,00NMSC1

The issue occurs on a booking line which was created by my bank (Volksbank / Fiducia) for canceling an account fee for issuing a new debit card. Not sure what to do with "RD" marked lines - aren't they basically "credit" lines (R= reversed, D=debit)?

On line 100 in Fhp\Paraser\MT940 you extract the different marks but the if/elseif (101, 103) doesn't have a case for "RD" and "RC".

Spec: https://www.rabobank.com/nl/images/format-description-swift-mt940-structured-en.pdf page 7 2.3.6 field :61: Statement Line

Quick fix:

Fhp\Paraser\MT940 line 100 to 107:

preg_match('/^\d{6}(\d{4})?(C|D|RC|RD)([A-Z]{1})?([^N]+)N/', $transaction, $trxMatch);
if ($trxMatch[2] == 'C' || $trxMatch[2] == 'RD') {
$trx[count($trx)]['credit_debit'] = static::CD_CREDIT;
} elseif ($trxMatch[2] == 'D' || $trxMatch[2] == 'RC') {
$trx[count($trx)]['credit_debit'] = static::CD_DEBIT;
} else {
throw new MT940Exception('cd mark not found in: ' . $transaction);
}

Problem with Sparkasse Salem-Heiligenberg

Hi
I am just testing out this library. It seems to be working with my personal account @volksbank Überlingen. However the account of my Company @Sparkasse Salem-Heiligenberg won't work.
I have enabled debugging and the system seems to think the username or password is wrong.

But I have double and tripple check the password.
Also using the dev-master branch from github did not change the issue.

So I tried out the demo user and password the bank provides and it does get past the logon stage. It does error out soon after, because the demo account was not enabled yet, but that is to be expected as the account gets reset every couple of hours.

I now suspect that it may be an Encoding issue, as our password does include an Umlaut character (ÄÜÖ). Maybe my server is sending the umlaut using the wrong encoding. However I have not been able to find out what the correct encoding could be.

$soa->getStatements() - Fatal error

While working with the samples I got in the statements_of_accounts.php this error:

Fatal error: Call to a member function getStatements() on null in C:\xampp\htdocs\test\vendor\mschindler83\fints-hbci-php\Samples\statement_of_account.php on line 40

40: foreach ($soa->getStatements() as $statement) {

Supporting depots

Hi, are there any plans to add the ability to access depot data next to the normal accounts?

ing-diba: wrong bookingDate year

with INGDiba
this MT940 raw data gets parsed as


:20:0
:21:NONREF
:25:50010517/5414367241
:28C:0
:60F:C171126EUR313,52
:34F:EURD10,99
:13D:1711272221-0000
:61:1711271201D10,99NMSCNONREF
:86:005?00Lastschrifteinzug?10009599?20SVWZ+NETFLIX.COM 866.579.71?21
72Datum 27.11.2017 Zeit 04.?2246Kaufumsatz VISA CardEUR 1?230,99?
32NETFLIX.COM              86?336-579-7172                 
-
Fhp\Model\StatementOfAccount\Transaction Object
(
    [bookingDate:protected] => DateTime Object
        (
            [date] => 2016-12-01 00:00:00.000000
            [timezone_type] => 3
            [timezone] => UTC
        )

    [valutaDate:protected] => DateTime Object
        (
            [date] => 2017-11-27 00:00:00.000000
            [timezone_type] => 3
            [timezone] => UTC
        )

    [amount:protected] => 10.99
    [creditDebit:protected] => debit
    [bookingText:protected] => Lastschrifteinzug
    [description1:protected] => SVWZ+NETFLIX.COM 866.579.7172Datum 27.11.2017 Zeit 04.46Kaufumsatz VISA CardEUR 10,99
    [description2:protected] => 
    [bankCode:protected] => 
    [accountNumber:protected] => 
    [name:protected] => 6-579-7172
)

with valuta date: 2017-11-27
and booking date: 2016-12-01

when instead the real booking date seems to be: 2017-12-01

Line 126 in MT940.php seems to be responsible:
https://github.com/mschindler83/fints-hbci-php/blob/master/lib/Fhp/Parser/MT940.php#L126

substr($transaction, 2, 2) and substr($transaction, 6, 2) evaluate to 11 and 12,
so $year gets decremented.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.