diff --git a/src/Application.php b/src/Application.php
index 18dda13..cc0cb81 100644
--- a/src/Application.php
+++ b/src/Application.php
@@ -25,11 +25,19 @@ class Application
self::$container = $app->getContainer();
}
+ /**
+ * Gets dependency injection container
+ * @return Slim\Container
+ */
public static function getContainer()
{
return self::$container;
}
+ /**
+ * Get Slim application object
+ * @return Slim\App;
+ */
public static function getApplication()
{
return self::$app;
diff --git a/src/Application/API/Handler.php b/src/Application/API/Handler.php
index 2ec6c3b..f739371 100644
--- a/src/Application/API/Handler.php
+++ b/src/Application/API/Handler.php
@@ -35,13 +35,12 @@ class Handler
* - amount
* - description
* - returnUrl
- * - sha1
+ * - hash
*/
$this->post('/transactionRequest', function ($request, $response, $args) {
$parsedBody = $request->getParsedBody();
if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['amount']) && isset($parsedBody['description']) && isset($parsedBody['returnUrl']) && isset($parsedBody['hash'])) {
- // Correct request
try {
$client = new Client($parsedBody['clientId']);
$clientSecret = $client->getClientSecret();
@@ -112,13 +111,12 @@ class Handler
* Requires the following POST arguments:
* - clientId
* - transactionId
- * - sha1
+ * - hash
*/
$this->post('/statusRequest', function ($request, $response, $args) {
$parsedBody = $request->getParsedBody();
if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['hash'])) {
- // Correct request
try {
$client = new Client($parsedBody['clientId']);
$clientSecret = $client->getClientSecret();
diff --git a/src/Application/Auth/Authorization.php b/src/Application/Auth/Authorization.php
index 65ab98a..7f0762a 100644
--- a/src/Application/Auth/Authorization.php
+++ b/src/Application/Auth/Authorization.php
@@ -18,6 +18,12 @@ use Inforbank\Application;
class Authorization
{
+ /**
+ * Login user
+ * @param $rekeningnr
+ * @param $passcode
+ * @return boolean
+ */
public function login($rekeningnr, $passcode)
{
$container = Application::getContainer();
@@ -42,16 +48,27 @@ class Authorization
return false;
}
+ /**
+ * Return current user id
+ * @return any
+ */
public function getUserID()
{
return $_SESSION['userid'];
}
+ /**
+ * Return if the current user is authenticated
+ * @return boolean
+ */
public function isUserAuthenticated()
{
return $this->getUserID() !== null;
}
+ /**
+ * Delete user session data
+ */
public function logout()
{
unset($_SESSION['userid']);
diff --git a/src/Application/Auth/Middleware.php b/src/Application/Auth/Middleware.php
index a5bfffd..01d54e4 100644
--- a/src/Application/Auth/Middleware.php
+++ b/src/Application/Auth/Middleware.php
@@ -19,6 +19,9 @@ use Inforbank\Application\Helper\Redirect;
class Middleware
{
+ /**
+ * Middleware (https://www.slimframework.com/docs/concepts/middleware.html) om te checken of de gebruiker is ingelogd
+ */
public function __invoke($request, $response, $next)
{
$container = Application::getContainer();
diff --git a/src/Application/Helper/Berichten.php b/src/Application/Helper/Berichten.php
index beebb0c..6d52b62 100644
--- a/src/Application/Helper/Berichten.php
+++ b/src/Application/Helper/Berichten.php
@@ -18,6 +18,10 @@ use Inforbank\Application;
class Berichten
{
+ /**
+ * Get all messages for a user
+ * @return array
+ */
public static function getUserBerichten()
{
$container = Application::getContainer();
@@ -36,7 +40,7 @@ class Berichten
"datum" => $datum,
"gelezen" => $bericht['gelezen']
);
- if(!$bericht['gelezen']){
+ if (!$bericht['gelezen']) {
$bericht->update([
"gelezen" => true
]);
@@ -46,6 +50,12 @@ class Berichten
return $berichtArray;
}
+ /**
+ * Send new message
+ * @param int $user Klantid
+ * @param string $afzender String name of the sender
+ * @param string $bericht Message
+ */
public static function newBericht($user, $afzender, $bericht)
{
$container = Application::getContainer();
diff --git a/src/Application/Helper/IBAN.php b/src/Application/Helper/IBAN.php
index 787b531..f15bd68 100644
--- a/src/Application/Helper/IBAN.php
+++ b/src/Application/Helper/IBAN.php
@@ -16,7 +16,7 @@ namespace Inforbank\Application\Helper;
class IBAN
{
- private function wordToNumbers($word)
+ private static function wordToNumbers($word)
{
$newword = "";
$wordarray = str_split($word);
@@ -30,7 +30,7 @@ class IBAN
return $newword;
}
- private function getCheckDigits($bignum)
+ private static function getCheckDigits($bignum)
{
//Modulo staartdeling
$modulo97 = (int)substr($bignum, 0, 6);
@@ -48,7 +48,7 @@ class IBAN
return $checkdigits;
}
- public function isValidIBAN($iban)
+ public static function isValidIBAN($iban)
{
$iban = str_replace(" ", "", $iban);
$landcode = substr($iban, 0, 2);
@@ -56,38 +56,38 @@ class IBAN
$identificatie = substr($iban, 4);
$identificatie .= $landcode;
$identificatie .= "00";
- $nummer = $this->wordToNumbers($identificatie);
- return $controle == $this->getCheckDigits($nummer);
+ $nummer = self::wordToNumbers($identificatie);
+ return $controle == self::getCheckDigits($nummer);
}
- public function getRekeningNummer($iban)
+ public static function getRekeningNummer($iban)
{
return substr(str_replace(" ", "", $iban), 8);
}
- public function getBank($iban)
+ public static function getBank($iban)
{
return substr(str_replace(" ", "", $iban), 4, 4);
}
- public function getLand($iban)
+ public static function getLand($iban)
{
return substr(str_replace(" ", "", $iban), 0, 2);
}
- public function getIBAN($rekeningnr)
+ public static function getIBAN($rekeningnr)
{
$landcode = "NL"; // NL in vertaling
- $landnumber = $this->wordToNumbers($landcode);
+ $landnumber = self::wordToNumbers($landcode);
$bankcode = "INFO";
- $banknumber = $this->wordToNumbers($bankcode);
+ $banknumber = self::wordToNumbers($bankcode);
$rekeningnr = str_pad($rekeningnr, 10, 0, STR_PAD_LEFT);
$bignum = $banknumber . $rekeningnr . $landnumber . "00";
- $checkdigits = $this->getCheckDigits($bignum);
+ $checkdigits = self::getCheckDigits($bignum);
$rekeningnrarr = str_split($rekeningnr, 4);
return $landcode.$checkdigits." ".$bankcode." ".$rekeningnrarr[0]." ".$rekeningnrarr[1]." ".$rekeningnrarr[2];
diff --git a/src/Application/Helper/Idob/Client.php b/src/Application/Helper/Idob/Client.php
index 2727922..e86c74d 100644
--- a/src/Application/Helper/Idob/Client.php
+++ b/src/Application/Helper/Idob/Client.php
@@ -16,6 +16,9 @@ namespace Inforbank\Application\Helper\Idob;
use Inforbank\Application;
+/**
+ * Used for client authentication in IDOB
+ */
class Client
{
private $client;
diff --git a/src/Application/Helper/Idob/Transactie.php b/src/Application/Helper/Idob/Transactie.php
index 5906ad4..3b6b142 100644
--- a/src/Application/Helper/Idob/Transactie.php
+++ b/src/Application/Helper/Idob/Transactie.php
@@ -18,6 +18,14 @@ use Inforbank\Application;
class Transactie
{
+ /**
+ * Create IDOB transaction
+ * @param string $reference Reference passed by the client (webshop)
+ * @param string $clientId Client identifier
+ * @param double $amount Transaction amount
+ * @param string $description Description for the user
+ * @return int Transaction identifier
+ */
public static function createTransactie($reference, $clientId, $amount, $description)
{
$container = Application::getContainer();
@@ -33,6 +41,11 @@ class Transactie
return $trans['id'];
}
+ /**
+ * Get IDOB transaction data
+ * @param int $id Transaction identifier
+ * @return array
+ */
public static function getTransactie($id)
{
$container = Application::getContainer();
@@ -54,6 +67,11 @@ class Transactie
);
}
+ /**
+ * Set the IDOB transaction status
+ * @param int $id Transaction identifier
+ * @param int $status Status: 1 for pending, 2 for paid, 3 for unknown
+ */
public static function setTransactionStatus($id, $status)
{
$container = Application::getContainer();
diff --git a/src/Application/Helper/Klant.php b/src/Application/Helper/Klant.php
index c51a175..18c372f 100644
--- a/src/Application/Helper/Klant.php
+++ b/src/Application/Helper/Klant.php
@@ -18,6 +18,10 @@ use Inforbank\Application;
class Klant
{
+ /**
+ * Get current user data
+ * @return array
+ */
public static function getCurrentUser()
{
$container = Application::getContainer();
diff --git a/src/Application/Helper/Overboekingen.php b/src/Application/Helper/Overboekingen.php
index d76f557..99ba3a0 100644
--- a/src/Application/Helper/Overboekingen.php
+++ b/src/Application/Helper/Overboekingen.php
@@ -69,20 +69,20 @@ class Overboekingen
$ascii = ord($char);
if ($char === "." || $char === ",") {
$komma++;
- if($komma > 1){
+ if ($komma > 1) {
//Twee komma's
return false;
}
} elseif (($ascii >= ord("0") && $ascii <= ord("9") || $char === "-")) {
- if($komma >= 1){
+ if ($komma >= 1) {
$decimalen++;
if ($decimalen > 2) {
//Meer dan twee cijfers achter de komma
return false;
}
- }else{
+ } else {
$cijfers++;
- if($cijfers > 9){
+ if ($cijfers > 9) {
//Te veel cijfers voor de komma
return false;
}
@@ -101,7 +101,7 @@ class Overboekingen
}
/**
- *
+ * Maak een nieuwe overboeking aan
* @param IBAN $van De rekening waar het bedrag vanaf wordt gehaald
* @param IBAN $naar De rekening waar het bedrag bijkomt
* @param double $bedrag Het bedrag
@@ -115,15 +115,15 @@ class Overboekingen
//error: rekening is niet van klant
Overboekingen::error(Overboekingen::$EIGENAAR);
}
- $ibanHelper = new IBAN();
- if (!$ibanHelper->isValidIBAN($naar)) {
+
+ if (!IBAN::isValidIBAN($naar)) {
//error: ongeldige iban
throw new Exception("De IBAN van de ontvanger is ongeldig.", Overboekingen::$IBAN);
- } elseif (!($ibanHelper->getLand($naar) == "NL" && $ibanHelper->getBank($naar) === "INFO")) {
+ } elseif (!(IBAN::getLand($naar) == "NL" && IBAN::getBank($naar) === "INFO")) {
//error: andere bank
Overboekingen::error(Overboekingen::$BANK);
}
- $naarRekeningnr = $ibanHelper->getRekeningNummer($naar);
+ $naarRekeningnr = IBAN::getRekeningNummer($naar);
//Controleer of de rekening bestaat
$db = Application::getContainer()->db;
@@ -180,7 +180,7 @@ class Overboekingen
]);
//Stuur bericht bij laag saldo
if ($vanRekening['saldo'] - $bedragvalue < 20) {
- Berichten::newBericht(Application::getContainer()->auth->getUserID(), "Bank", "U heeft een laag saldo op uw rekening: " . $ibanHelper->getIBAN($vanRekening['nr']) . ".
Uw huidige saldo is " . money_format('%(#1n', $vanRekening['saldo'] - $bedragvalue) . ".");
+ Berichten::newBericht(Application::getContainer()->auth->getUserID(), "Bank", "U heeft een laag saldo op uw rekening: " . IBAN::getIBAN($vanRekening['nr']) . ".
Uw huidige saldo is " . money_format('%(#1n', $vanRekening['saldo'] - $bedragvalue) . ".");
}
//In de database worden de getallen met 10 cijfers voor de komma opgeslagen
//Als het saldo te hoog wordt heb je een probleem
diff --git a/src/Application/Helper/Redirect.php b/src/Application/Helper/Redirect.php
index 1fe4108..771197a 100644
--- a/src/Application/Helper/Redirect.php
+++ b/src/Application/Helper/Redirect.php
@@ -16,6 +16,13 @@ namespace Inforbank\Application\Helper;
class Redirect
{
+ /**
+ * Create a new redirect to the given path
+ * @param Request $request
+ * @param Response $response
+ * @param string $path
+ * @return Response object
+ */
public static function create($request, $response, $path)
{
$basePath = $request->getUri()->getBaseUrl();
diff --git a/src/Application/Helper/Rekeningen.php b/src/Application/Helper/Rekeningen.php
index 0fdfe51..299e8cf 100644
--- a/src/Application/Helper/Rekeningen.php
+++ b/src/Application/Helper/Rekeningen.php
@@ -21,13 +21,16 @@ class Rekeningen
public static $BETAALREKENING = 1;
public static $SPAARREKENING = 2;
+ /**
+ * Return the current user bank accounts
+ * @return array
+ */
public static function getCurrentUserRekeningen()
{
$container = Application::getContainer();
$user = $container->auth->getUserID();
$db = $container->db;
- $ibanhelper = new IBAN;
$rekeningen = $db->rekeningen->where('klantid', $user);
@@ -37,7 +40,7 @@ class Rekeningen
$type = $db->types->where('id', $rekening['typeid'])[$rekening['typeid']];
$returnArray[] = array(
- "iban" => $ibanhelper->getIBAN($rekening['rekeningnr']),
+ "iban" => IBAN::getIBAN($rekening['rekeningnr']),
"nr" => $rekening['rekeningnr'],
"saldo" => (double) $rekening['saldo'],
"naam" => $type['rekeningnaam'],
@@ -48,6 +51,11 @@ class Rekeningen
return $returnArray;
}
+ /**
+ * Check if the current user is the owner of this bank account
+ * @param string $iban
+ * @return boolean
+ */
public static function isEigenRekeningIBAN($iban)
{
$rekeningen = Rekeningen::getCurrentUserRekeningen();
@@ -62,6 +70,11 @@ class Rekeningen
return $vanRekening;
}
+ /**
+ * Check if the current user is the owner of this bank account
+ * @param string $nr Internal bank account number
+ * @return boolean
+ */
public static function isEigenRekeningnr($nr)
{
$rekeningen = Rekeningen::getCurrentUserRekeningen();
diff --git a/src/Application/Helper/Statistieken.php b/src/Application/Helper/Statistieken.php
index e1bf897..fe07f5a 100644
--- a/src/Application/Helper/Statistieken.php
+++ b/src/Application/Helper/Statistieken.php
@@ -5,15 +5,17 @@ namespace Inforbank\Application\Helper;
use Exception;
use Inforbank\Application;
-class Statistieken {
+class Statistieken
+{
public static $EIGENAAR = 1;
-
- public static function getSaldoverloop($dagen, $rekeningNummer){
- if(!Rekeningen::isEigenRekeningnr($rekeningNummer)){
+
+ public static function getSaldoverloop($dagen, $rekeningNummer)
+ {
+ if (!Rekeningen::isEigenRekeningnr($rekeningNummer)) {
throw new Exception("Dit is niet uw eigen rekening", Statistieken::$EIGENAAR);
}
$xas = array();
- for($i = $dagen; $i >= 0; $i--){
+ for ($i = $dagen; $i >= 0; $i--) {
$xas[] = date("Y-m-d", strtotime("now") - $i * 86400);
}
$container = Application::getContainer();
@@ -26,27 +28,27 @@ class Statistieken {
$huidigSaldo = (double)$saldo;
$vandaag = strtotime("now");
$yas = array_fill(0, $dagen + 1, 0);
- foreach($eraf as $af){
- $dag = strtotime($af['datum']);
- $diff = floor(($vandaag - $dag)/86400);
- if($diff <= $dagen){
- $yas[$dagen - $diff] = (double)$af['bedr'];
- }
+ foreach ($eraf as $af) {
+ $dag = strtotime($af['datum']);
+ $diff = floor(($vandaag - $dag)/86400);
+ if ($diff <= $dagen) {
+ $yas[$dagen - $diff] = (double)$af['bedr'];
+ }
}
- foreach($erbij as $bij){
- $dag = strtotime($bij['datum']);
- $diff = floor(($vandaag - $dag)/86400);
- if($diff <= $dagen){
- $yas[$dagen - $diff + 1] -= (double)$bij['bedr'];
- }else{
- break;
- }
+ foreach ($erbij as $bij) {
+ $dag = strtotime($bij['datum']);
+ $diff = floor(($vandaag - $dag)/86400);
+ if ($diff <= $dagen) {
+ $yas[$dagen - $diff + 1] -= (double)$bij['bedr'];
+ } else {
+ break;
+ }
}
$verandering = 0;
- for($i = $dagen; $i >= 0; $i--){
- $huidigSaldo += $verandering;
- $verandering = $yas[$i];
- $yas[$i] = $huidigSaldo;
+ for ($i = $dagen; $i >= 0; $i--) {
+ $huidigSaldo += $verandering;
+ $verandering = $yas[$i];
+ $yas[$i] = $huidigSaldo;
}
return [
"x-as" => $xas,
diff --git a/src/Application/Idob.php b/src/Application/Idob.php
index 1c9ddc8..f218c04 100644
--- a/src/Application/Idob.php
+++ b/src/Application/Idob.php
@@ -75,10 +75,9 @@ class Idob
/**
* All set to pay!
*/
- $ibanhelper = new IBAN();
// Do overboeking
- Overboekingen::createOverboeking($ibanhelper->getIBAN($van), $ibanhelper->getIBAN($rekening), $transactie['amount'], "Betaling aan " . $naam . " voor transactie " . $transactie['reference'], "id");
+ Overboekingen::createOverboeking(IBAN::getIBAN($van), IBAN::getIBAN($rekening), $transactie['amount'], "Betaling aan " . $naam . " voor transactie " . $transactie['reference'], "id");
// Do Status update
Transactie::setTransactionStatus($transactie['transactieId'], 2);
diff --git a/src/Application/Overboeking.php b/src/Application/Overboeking.php
index c0b985c..21dd28a 100644
--- a/src/Application/Overboeking.php
+++ b/src/Application/Overboeking.php
@@ -27,7 +27,7 @@ class Overboeking
{
public function __construct(App $app)
{
- $app->get('/overboeking', function ($request, $response, $args) use($app) {
+ $app->get('/overboeking', function ($request, $response, $args) use ($app) {
$rekeningen = Rekeningen::getCurrentUserRekeningen();
return $this->renderer->render($response, 'overboeking.phtml', [
'header' => Header::getHeaderData(),
@@ -44,8 +44,7 @@ class Overboeking
$omschrijving = $post['omschrijving'];
try {
- $ibanhelper = new IBAN();
- Overboekingen::createOverboeking($ibanhelper->getIBAN($van), $naar, $bedrag, $omschrijving, "bg");
+ Overboekingen::createOverboeking(IBAN::getIBAN($van), $naar, $bedrag, $omschrijving, "bg");
return Redirect::create($request, $response, "/rekeningen/$van?geslaagd=1");
} catch (Exception $e) {
return Redirect::create($request, $response, "/overboeking?error=" . $e->getCode() . "");
diff --git a/src/Application/Transacties.php b/src/Application/Transacties.php
index 6cd7296..a7562de 100644
--- a/src/Application/Transacties.php
+++ b/src/Application/Transacties.php
@@ -26,8 +26,6 @@ class Transacties
{
$app->get('/rekeningen/{rekeningnummer}', function ($request, $response, $args) {
$rekeningen = Rekeningen::getCurrentUserRekeningen();
-
- $ibanhelper = new IBAN;
$rekening = $rekening = Rekeningen::isEigenRekeningnr($args['rekeningnummer']);
$rekeningnr = $args['rekeningnummer'];
if (!$rekening) {
@@ -45,8 +43,8 @@ class Transacties
foreach ($transacties as $transactie) {
$returnArray[] = array(
- "van" => $ibanhelper->getIBAN($transactie['van']),
- "naar" => $ibanhelper->getIBAN($transactie['naar']),
+ "van" => IBAN::getIBAN($transactie['van']),
+ "naar" => IBAN::getIBAN($transactie['naar']),
"bedrag" => $transactie['bedrag'],
"type" => $transactie['type'],
"omschrijving" => $transactie['omschrijving'],
diff --git a/src/Proxy.php b/src/Proxy.php
index afcdbe7..91d1db1 100644
--- a/src/Proxy.php
+++ b/src/Proxy.php
@@ -14,6 +14,9 @@
namespace Inforbank;
+/**
+ * Proxy class om de limitaties van de sgni.nl webserver te omzeilen. Het is mogelijk om de site te bezoeken via zowel /login als /index.php/login op een goed geconfigureerde webserver, maar als de /index.php/login url wordt gebruikt is de onderstaande static file proxy nodig.
+ */
class Proxy
{
public static $route;
diff --git a/src/settings.php b/src/settings.php
index 739ee3c..5ef5b1e 100644
--- a/src/settings.php
+++ b/src/settings.php
@@ -1,8 +1,8 @@
[
- 'displayErrorDetails' => true, // set to false in production
- 'addContentLengthHeader' => false, // Allow the web server to send the content-length header
+ 'displayErrorDetails' => true,
+ 'addContentLengthHeader' => false,
// Renderer settings
'renderer' => [