Finalized IDOB + small changes concerning redirects
This commit is contained in:
@ -21,16 +21,17 @@ class IBAN
|
||||
$newword = "";
|
||||
$wordarray = str_split($word);
|
||||
foreach ($wordarray as $v) {
|
||||
if(ctype_alpha($v)){
|
||||
if (ctype_alpha($v)) {
|
||||
$newword .= ord(strtolower($v)) - 87;
|
||||
}else{
|
||||
} else {
|
||||
$newword .= $v;
|
||||
}
|
||||
}
|
||||
return $newword;
|
||||
}
|
||||
|
||||
private function getCheckDigits($bignum){
|
||||
private function getCheckDigits($bignum)
|
||||
{
|
||||
//Modulo staartdeling
|
||||
$modulo97 = (int)substr($bignum, 0, 6);
|
||||
$modulo97 = $modulo97 % 97;
|
||||
@ -46,8 +47,9 @@ class IBAN
|
||||
}
|
||||
return $checkdigits;
|
||||
}
|
||||
|
||||
public function isValidIBAN($iban){
|
||||
|
||||
public function isValidIBAN($iban)
|
||||
{
|
||||
$iban = str_replace(" ", "", $iban);
|
||||
$landcode = substr($iban, 0, 2);
|
||||
$controle = substr($iban, 2, 2);
|
||||
@ -57,19 +59,22 @@ class IBAN
|
||||
$nummer = $this->wordToNumbers($identificatie);
|
||||
return $controle == $this->getCheckDigits($nummer);
|
||||
}
|
||||
|
||||
public function getRekeningNummer($iban){
|
||||
|
||||
public function getRekeningNummer($iban)
|
||||
{
|
||||
return substr(str_replace(" ", "", $iban), 8);
|
||||
}
|
||||
|
||||
public function getBank($iban){
|
||||
|
||||
public function getBank($iban)
|
||||
{
|
||||
return substr(str_replace(" ", "", $iban), 4, 4);
|
||||
}
|
||||
|
||||
public function getLand($iban){
|
||||
|
||||
public function getLand($iban)
|
||||
{
|
||||
return substr(str_replace(" ", "", $iban), 0, 2);
|
||||
}
|
||||
|
||||
|
||||
public function getIBAN($rekeningnr)
|
||||
{
|
||||
$landcode = "NL"; // NL in vertaling
|
||||
|
54
src/Application/Helper/Idob/Client.php
Normal file
54
src/Application/Helper/Idob/Client.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Helper\Idob;
|
||||
|
||||
use Inforbank\Application;
|
||||
|
||||
class Client
|
||||
{
|
||||
private $client;
|
||||
|
||||
public function __construct($id)
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$db = $container->db;
|
||||
|
||||
$this->client = $db->idobc->where("clientId", $id)->limit(1)->fetch();
|
||||
|
||||
if (!$this->client) {
|
||||
throw new \Exception("There is no client with this id");
|
||||
}
|
||||
}
|
||||
|
||||
public function getClientSecret()
|
||||
{
|
||||
return $this->client['clientSecret'];
|
||||
}
|
||||
|
||||
public function getClientRedirectURI()
|
||||
{
|
||||
return $this->client['redirectUri'];
|
||||
}
|
||||
|
||||
public function getClientName()
|
||||
{
|
||||
return $this->client['naam'];
|
||||
}
|
||||
|
||||
public function getClientRekening()
|
||||
{
|
||||
return $this->client['rekeningnr'];
|
||||
}
|
||||
}
|
75
src/Application/Helper/Idob/Transactie.php
Normal file
75
src/Application/Helper/Idob/Transactie.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Helper\Idob;
|
||||
|
||||
use Inforbank\Application;
|
||||
|
||||
class Transactie
|
||||
{
|
||||
public static function createTransactie($reference, $clientId, $amount, $description)
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$db = $container->db;
|
||||
|
||||
$trans = $db->idobt->insert([
|
||||
"reference" => $reference,
|
||||
"clientId" => $clientId,
|
||||
"amount" => $amount,
|
||||
"description" => $description,
|
||||
"status" => 1
|
||||
]);
|
||||
return $trans['id'];
|
||||
}
|
||||
|
||||
public static function getTransactie($id)
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$db = $container->db;
|
||||
|
||||
$transactie = $db->idobt->where("transactieId", $id)->limit(1)->fetch();
|
||||
|
||||
if (!$transactie) {
|
||||
throw new \Exception("Transaction not found");
|
||||
}
|
||||
|
||||
return array(
|
||||
"transactieId" => $transactie['transactieId'],
|
||||
"reference" => $transactie['reference'],
|
||||
"clientId" => $transactie['clientId'],
|
||||
"amount" => (double) $transactie['amount'],
|
||||
"description" => $transactie['description'],
|
||||
"status" => (int) $transactie['status']
|
||||
);
|
||||
}
|
||||
|
||||
public static function setTransactionStatus($id, $status)
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$db = $container->db;
|
||||
|
||||
$transactie = $db->idobt->where("transactieId", $id)->limit(1);
|
||||
if (!$transactie) {
|
||||
throw new \Exception("Transaction not found");
|
||||
}
|
||||
|
||||
$transactie->update(array(
|
||||
"status" => $status
|
||||
));
|
||||
|
||||
if (!$transactie) {
|
||||
throw new \Exception("Failed to update status");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,16 +16,18 @@ use Inforbank\Application;
|
||||
*
|
||||
* @author Sjelm
|
||||
*/
|
||||
class Overboekingen {
|
||||
class Overboekingen
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @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
|
||||
* @param string $omschrijving De omschrijving van de overoeking
|
||||
* $param string $type Het type overboeking
|
||||
*/
|
||||
public static function createOverboeking($van, $naar, $bedrag, $omschrijving, $type){
|
||||
public static function createOverboeking($van, $naar, $bedrag, $omschrijving, $type)
|
||||
{
|
||||
$rekeningen = Rekeningen::getCurrentUserRekeningen();
|
||||
|
||||
$vanRekening = false;
|
||||
@ -59,7 +61,7 @@ class Overboekingen {
|
||||
|
||||
//TODO geldigheid bedrag onderzoeken
|
||||
//$bedragValue = (double) $bedrag;
|
||||
if (strlen($omschrijving) > 40) {
|
||||
if (strlen($omschrijving) > 40 && $type !== "id") {
|
||||
//error: te lange omschrijving
|
||||
throw new Exception("De omschrijving is te lang");
|
||||
}
|
||||
|
Reference in New Issue
Block a user