walle89 / SwedbankJson

Unofficial API client for the Swedbank's and Sparbankerna's mobile apps in Sweden.
MIT License
75 stars 14 forks source link

Trying out BankID sample and getting "undefined property" #34

Closed challe closed 7 years ago

challe commented 7 years ago

I'm trying out the BankID sample with the following code:

<?php 
require 'vendor/autoload.php';

// Settings
$bankApp  = 'swedbank';
$username = xxxxxxxxxxxx; // Personal identity number (personnummer).

session_start();

// Step 1 - Start the authentication process
if (!isset($_SESSION['swedbankjson_auth']))
{
    $auth = new SwedbankJson\Auth\MobileBankID($bankApp, $username);
    $auth->initAuth();
    exit("Open the BankID app and confirm the login. Then refresh the page.");
}

// Step 2 - Verify authentication
$auth = unserialize($_SESSION['swedbankjson_auth']);
if (!$auth->verify())
    exit("You updated the page, but the login is not approved in the BankID app. Please try again.");

// Step 3 - You are in!
$bankConn = new SwedbankJson\SwedbankJson($auth);

$accountInfo = $bankConn->accountDetails();
$bankConn->terminate(); // Sign out

echo 'Bank statements
<pre>';
print_r($accountInfo);

And 'm getting the following error:

Notice: Undefined property: stdClass::$hasSavingsbankProfile in C:\xampp\htdocs\swedbank\vendor\walle89\swedbank-json\src\SwedbankJson.php on line 51

Followed by

Fatal error: Uncaught Exception: The profile do not contain any bank accounts. in C:\xampp\htdocs\swedbank\vendor\walle89\swedbank-json\src\SwedbankJson.php:66 Stack trace: #0 C:\xampp\htdocs\swedbank\vendor\walle89\swedbank-json\src\SwedbankJson.php(87): SwedbankJson\SwedbankJson->profileList() #1 C:\xampp\htdocs\swedbank\vendor\walle89\swedbank-json\src\SwedbankJson.php(159): SwedbankJson\SwedbankJson->selectProfile('') #2 C:\xampp\htdocs\swedbank\vendor\walle89\swedbank-json\src\SwedbankJson.php(203): SwedbankJson\SwedbankJson->accountList() #3 C:\xampp\htdocs\swedbank\index.php(29): SwedbankJson\SwedbankJson->accountDetails() #4 {main} thrown in C:\xampp\htdocs\swedbank\vendor\walle89\swedbank-json\src\SwedbankJson.php on line 66