Payone, Shop, wizard
This commit is contained in:
parent
446bc4561b
commit
044a6bf253
28 changed files with 996 additions and 814 deletions
111
KasController.php
Normal file
111
KasController.php
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Input;
|
||||
use Session;
|
||||
use \SoapClient;
|
||||
|
||||
class KasController extends Controller
|
||||
{
|
||||
|
||||
|
||||
// Logindaten
|
||||
private $kas_user = 'w017f6e4'; // KAS-Logon
|
||||
private $kas_pass = '7mMJUF4YSVWNpp39'; // KAS-Passwort
|
||||
private $session_lifetime = 600; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung
|
||||
private $session_update_lifetime = 'Y'; // bei N läuft die Session nach <$session_lifetime> Sekunden ab, bei Y verlängert sich die Session mit jeder Benutzung
|
||||
private $CredentialToken = false;
|
||||
private $kas_flood_delay = 2;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->login();
|
||||
}
|
||||
|
||||
|
||||
public function action($func, $para = array()){
|
||||
|
||||
$this->checkSession($func);
|
||||
try
|
||||
{
|
||||
$Params = array(); // Parameter für die API-Funktion
|
||||
$SoapRequest = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl');
|
||||
$req = $SoapRequest->KasApi(json_encode(array(
|
||||
'KasUser' => $this->kas_user, // KAS-User
|
||||
'KasAuthType' => 'session', // Auth per Sessiontoken
|
||||
'KasAuthData' => $this->CredentialToken, // Auth-Token
|
||||
'KasRequestType' => $func, // API-Funktion
|
||||
'KasRequestParams' => $para // Parameter an die API-Funktion
|
||||
)));
|
||||
Session::put('flood_protection.'.$func, time() + $this->kas_flood_delay + 0.2);
|
||||
|
||||
if(isset($req['Response']['ReturnString']) && $req['Response']['ReturnString'] == "TRUE"){
|
||||
return $req['Response']['ReturnInfo'];
|
||||
}
|
||||
return $req;
|
||||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
{
|
||||
trigger_error(" Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
Verursacher: {$fault->faultactor},
|
||||
Details: {$fault->detail}", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function login(){
|
||||
|
||||
$this->checkSession('auth');
|
||||
try
|
||||
{
|
||||
|
||||
$SoapLogon = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl');
|
||||
$this->CredentialToken = $SoapLogon->KasAuth(json_encode(array(
|
||||
'KasUser' => $this->kas_user,
|
||||
'KasAuthType' => 'sha1',
|
||||
'KasPassword' => sha1($this->kas_pass),
|
||||
'SessionLifeTime' => $this->session_lifetime,
|
||||
'SessionUpdateLifeTime' => $this->session_update_lifetime
|
||||
)));
|
||||
Session::put('flood_protection.auth', time() + $this->kas_flood_delay + 0.2);
|
||||
|
||||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
{
|
||||
trigger_error("Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
Verursacher: {$fault->faultactor},
|
||||
Details: {$fault->detail}", E_USER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkSession($func)
|
||||
{
|
||||
$name = 'flood_protection.'.$func;
|
||||
|
||||
if(Session::exists($name)){
|
||||
$time_to_wait = (float)Session::get($name) - time();
|
||||
Session::forget($name);
|
||||
}else {
|
||||
$time_to_wait = 0;
|
||||
}
|
||||
if ( $time_to_wait >= 0 ) {
|
||||
usleep( intval( $time_to_wait*1000000 ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue