nemiah / phpFinTS

PHP library to communicate with FinTS/HBCI servers
MIT License
130 stars 42 forks source link

easy Laravel Implementation possible? #374

Closed seem2810 closed 3 months ago

seem2810 commented 2 years ago

Hi there,

I'm coming over https://github.com/abiturma/laravel-fints to https://github.com/abiturma/php-fints and from this https://github.com/mschindler83/fints-hbci-php to finally this project.

I've got the big problem, that my bank needs a Tan to receive the statements. However I didn't find a solution.

Maybe some other has a possible migration? (Gerne auf Englisch oder Deutsch)

use Abiturma\PhpFints\Fints;

class HBCI
{
    public static function init(Bank $bank, $username = null, $pin = null)
    {
        $host = $bank->server;
        $account_number = $bank->account_number;
        $bank_code = $bank->bank_code;

        $fints = Fints::host($host)->username($username)->bankCode($bank_code)->pin($pin);
        dump($fints);
        dump($fints->getAccounts());
        $account = false;
        foreach ($fints->getAccounts() as $ac) {
            if ($ac->account_number == $account_number) $account = $ac;
        }

        if ($account) {
           $statements = $fints->getStatementOfAccount($account, $startDate);
           dd($statements);
lukas-staab commented 2 years ago

Have you had a look into Samples/statementOfAccount.php? You will need way more User Interaction for TAN Cases than you showed here. Your provided code will only work if there is no tan needed (and I think you also forgot the $fints->login() method, which might need a seperate tan every 30(?) days as well :/ )

I did it like this in another project - in the Samples directory in this project you find some example code as well. You will need different Reqests (which sometimes will and sometimes will not be needed - depending on your bank) - therefore you need the $fints->persist() to reinitiate the $fints object in your (then new) Laravel request.

seem2810 commented 2 years ago

Thanks. I'll try.

seem2810 commented 2 years ago

I've implemented your repo and it worked well. But If i choose pushTAN 2.0 my app ask for confirmation. After I receive an error:

Protocol
 \ 
UnexpectedResponseException
PHP 8.1.7
9.20.0
Got neither 3956 nor HITAN with tanProzess=2

In:

if ($this->fints->checkDecoupledSubmission($action)) {

                    echo "Bestätigt.<br />";

                }

This validate the request for a few minutes and everything is fine. But I don't know how to handle this error.

seem2810 commented 2 years ago

any ideas?

lukas-staab commented 2 years ago

I am not sure right now. Seems either like a bank issue or a wrong api call. Maybe @Philipp91 or @nemiah has an idea.

Philipp91 commented 2 years ago

This validate the request for a few minutes and everything is fine.

What do you mean by "everything is fine"? That you can receive the bank statements as expected as long as you just ignore that exception?

Philipp91 commented 2 years ago

Got neither 3956 nor HITAN with tanProzess=2

Please log the traffic and send us the last response received from the server. That's the one to which the error message refers. Please make sure it doesn't contain any sensitive information before posting it.


The library currently only supports those two aforementioned cases (3956 code to mean "still waiting for the user's confirmation" or HITAN segment to mean "confirmation successful"). But perhaps there are more cases. I suspect that this could be the issue:

Note that we only support the (B) variant here.

Which refers to section B.4.2.2.1 of the specification. So I guess based on the response you post and the further specification sections, we'd have to implement some more functionality to support this bank's login procedure.

seem2810 commented 2 years ago

This validate the request for a few minutes and everything is fine.

What do you mean by "everything is fine"? That you can receive the bank statements as expected as long as you just ignore that exception?

Yes. I can receive the statements when I ignore the error.

Got neither 3956 nor HITAN with tanProzess=2

Please log the traffic and send us the last response received from the server. That's the one to which the error message refers. Please make sure it doesn't contain any sensitive information before posting it.

The library currently only supports those two aforementioned cases (3956 code to mean "still waiting for the user's confirmation" or HITAN segment to mean "confirmation successful"). But perhaps there are more cases. I suspect that this could be the issue:

Note that we only support the (B) variant here.

Which refers to section B.4.2.2.1 of the specification. So I guess based on the response you post and the further specification sections, we'd have to implement some more functionality to support this bank's login procedure.

I'll check it this week.

timrasche commented 1 year ago

@Philipp91 @nemiah short information after days of working on this implementation: success in all cases except decoupled authentication request. There is a method called "isProzessvariante2" on TanMode model. This returns true in my case but throw an error on "checkDecoupledSubmission" with message "Got neither 3956 nor HITAN with tanProzess=2". I think thats not a right behaviour. Can you check this?

Philipp91 commented 1 year ago

Please log the traffic and send us the last response received from the server. That's the one to which the error message refers. Please make sure it doesn't contain any sensitive information before posting it.

Handman280 commented 1 year ago

any new news about this issue?

seem2810 commented 1 year ago

I can't test it... My customer has changed his tan mode .. I think we can close it

any new news about this issue?

witschko commented 1 year ago

Please log the traffic and send us the last response received from the server. That's the one to which the error message refers. Please make sure it doesn't contain any sensitive information before posting it.

Hi everybody...I've got the same issue "Got neither 3956 nor HITAN with tanProzess=2". The message for the getStatementOfAccount() returns the statements as it seems.

I have attached a log file with the request and a response where you can find "Freigabe erfolgreich" and the positions. But it nevertheless shows this error. fints.log