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;

View File

@@ -0,0 +1,34 @@
<?php
// parametr wywołania: id_order
require_once dirname(__FILE__).'/../../../../../config/config.inc.php';
include_once dirname(__FILE__).'/../../../config/ehpcfg.php';
include_once dirname(__FILE__).'/../HybridClient/PSHClient.php';
include_once dirname(__FILE__).'/../../../sql/ScbDbUtil.php';
$pshLocation = Configuration::get('SANTANDERCREDIT_SVC_LOCATION');
$pshLogin = Configuration::get('SANTANDERCREDIT_PSH_LOGIN');
$pshPass = Configuration::get('SANTANDERCREDIT_PSH_PASS');
$pshCrt = Configuration::get('SANTANDERCREDIT_CRT_FILE');
$shopNumber = trim(Configuration::get('SANTANDERCREDIT_SHOP_ID'));
$pshCrt = dirname(__FILE__).'/../../../CERT/' . trim($pshCrt);
$oid = Tools::getValue('id_order');
$shopAppNr = ScbDbUtil::getShopApplicationNumber($oid);
$client = new PSHClient($pshLogin, $pshPass, $pshLocation, $pshCrt, $shopNumber);
if($client->isActive()) {
$client->checkAppStatus([$shopAppNr]);
if($client->isCorrect and is_object($client->applications) and $client->applications->count() == 1){
//log request, response and perform notification
if(isset($client->applications[0]->ApplicationNumber)) {
ScbDbUtil::RegisterSuccessfullPshResponse($shopAppNr, $client->operationStatus, $client->applications[0]);
} else {
// response formalnie poprawny ale brak wniosku
// ScbDbUtil::LogIncorrectPshResponse($shopAppNr, $client->operationStatus, $client->applications[0]->CreditState);
ScbDbUtil::RegisterSuccessfullPshResponse($shopAppNr, $client->operationStatus, $client->applications[0]);
}
} else{
// bad request - log it
ScbDbUtil::LogIncorrectPshResponse($shopAppNr, $client->operationStatus, $client->lastException);
}
}
echo '{"isOk":"1"}';

View File

@@ -0,0 +1,27 @@
<?php
require_once dirname(__FILE__).'/../../../../../config/config.inc.php';
include_once dirname(__FILE__).'/../../../config/ehpcfg.php';
include_once dirname(__FILE__).'/../HybridClient/PSHClient.php';
include_once dirname(__FILE__).'/../../../sql/ScbDbUtil.php';
/**
* Sprawdzanie co 5 minut, wysyłany request max 20 wniosków w kolejności check_date
*/
$pshLocation = Configuration::get('SANTANDERCREDIT_SVC_LOCATION');
$pshLogin = Configuration::get('SANTANDERCREDIT_PSH_LOGIN');
$pshPass = Configuration::get('SANTANDERCREDIT_PSH_PASS');
$pshCrt = Configuration::get('SANTANDERCREDIT_CRT_FILE');
$shopNumber = trim(Configuration::get('SANTANDERCREDIT_SHOP_ID'));
$pshCrt = dirname(__FILE__).'/../../../CERT/' . trim($pshCrt);
// select top 20 wniosków (wszystkie niezakończone w kolejności check_date)
$ordersArray = ScbDbUtil::getOrders2check();
$client = new PSHClient($pshLogin, $pshPass, $pshLocation, $pshCrt, $shopNumber);
if(count($ordersArray) > 0 and $client->isActive()) {
// buduj request
// getApplicationState
$client->checkAppStatus($ordersArray);
// oznaczenie daty synchronizacji statusu na sprawdzanych wnioskach
ScbDbUtil::updateCheckDate($ordersArray);
// przetwarzanie odpowiedzi w pętli
ScbDbUtil::updateAppStates($client->applications, $client->operationStatus);
}

View File

@@ -0,0 +1,37 @@
<?php
// parametr wywołania: id_order musi, w przypadku tego skryptu, zawierać POSApplicationNumber (nie ma konwersji z id)
require_once dirname(__FILE__).'/../../../../../config/config.inc.php';
include_once dirname(__FILE__).'/../../../config/ehpcfg.php';
include_once dirname(__FILE__).'/../HybridClient/PSHClient.php';
include_once dirname(__FILE__).'/../../../sql/ScbDbUtil.php';
$pshLocation = Configuration::get('SANTANDERCREDIT_SVC_LOCATION');
$pshLogin = Configuration::get('SANTANDERCREDIT_PSH_LOGIN');
$pshPass = Configuration::get('SANTANDERCREDIT_PSH_PASS');
$pshCrt = Configuration::get('SANTANDERCREDIT_CRT_FILE');
$shopNumber = trim(Configuration::get('SANTANDERCREDIT_SHOP_ID'));
$pshCrt = dirname(__FILE__).'/../../../CERT/' . trim($pshCrt);
$oid = Tools::getValue('id_order');
$shopAppNr = $oid;
$responseJson = '{"isOk":"false"}';
$client = new PSHClient($pshLogin, $pshPass, $pshLocation, $pshCrt, $shopNumber);
if($client->isActive()) {
$client->checkAppStatus([$shopAppNr]);
if($client->isCorrect and is_object($client->applications) and $client->applications->count() == 1){
//log request, response and perform notification
if(isset($client->applications[0]->ApplicationNumber)) {
ScbDbUtil::RegisterSuccessfullPshResponse($shopAppNr, $client->operationStatus, $client->applications[0]);
$responseJson = '{"isOk":"true"}';
} else {
// response formalnie poprawny ale brak wniosku
// ScbDbUtil::LogIncorrectPshResponse($shopAppNr, $client->operationStatus, $client->applications[0]->CreditState);
ScbDbUtil::RegisterSuccessfullPshResponse($shopAppNr, $client->operationStatus, $client->applications[0]);
$responseJson = '{"isOk":"true"}';
}
} else{
// bad request - log it
ScbDbUtil::LogIncorrectPshResponse($shopAppNr, $client->operationStatus, $client->lastException);
}
}
echo $responseJson;

View File

@@ -0,0 +1,20 @@
<?php
// parametr wywołania: id_order
require_once dirname(__FILE__).'/../../../../../config/config.inc.php';
include_once dirname(__FILE__).'/../../../config/ehpcfg.php';
include_once dirname(__FILE__).'/../HybridClient/PSHClient.php';
include_once dirname(__FILE__).'/../../../sql/ScbDbUtil.php';
$pshLocation = Configuration::get('SANTANDERCREDIT_SVC_LOCATION');
$pshLogin = Configuration::get('SANTANDERCREDIT_PSH_LOGIN');
$pshPass = Configuration::get('SANTANDERCREDIT_PSH_PASS');
$pshCrt = Configuration::get('SANTANDERCREDIT_CRT_FILE');
$shopNumber = trim(Configuration::get('SANTANDERCREDIT_SHOP_ID'));
$pshCrt = dirname(__FILE__).'/../../../CERT/' . trim($pshCrt);
$client = new PSHClient($pshLogin, $pshPass, $pshLocation, $pshCrt, $shopNumber);
if($client->isActive()) {
echo 'OK';
} else {
echo 'Błąd';
}

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;

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;