first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<?php
class stEserviceFrontendActions extends stActions {
public function executeReturnSuccess() {
$this->smarty = new stSmarty($this->getModuleName());
$this->processPaymentByRequest();
}
public function executeReturnFail() {
$this->smarty = new stSmarty($this->getModuleName());
$this->processPaymentByRequest();
$this->contactPage = WebpagePeer::retrieveByState('CONTACT');
}
public function executeReturnPending() {
$this->smarty = new stSmarty($this->getModuleName());
$this->processPaymentByRequest();
}
protected function processPaymentByRequest() {
if ($this->getRequest()->getMethod() == sfRequest::POST) {
list(, $orderId) = explode('-', $this->getRequestParameter('OrderId'));
$amount = $this->getRequestParameter('Total');
$status = ucfirst($this->getRequestParameter('Response'));
if ($this->checkHash()) {
$stPayment = new stPayment();
$order = OrderPeer::retrieveByPK($orderId);
if ($order) {
$payment = $order->getOrderPayment();
if ($payment) {
switch ($status) {
case stEservice::PAYMENT_PENDING:
break;
case stEservice::PAYMENT_APPROVED:
$stPayment->confirmPayment($payment->getHash());
break;
case stEservice::PAYMENT_DECLINED:
$stPayment->cancelPayment($payment->getHash());
break;
}
}
}
}
}
}
protected function checkHash()
{
$stEservice = new stEservice();
$storeKey = $stEservice->getStoreKey();
$sep = "|";
$secureCount = 0;
$params = array();
foreach(explode($sep, $this->getRequestParameter('HASHPARAMS')) as $hashParam)
{
if($hashParam == "ClientId" || $hashParam == "Response" || $hashParam == "OrderId")
{
$secureCount++;
}
$params[] = $this->getRequestParameter($hashParam, '');
}
$hashParamsVal = implode($sep, $params);
$hash = base64_encode(hash('sha512', $hashParamsVal .$sep. $storeKey, true));
if($hashParamsVal != $this->getRequestParameter('HASHPARAMSVAL') || $hash != $this->getRequestParameter('HASH') || $secureCount != 3 || $this->getRequestParameter('TranType') != 'Auth') {
file_put_contents(sfConfig::get('sf_root_dir').'/log/eservice.txt', "[".date('d-m-Y H:i:s')."]\nHASHC: ".$hash."\nHASHO: ".$this->getRequestParameter('HASH')."\n"."\nPARAM1: ".$hashParamsVal."\nPARAM2: ".$this->getRequestParameter('HASHPARAMSVAL')."\n\nPOST:\n".var_export($_POST, true), FILE_APPEND);
return false;
}
return true;
}
}

View File

@@ -0,0 +1,42 @@
<?php
class stEserviceFrontendComponents extends sfComponents {
public function executeShowPayment() {
$this->smarty = new stSmarty('stEserviceFrontend');
if (stPaymentType::hasOrderInSummary()) {
$this->stEservice = new stEservice();
$this->stWebRequest = new stWebRequest();
$this->order = stPaymentType::getOrderInSummary();
$this->user = $this->order->getOrderUserDataBilling();
$this->lang = stPaymentType::getLanguage(array('PL', 'EN'), false);
$this->currency = stPaymentType::getCurrency($this->order->getId());
$this->orderId = time().'-'.$this->order->getId();
$postParameters = array(
'ClientId' => $this->stEservice->getClientId(),
'Password' => $this->stEservice->getPassword(),
'OrderId' => $this->orderId,
'Total' => $this->stEservice->parseAmount(stPayment::getUnpayedAmountByOrder($this->order)),
'Currency' => $this->currency->getCode(),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->stEservice->getTokenUrl());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postParameters, '', '&'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
list($status, $message) = explode('&', $response);
$this->tokenStatus = preg_match('/=ok$/i', $status);
$this->token = preg_replace('/^msg=/', '', $message);
}
$this->isSecure = $this->getRequest()->isSecure();
}
}

View File

@@ -0,0 +1,24 @@
<?php
st_theme_use_stylesheet('stPayment.css');
$smarty->assign('check_configuration', ($stEservice->checkPaymentConfiguration() && $tokenStatus));
if ($stEservice->checkPaymentConfiguration() && $tokenStatus) {
$smarty->assign('params', array(
'ClientId' => $stEservice->getClientId(),
'StoreType' => $stEservice->getStoreType(),
'Token' => $token,
'TranType' => 'Auth',
'Total' => $stEservice->parseAmount(stPayment::getUnpayedAmountByOrder($order)),
'Currency' => $currency->getCode(),
'OrderId' => $orderId,
'ConsumerName' => $user->getName(),
'ConsumerSurname' => $user->getSurname(),
'okUrl' => $sf_context->getController()->genUrl('@stEservicePlugin?action=returnSuccess', true),
'failUrl' => $sf_context->getController()->genUrl('@stEservicePlugin?action=returnFail', true),
'pendingUrl' => $sf_context->getController()->genUrl('@stEservicePlugin?action=returnPending', true),
'lang' => $lang,
'hashAlgorithm' => 'ver2',
));
$smarty->assign('url', $stEservice->getPostUrl());
$smarty->assign('description', stPaymentType::getSummaryDescriptionByOrderIdAndHash($order->getId()));
}
$smarty->display('eservice_show_payment.html');

View File

@@ -0,0 +1,4 @@
<?php
st_theme_use_stylesheet('stPayment.css');
$smarty->assign('contactLink', is_object($contactPage) ? url_for('stWebpageFrontend/index?url='.$contactPage->getFriendlyUrl()) : null);
$smarty->display('eservice_return_fail.html');

View File

@@ -0,0 +1,3 @@
<?php
st_theme_use_stylesheet('stPayment.css');
$smarty->display('eservice_return_pending.html');

View File

@@ -0,0 +1,3 @@
<?php
st_theme_use_stylesheet('stPayment.css');
$smarty->display('eservice_return_success.html');

View File

@@ -0,0 +1,8 @@
<div id="stPayment_return" class="box roundies">
<div class="title">
<h2>{__ text="Płatność"}</h2>
</div>
<div class="content">
<p>{__ text="Płatność nie została zrealizowana."}</p>
</div>
</div>

View File

@@ -0,0 +1,8 @@
<div id="stPayment_return" class="box roundies">
<div class="title">
<h2>{__ text="Płatność"}</h2>
</div>
<div class="content">
<p>{__ text="Płatność jest w trakcie realizacji."}</p>
</div>
</div>

View File

@@ -0,0 +1,8 @@
<div id="stPayment_return" class="box roundies">
<div class="title">
<h2>{__ text="Płatność"}</h2>
</div>
<div class="content">
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
</div>
</div>

View File

@@ -0,0 +1,21 @@
<div id="st_box_payment">
<img id="st_home" src="/images/frontend/theme/default2/stEservicePlugin/logo.png" alt="" style="margin: 20px 0px" />
<div>
{$description}
</div>
{if $check_configuration}
<form action="{$url}" method="get">
{foreach key=name item=value from=$params}
<input type="hidden" name="{$name}" value="{$value}" />
{/foreach}
<div class="buttons">
<button type="submit" class="important roundies">
<span class="arrow_right">{__ text="Zapłać"}</span>
</button>
</div>
<br class="clear" />
</form>
{else}
<br />{__ text="Płatność została błędnie skonfigurowana."}
{/if}
</div>

View File

@@ -0,0 +1,20 @@
{set layout="one_column"}
<div id="payment">
<div class="title">
<h1>{__ text="Płatność"}</h1>
</div>
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eService"}
</div>
<div class="panel-body text-center">
<p>
{__ text="Płatność nie została zrealizowana."}<br/>
{__ text="Skontaktuj się z nami." langCatalogue="stPayment"}
</p>
{if $contactLink}
<a href="{$contactLink}" class="btn btn-primary">{__ text="Kontakt" langCatalogue="stPayment"}</a>
{/if}
</div>
</div>
</div>

View File

@@ -0,0 +1,15 @@
{set layout="one_column"}
<div id="payment">
<div class="title">
<h1>{__ text="Płatność"}</h1>
</div>
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eService"}
</div>
<div class="panel-body text-center">
<p>{__ text="Płatność jest w trakcie realizacji."}</p>
<a href="/" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stPayment"}</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,15 @@
{set layout="one_column"}
<div id="payment">
<div class="title">
<h1>{__ text="Płatność"}</h1>
</div>
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eService"}
</div>
<div class="panel-body text-center">
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
<a href="/" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stPayment"}</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,23 @@
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="eService"}
</div>
<div class="panel-body text-center">
{if $check_configuration}
<img src="/images/frontend/theme/default2/stEservicePlugin/logo.png" alt="{__ text="eService"}" style="margin: 20px 0px" />
<div>
{$description}
</div>
<form action="{$url}" method="get">
{foreach key=name item=value from=$params}
<input type="hidden" name="{$name}" value="{$value}" />
{/foreach}
<button type="submit" class="btn btn-primary">
{__ text="Zapłać"}
</button>
</form>
{else}
{__ text="Płatność została błędnie skonfigurowana."}
{/if}
</div>
</div>