Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTanMedia not returning anything #446

Open
CasparKrog opened this issue Jul 16, 2024 · 9 comments
Open

getTanMedia not returning anything #446

CasparKrog opened this issue Jul 16, 2024 · 9 comments

Comments

@CasparKrog
Copy link

CasparKrog commented Jul 16, 2024

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"; ).

@seem2810
Copy link
Contributor

seem2810 commented Sep 3, 2024

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?

@CasparKrog
Copy link
Author

CasparKrog commented Sep 9, 2024

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?

@seem2810
Copy link
Contributor

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

@CasparKrog
Copy link
Author

`<?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

@seem2810
Copy link
Contributor

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...

@mmnasir
Copy link

mmnasir commented Sep 12, 2024

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
Copy link

mmnasir commented Sep 12, 2024

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 .

@CasparKrog
Copy link
Author

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
Copy link
Author

CasparKrog commented Sep 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants