phpFinTS icon indicating copy to clipboard operation
phpFinTS copied to clipboard

getTanMedia not returning anything

Open CasparKrog opened this issue 1 year ago • 9 comments

Same problem, as some had with "Sparkasse" before in here.

But for me it is not even showing "Alle Geräte" in tanMedia. Executing this $tanMedia = $fints->getTanMedia($tanMode); is not returning anything. The code is not getting past this. If I set this manually to "Alle Geräte", the code won't work ($tanMedium = "Alle Geräte"; ).

CasparKrog avatar Jul 16 '24 14:07 CasparKrog

Hi CasparKrog,

this is how my code works:

                    $tanModes = $this->fints->getTanModes();
                    $tanModeNumber = $tanMode;  //EG 923 PushTan
                    if (is_array($tanModeNumber) && isset($tanModeNumber['sicherheitsfunktion'])) $tanModeNumber = $tanModeNumber['sicherheitsfunktion'];
                    $tanModeObject = (isset($tanModes[$tanModeNumber])) ? $tanModes[$tanModeNumber] : null;
                    if ($tanModeObject && $tanModeObject->needsTanMedium()) {
                        $tanMedias = $this->fints->getTanMedia($tanModeObject);
                        if (!empty($tanMedias)) {
                            $this->fints->close();
                            return 'tan_medium_selection';
                        }
                    }

Do you have the $tanModeObject->needsTanMedium() in your code?

seem2810 avatar Sep 03 '24 10:09 seem2810

Do you have the $tanModeObject->needsTanMedium() in your code?

Yes I have that in my code.

Is it possible that you will have a closer look at my code?

CasparKrog avatar Sep 09 '24 09:09 CasparKrog

Can you compare your code with my code snippet above? Post your code snippet here

seem2810 avatar Sep 10 '24 07:09 seem2810

`<?php

/** @noinspection PhpUnhandledExceptionInspection */

/**

  • SAMPLE - Creates a new FinTs instance (init.php) and lets the user select the TAN mode they want to use. */

/** @var \Fhp\FinTs $fints */ $fints = require_once 'init.php';

// First, the user has to decide which TAN mode they want to use. // NOTE: There is a special case for banks that do not support PSD2, use NoPsd2TanMode for those. $tanModes = $fints->getTanModes(); if (empty($tanModes)) { echo 'Your bank does not support any TAN modes!'; return; }

echo "Here are the available TAN modes:\n"; $tanModeNames = array_map(function (\Fhp\Model\TanMode $tanMode) { return $tanMode->getName(); }, $tanModes); print_r($tanModeNames);

echo "Which one do you want to use? Index:\n"; $tanModeIndex = "923"; if (!is_numeric($tanModeIndex) || !array_key_exists(intval($tanModeIndex), $tanModes)) { echo 'Invalid index!'; return; } $tanMode = $tanModes[intval($tanModeIndex)]; echo 'You selected ' . $tanMode->getName() . "\n";

// In case the selected TAN mode requires a TAN medium (e.g. if the user picked mTAN, they may have to pick the mobile // device on which they want to receive TANs), let the user pick that too. if ($tanMode->needsTanMedium()) { $tanMedia = $fints->getTanMedia($tanMode); if (empty($tanMedia)) { echo 'Your bank did not provide any TAN media, even though it requires selecting one!'; return; }

echo "Here are the available TAN media:\n";
$tanMediaNames = array_map(function (\Fhp\Model\TanMedium $tanMedium) {
    return $tanMedium->getName();
}, $tanMedia);
print_r($tanMediaNames);

echo "Which one do you want to use? Index:\n";
$tanMediumIndex = trim(fgets(STDIN));
if (!is_numeric($tanMediumIndex) || !array_key_exists(intval($tanMediumIndex), $tanMedia)) {
    echo 'Invalid index!';
    return;
}
$tanMedium = $tanMedia[intval($tanMediumIndex)];
echo 'You selected ' . $tanMedium->getName() . "\n";

} else { $tanMedium = null; }

// Announce the selection to the FinTS library. $fints->selectTanMode($tanMode, $tanMedium);

// Within your application, you should persist these choices somewhere (e.g. database), so that the user does not have // to select them again the future. Note that it is sufficient to persist the ID/name, i.e. this is equivalent: $fints->selectTanMode($tanMode->getId(), $tanMedium->getName());

// Now you could do $fints->login(), see login.php for that. For this example, we'll just close the connection. $fints->close(); echo 'Done'; `

The Output:

https://erp.trimix-baustoffe.de/plugins/phpFinTS/Samples/tanModesAndMedia.php

CasparKrog avatar Sep 10 '24 12:09 CasparKrog

Okay, but it seems to be correct? "Here are the available TAN modes: Array ( [923] => pushTAN 2.0 ) Which one do you want to use? Index: You selected pushTAN 2.0"

after that is no more output set in your code? Looks like, that if ($tanMode->needsTanMedium()) { is false...

seem2810 avatar Sep 11 '24 05:09 seem2810

Hi @CasparKrog you need to delete or stop this line in init.php file:

//$fints->setLogger(new \Tests\Fhp\CLILogger());

then you can see a clear page.

best wishes

mmnasir avatar Sep 12 '24 07:09 mmnasir

again , if you want to know exactly how your tanMeduim is saved in the bank , you need to visit the browser.php and then sign in with your account .

mmnasir avatar Sep 12 '24 07:09 mmnasir

Hi @CasparKrog you need to delete or stop this line in init.php file:

//$fints->setLogger(new \Tests\Fhp\CLILogger());

then you can see a clear page.

best wishes

Sure, I just did it, to get the debugging Info.

CasparKrog avatar Sep 12 '24 07:09 CasparKrog

again , if you want to know exactly how your tanMeduim is saved in the bank , you need to visit the browser.php and then sign in with your account .

Good idea, tried it, but it won't give me the balance? It stops without giving me the balance. It works with a different back though. Just not with Sparkasse.

CasparKrog avatar Sep 12 '24 07:09 CasparKrog