This commit is contained in:
2025-03-09 23:50:32 +01:00
parent 1e498b41c7
commit 67c05416ac
190 changed files with 8061 additions and 3363 deletions

View File

@@ -0,0 +1,9 @@
<?php
class AppStateDocument {
public $Identity;
public $ShopApplicationNumbers;
public function __construct($i, $a){
$this->Identity = $i;
$this->ShopApplicationNumbers = $a;
}
};

View File

@@ -0,0 +1,44 @@
<?php
class Application {
/**
* Agreement date
*/
public $AgreementDate;
/**
* Credit Agreement number
*/
public $AgreementNumber;
/**
* Credit application number
*/
public $ApplicationNumber;
/**
* Application state change date
*/
public $ChangeDate;
/**
* Application state
*/
public $CreditState;
/**
* Downpayment(reduces total price in credit application)
*/
public $Downpayment;
/**
* This is order number. In PrestaShop - order reference (in previous module versions it was order id)
*/
public $ShopApplicationNumber;
/**
* Shop number (in the Bank database)
*/
public $ShopNumber;
/**
* Total Price paid for the order
*/
public $TotalPrice;
public $check_date;
}

View File

@@ -0,0 +1,15 @@
<?php
class ClientIdentity {
public $Login;
public $Password;
/*sklep testowy 99995 mozna wykorzystać jeśli jest przypisany do loginu sklepu.
Jeśli nie - testy można wykonywać na własnym sklepie.*/
public $ShopNumber;
public function __construct($Login, $Password, $ShopNumber) {
$this->Login = $Login;
$this->Password = $Password;
$this->ShopNumber = $ShopNumber;
}
};

View File

@@ -0,0 +1,19 @@
<?php
class SimulationResult {
public $APR;
public $AdjustmentInstalmentAmount;
public $Clause;
public $CommissionAmount;
public $CreditAmount;
public $Downpayment;
public $FirstInstallmentDate;
public $InstalmentAmount;
public $InstalmentsNumber;
public $InterestAmount;
public $InterestRate;
public $TotalAdditionalFee;
public $TotalAmountToPay;
public $TotalCreditCost;
}

View File

@@ -0,0 +1,10 @@
<?php
class ISActiveResult{
public $ErrorCode;
public $IsCorrect;
public $LogMarker;
public $Message;
public $UserMessage;
}

View File

@@ -0,0 +1,9 @@
<?php
class OperationStatus{
public $ErrorCode;
public $IsCorrect;
public $LogMarker;
public $Message;
public $UserMessage;
}

View File

@@ -0,0 +1,152 @@
<?php
include_once "Application.php";
include_once "AppStateDocument.php";
include_once "ClientIdentity.php";
include_once "FinancialDataResult.php";
include_once "IsActiveResult.php";
include_once "OperationStatus.php";
include_once "Simulation.php";
class PSHClient {
private $client;
private $login;
private $pass;
private $pemCert;
private $serviceLocation;
private $shopNumber;
public $applications;
public $operationStatus;
public $lastException;
public $isCorrect;
public $simulationResult;
public function __construct($login, $pass, $serviceLocation, $pemCert, $shopNumber) {
$this->applications = new ArrayObject();
$this->operationStatus = new OperationStatus();
$this->login = $login;
$this->pass = $pass;
$this->serviceLocation = $serviceLocation;
$this->pemCert = $pemCert;
$this->shopNumber = $shopNumber;
$wsdl = $serviceLocation . "?wsdl";
$this->client = new SoapClient(
$wsdl,
array(
'local_cert' => $pemCert,
'verify_peer' => false,
'exceptions' => 0,
'cache_wsdl' => WSDL_CACHE_NONE,
'passphrase' => $pass,
'location' => $serviceLocation
)
);
}
public function checkAppStatus($arrayOfOrderReference){
$this->lastException = null;
$this->operationStatus = new OperationStatus();
$this->isCorrect = false;
$this->applications = new ArrayObject();
$identyfikacja = new ClientIdentity($this->login, $this->pass,$this->shopNumber);
try {
$resp = $this->client->GetApplicationState(
new AppStateDocument($identyfikacja, $arrayOfOrderReference)
);
if ($this->validateResponse($resp)) {
$ap = $resp->GetApplicationStateResult->Applications->ApplicationData;
if (is_array($ap)){
$this->applications = new ArrayObject($ap);
} elseif (is_object($ap)){
$this->applications->append($ap);
} else {
$this->isCorrect = false;
$this->lastException = "Bad response structure: !no Application object!";
}
}
}
catch(Exception $e) {
$this->lastException = $e;
}
}
private function validateResponse($response) : bool{
$isOk = true;
// var_dump($response);
$msg = "Bad response structure: ";
if(!is_object($response)){
$isOk = false;
$msg= $msg . " !response is not object!";
};
if($isOk and !is_object($response->GetApplicationStateResult)){
$isOk = false;
$msg= $msg . " !GetApplicationStateResult is not object!";
};
if($isOk and !is_object($response->GetApplicationStateResult->OperationStatus)){
$isOk = false;
$msg= $msg . " !response->GetApplicationStateResult->OperationStatus is not object!";
};
if($isOk and !isset($response->GetApplicationStateResult->OperationStatus->IsCorrect)){
$isOk = false;
$msg= $msg . " !response->GetApplicationStateResult->OperationStatus->IsCorrect is not set!";
};
$this->isCorrect = $isOk;
if($isOk) {
$this->operationStatus = $response->GetApplicationStateResult->OperationStatus;
$this->isCorrect = $response->GetApplicationStateResult->OperationStatus->IsCorrect;
$this->lastException = $response->GetApplicationStateResult->OperationStatus->Message;
if($this->isCorrect and !is_object($response->GetApplicationStateResult->Applications)){
$this->isCorrect = false;
$msg= $msg . " !response->GetApplicationStateResult->Applications is not object!";
$this->lastException = $msg;
};
} else{
$this->lastException = $msg;
}
return $this->isCorrect;
}
/**
* $dnp downpayment
* $inr installment number
* $prd product/credit line
* $price
*/
public function calculateCredit($dnp, $inr, $prd, $price){
$this->lastException = null;
$this->simulationResult = null;
$this->isCorrect = false;
$identyfikacja = new ClientIdentity($this->login, $this->pass,$this->shopNumber);
try {
$resp = $this->client->GetFinancialData(
new FinancialDataDocument(
new Identyfikacja(), new Simulation($dnp, $inr, $prd, $price)));
$this->operationStatus = $resp->GetFinancialDataResult->OperationStatus;
$this->simulationResult = $resp->GetFinancialDataResult->SimulationResult;
$this->isCorrect = $this->operationStatus->IsCorrect;
}
catch(Exception $e) {
$this->lastException = $e;
}
}
public function isActive(){
$this->lastException = null;
try {
$resp = $this->client->IsActive();
$this->isActive = $resp->IsActiveResult;
$this->isCorrect = true;
}
catch(Exception $e) {
$this->lastException = $e;
$this->isCorrect = false;
}
return $this->isCorrect;
}
}

View File

@@ -0,0 +1,14 @@
<?php
class Simulation {
public $Downpayment;
public $InstalmentsNumber;
public $ProductNumber;
public $TotalPrice;
public function __construct($dnp, $inr, $prd, $price){
$this->Downpayment = $dnp;
$this->InstalmentsNumber = $inr;
$this->ProductNumber = $prd;
$this->TotalPrice = $price;
}
};

View File

@@ -0,0 +1,34 @@
<?php
/**
* 2007-2021 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2021 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;