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,197 @@
<?php
/**
* SOTESHOP/stPlatnosciPlPlugin
*
* Ten plik należy do aplikacji stPlatnosciPlPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stPlatnosciPlPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: actions.class.php 15168 2011-09-20 11:56:58Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stPlatnosciPlBackendActions
*
* @package stPlatnosciPlPlugin
* @subpackage actions
*/
class stPlatnosciPlBackendActions extends stActions
{
/**
* Wyświetla konfigurację modułu
*/
public function executeIndex()
{
$this->labels = $this->getLabels();
$this->config = stConfig::getInstance($this->getContext());
if (!$this->config->get('configuration_check')) {
$notice = $this->getContext()->getI18n()->__('Jeśli nie masz jeszcze konta w PayU, załóż je')."&nbsp;".'<a href="https://registration.payu.com/boarding/#/form?lang=pl&nsf=true&origin=pl&partnerId=p3h2qb6k" target="_blank">'.$this->getContext()->getI18n()->__('tutaj').'</a>';
$this->setFlash("info", $notice, false);
}
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->config->setFromRequest('config');
$data = $this->getRequestParameter('config');
$this->config->set('configuration_check', false);
foreach ($this->getCurrencies() as $currency)
{
$shortcut = $currency->getShortcut();
$value = $this->config->get($shortcut);
if (isset($value['enabled']) && $value['enabled'])
{
$this->config->set('configuration_check', true);
break;
}
}
$this->config->save();
$this->setFlash('notice', 'Twoje zmiany zostały zapisane');
}
$this->config->load();
}
public function validateIndex()
{
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
$data = $this->getRequestParameter('config');
$i18n = $this->getContext()->getI18N();
foreach ($this->getCurrencies() as $currency)
{
$shortcut = $currency->getShortcut();
if (!isset($data[$shortcut]))
{
continue;
}
$ok = true;
if (!$data[$shortcut]['pos_id'] || !$data[$shortcut]['md5_secound_key'])
{
$ok = false;
$this->getRequest()->setError('config{'.$shortcut.'}{currency}', $shortcut);
}
if (!$data[$shortcut]['pos_id'])
{
$this->getRequest()->setError('config{'.$shortcut.'}{pos_id}', $i18n->__('Proszę uzupełnić pole.'));
}
if (!$data[$shortcut]['md5_secound_key'])
{
$this->getRequest()->setError('config{'.$shortcut.'}{md5_secound_key}', $i18n->__('Proszę uzupełnić pole.'));
}
if ($ok)
{
try
{
OpenPayU_Configuration::setEnvironment('secure');
OpenPayU_Configuration::setMerchantPosId($data[$shortcut]['pos_id']); // POS ID (Checkout)
OpenPayU_Configuration::setSignatureKey($data[$shortcut]['md5_secound_key']);
$order['notifyUrl'] = 'http://localhost/';
$order['customerIp'] = $_SERVER['REMOTE_ADDR'];
$order['merchantPosId'] = OpenPayU_Configuration::getMerchantPosId();
$order['description'] = 'New order';
$order['currencyCode'] = $shortcut;
$order['totalAmount'] = 3200;
$order['products'][0]['name'] = 'Product1';
$order['products'][0]['unitPrice'] = 3200;
$order['products'][0]['quantity'] = 1;
$result = OpenPayU_Order::create($order);
if ($result->getStatus() == 'ERROR_INCONSISTENT_CURRENCIES')
{
$this->getRequest()->setError('config{'.$shortcut.'}{currency}', $shortcut);
$this->getRequest()->setError('config{'.$shortcut.'}{payu}', $i18n->__('Brak zgodności z walutą "sklepu" PayU (Podaj konfigurację punktu płatności zgodną z wybraną walutą lub skontaktuj się z PayU)'));
}
}
catch(OpenPayU_Exception_Authorization $e)
{
$this->getRequest()->setError('config{'.$shortcut.'}{currency}', $shortcut);
$this->getRequest()->setError('config{'.$shortcut.'}{pos_id}', $i18n->__('Podana konfiguracja punktu płatności jest nieprawidłowa'));
$this->getRequest()->setError('config{'.$shortcut.'}{md5_secound_key}', $i18n->__('Podana konfiguracja punktu płatności jest nieprawidłowa'));
}
catch(OpenPayU_Exception $e)
{
$this->getRequest()->setError('config{'.$shortcut.'}{currency}', $shortcut);
$this->getRequest()->setError('config{'.$shortcut.'}{payu}', $i18n->__('Wystąpił problem z połączeniem z usługą PayU (%%error%%)', array('%%error%%' => $e->getMessage())));
}
}
}
}
return !$this->getRequest()->hasErrors();
}
public function getCurrencies()
{
if (!isset($this->currencies))
{
$this->currencies = CurrencyPeer::doSelectActive();
}
return $this->currencies;
}
public function getLabels()
{
$i18n_posid = $this->getContext()->getI18n()->__('Id punktu płatności (pos_id)');
$i18n_md5 = $this->getContext()->getI18n()->__('Drugi klucz (md5)');
$i18n_curency = $this->getContext()->getI18n()->__('Waluta');
$labels = array();
foreach ($this->getCurrencies() as $currency)
{
$shortcut = $currency->getShortcut();
$labels['config{'.$shortcut.'}{payu}'] = 'PayU';
$labels['config{'.$shortcut.'}{currency}'] = $i18n_curency;
$labels['config{'.$shortcut.'}{pos_id}'] = $i18n_posid;
$labels['config{'.$shortcut.'}{md5_secound_key}'] = $i18n_md5;
}
return $labels;
}
/**
* Akcja w przypadku błędu w uzupełnianiu pól
*/
public function handleErrorIndex()
{
$this->webRequest = new stWebRequest();
$this->config = stConfig::getInstance($this->getContext());
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->config->setFromRequest('config');
}
$this->labels = $this->getLabels();
return sfView::SUCCESS;
}
}

View File

@@ -0,0 +1,13 @@
<?php
class stPlatnosciPlBackendComponents extends sfComponents
{
public function executeListMenu()
{
}
}
?>

View File

@@ -0,0 +1,19 @@
<div class="list-menu">
<ul>
<li class="selected">
<?php echo link_to(__('PayU'),'stPlatnosciPlBackend/index')?>
</li>
<li>
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
<a href="https://www.sote.pl/docs/payu" target="_blank"><?php echo __('Dokumentacja'); ?></a>
<?php else: ?>
<a href="https://www.soteshop.com/docs/payu" target="_blank"><?php echo __('Documentation'); ?></a>
<?php endif; ?>
</li>
</ul>
</div>
<div class="clr"></div>

View File

@@ -0,0 +1,49 @@
<?php use_helper('I18N', 'stAdminGenerator', 'Validation');?>
<?php echo st_get_admin_head('stPlatnosciPlPlugin', __('PayU', array()), __('',array()),array('stPayment'));?>
<?php st_view_slot_start('application-menu') ?>
<?php st_include_component('stPlatnosciPlBackend', 'listMenu') ?>
<?php st_view_slot_end() ?>
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels));?>
<?php echo form_tag('platnoscipl/index', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form', 'class' => 'admin_form'));?>
<fieldset>
<div class="content">
<div class="row">
<?php echo st_admin_get_form_field('config[autoredirect]', __('Automatyczne przekierowanie'), 1, 'checkbox_tag', array('checked' => $config->get('autoredirect'), 'help' => __('Przekierowuje automatycznie na stronę płatności po złożeniu zamówienia'))) ?>
</div>
<div class="clr"></div>
</div>
</fieldset>
<?php foreach ($currencies as $currency): $shortcut = $currency->getShortcut(); $current = $config->get($shortcut); $enabled = $current ? $current['enabled'] : false; ?>
<fieldset>
<h2><?php echo __('Waluta');?> <?php echo $shortcut ?></h2>
<div class="content">
<div class="row">
<?php echo st_admin_get_form_field('config['.$shortcut.'][enabled]', __('Aktywuj'), 1, 'checkbox_tag', array('checked' => $enabled, 'class' => 'payu_enable', 'size' => '60')) ?>
<div class="clr"></div>
</div>
<div class="row">
<?php echo st_admin_get_form_field('config['.$shortcut.'][pos_id]', __('Numer PosId'), $current ? $current['pos_id'] : '', 'input_tag', array('required' => true, 'disabled' => !$enabled, 'size' => '60')) ?>
<div class="clr"></div>
</div>
<div class="row">
<?php echo st_admin_get_form_field('config['.$shortcut.'][md5_secound_key]', __('Drugi klucz (md5)'), $current ? $current['md5_secound_key'] : '', 'input_tag', array('required' => true, 'disabled' => !$enabled, 'size' => '60')) ?>
<div class="clr"></div>
</div>
</div>
</fieldset>
<?php endforeach ?>
<?php echo st_get_admin_actions(array(
array('type' => 'save', 'label' => __('Zapisz', null, 'stAdminGeneratorPlugin'))
)) ?>
</form>
<div class="clr"></div>
<?php echo st_get_admin_foot();?>
<script type="text/javascript">
jQuery(function($) {
$('.payu_enable').change(function() {
var checkbox = $(this);
checkbox.closest('.content').find('input[type=text]').attr('disabled', !checkbox.prop('checked'))
});
});
</script>

View File

@@ -0,0 +1,144 @@
<?php
/**
* SOTESHOP/stPlatnosciPlPlugin
*
* Ten plik należy do aplikacji stPlatnosciPlPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stPlatnosciPlPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: actions.class.php 5335 2010-05-28 11:39:59Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stPlatnosciPlFrontendActions
*
* @package stPlatnosciPlPlugin
* @subpackage actions
*/
class stPlatnosciPlFrontendActions extends stActions
{
/**
* Pozytywny powrót z płatności
*/
public function executeReturnSuccess()
{
if ($this->hasRequestParameter('error'))
{
return $this->redirect('@stPlatnosciPlPlugin?action=returnFail');
}
$this->smarty = new stSmarty($this->getModuleName());
}
/**
* Negatywny powrót z płatności
*/
public function executeReturnFail()
{
$this->smarty = new stSmarty($this->getModuleName());
$webpage = WebpagePeer::retrieveByState('CONTACT');
if ($webpage)
{
sfLoader::loadHelpers(array('Helper', 'stUrl'));
$this->smarty->assign('contact_url', st_url_for('stWebpageFrontend/index?url='.$webpage->getFriendlyUrl()));
}
}
public function executeProcessPayment()
{
$this->smarty = new stSmarty('stPlatnosciPlFrontend');
$api = new stPlatnosciPl();
$order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('id'), $this->getRequestParameter('hash'));
try
{
$url = $api->getOrderFormUrl($order);
if ($url)
{
return $this->renderJSON(array('redirect' => $url));
}
}
catch (OpenPayU_Exception $e)
{
stPlatnosciPl::log("Process Payment - Exception: in file ".$e->getFile().' on line '.$e->getLine().' with message'.$e->getMessage());
}
sfLoader::loadHelpers(array('Helper', 'stUrl'));
return $this->renderJSON(array('redirect' => st_url_for('stPlatnosciPlFrontend/returnFail?type=process')));
}
/**
* Odbieranie statusu transakcji
*/
public function executeStatusReport()
{
$body = file_get_contents('php://input');
$data = trim($body);
stPlatnosciPl::log("Status Report Request: ".$data);
$api = new stPlatnosciPl();
try
{
$order = $api->getOrderNotify($data);
} catch (OpenPayU_Exception $e) {
stPlatnosciPl::log("Process Payment - Exception: in file ".$e->getFile().' on line '.$e->getLine().' with message'.$e->getMessage());
throw $e;
}
if ($order && $order->status == 'COMPLETED')
{
$payment_id = null;
if ($this->hasRequestParameter('id'))
{
$order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('id'), $this->getRequestParameter('hash'));
if (null !== $order)
{
$payment = $order->getOrderPayment();
if (!$payment)
{
stPlatnosciPl::log("Status Report: Payment for order id {$this->getRequestParameter('id')} does not exist");
}
}
else
{
stPlatnosciPl::log("Status Report: Order with id {$this->getRequestParameter('id')} does not exist");
}
}
else
{
list($id) = explode(':', $order->extOrderId);
$payment = PaymentPeer::retrieveByPK($id);
if (!$payment)
{
stPlatnosciPl::log("Status Report: Payment with id $id does not exist");
}
}
if ($payment)
{
$payment->setStatus(true);
$payment->save();
stPlatnosciPl::log("Status Report: Payment with id {$payment->getId()} paid successfully");
}
}
return $this->renderText('OK');
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* SOTESHOP/stPlatnosciPlPlugin
*
* Ten plik należy do aplikacji stPlatnosciPlPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stPlatnosciPlPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: components.class.php 10 2009-08-24 09:32:18Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stPlatnosciPlFrontendComponents
*
* @package stPlatnosciPlPlugin
* @subpackage actions
*/
class stPlatnosciPlFrontendComponents extends sfComponents {
/**
* Pokazywanie formularza płatności
*/
public function executeShowPayment() {
$this->smarty = new stSmarty('stPlatnosciPlFrontend');
$api = new stPlatnosciPl();
$order = stPaymentType::getOrderInSummary();
try
{
$url = $api->getOrderFormUrl($order);
if ($url)
{
return $this->getController()->redirect($url);
}
}
catch (OpenPayU_Exception $e)
{
stPlatnosciPl::log("stPlatnosciPl::getOrderFormUrl() - Exception:\n".$e->getFile().':'.$e->getLine().':'.$e->getMessage());
}
$webpage = WebpagePeer::retrieveByState('CONTACT');
if ($webpage)
{
sfLoader::loadHelpers(array('Helper', 'stUrl'));
$this->smarty->assign('contact_url', st_url_for('stWebpageFrontend/index?url='.$webpage->getFriendlyUrl()));
}
}
}

View File

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

View File

@@ -0,0 +1 @@
<?php echo $sig;

View File

@@ -0,0 +1,11 @@
<?php
st_theme_use_stylesheet('stPayment.css');
if ($sf_request->getParameter('type') == 'process')
{
$smarty->display('platnoscipl_show_payment.html');
}
else
{
$smarty->display('platnoscipl_return_fail.html');
}

View File

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

View File

@@ -0,0 +1,8 @@
<div class="st_application">
<h1 class="st_title">
{__ text="Płatność"}
</h1>
<p style="text-align: center; margin-bottom: 20px;">
{__ text="Płatność nie została zrealizowana."}
</p>
</div>

View File

@@ -0,0 +1,8 @@
<div class="st_application">
<h1 class="st_title">
{__ text="Płatność"}
</h1>
<p style="text-align: center; margin-bottom: 20px;">
{__ text="Dziękujemy za dokonanie płatności."}
</p>
</div>

View File

@@ -0,0 +1,48 @@
<div id="st_frame_platnoscipl">
{if $check_configuration == true}
<div id="st_txt_platnoscipl">
<p>{__ text="Wybierz płatność i kliknij przycisk"} <b>{__ text='"Zapłać"'}</b> {__ text="aby przejść do serwisu PayU."}</p>
</div>
<div class="st_logo_platnosci">
<img src="/images/frontend/theme/default/stPlatnosciPlPlugin/logo.png" alt="Płatności.pl"/>
</div>
{$form_start}
{$hidden_pos_id}
{$hidden_pos_auth_key}
{$hidden_session_id}
{$hidden_amount}
{$hidden_desc}
{$hidden_order_id}
{$hidden_first_name}
{$hidden_last_name}
{$hidden_street}
{$hidden_street_hn}
{$hidden_street_an}
{$hidden_city}
{$hidden_post_code}
{$hidden_email}
{$hidden_language}
{$hidden_client_ip}
<script language="JavaScript" type="text/javascript" src="https://www.platnosci.pl/paygw/UTF/js/{$pos_id}/{$md5_first_key}/paytype.js"></script>
<script language="JavaScript" type="text/javascript">{$variant_name}</script>
{if $payback == true}
<br class="st_clear-all" />
<div id="st_form-payment-input_tag" class="st_row">
{$payback_login_label}
<div class="st_field">
{$payback_login}
</div>
</div>
{/if}
<div id="st_form-payment-submit" class="st_button-container">
<div class="st_button st_align-right">
<div class="st_button-left">
{$pay_submit}
</div>
</div>
</div>
</form>
{else}
{__ text="Płatność została błędnie skonfigurowana."}
{/if}
</div>

View File

@@ -0,0 +1,26 @@
<div id="st_box_payment" class="box roundies">
<div class="content">
<p><img src="/plugins/stPlatnosciPlPlugin/images/payu.png" alt=""/></p>
<p>{__ text="Płatność nie została zrealizowana."}</p>
{if $contact_url}
<form action="{$contact_url}" class="buttons" method="get">
<p>
<button type="submit" class="important roundies">
<span class="arrow_right">{__ text="Skontaktuj się z nami"}</span>
</button>
</p>
</form>
{/if}
</div>
</div>
{literal}
<script type="text/javascript">
jQuery(function($) {
$('#st_box_payment form').submit(function() {
var form = $(this);
window.location = form.attr('action');
return false;
});
});
</script>
{/literal}

View File

@@ -0,0 +1,24 @@
<div id="st_box_payment" class="box roundies">
<div class="content">
<p><img src="/plugins/stPlatnosciPlPlugin/images/payu.png" alt=""/></p>
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
<form action="{$homepage_url}" class="buttons" method="get">
<p>
<button type="submit" class="important roundies">
<span>{__ text="Wróć do zakupów" langCatalogue="stBasket"}</span>
</button>
</p>
</form>
</div>
</div>
{literal}
<script type="text/javascript">
jQuery(function($) {
$('#st_box_payment form').submit(function() {
var form = $(this);
window.location = form.attr('action');
return false;
});
});
</script>
{/literal}

View File

@@ -0,0 +1,26 @@
<div id="st_box_payment">
<img src="/plugins/stPlatnosciPlPlugin/images/payu.png" alt=""/><br />
<p style="text-align: center">
{__ text="Wystąpił problem z połączeniem się z serwisem PayU."}
{if $contact_url}
<form action="{$contact_url}" class="buttons" method="get">
<p>
<button type="submit" class="important roundies">
<span class="arrow_right">{__ text="Skontaktuj się z nami"}</span>
</button>
</p>
</form>
{/if}
</p>
</div>
{literal}
<script type="text/javascript">
jQuery(function($) {
$('#st_box_payment form').submit(function() {
var form = $(this);
window.location = form.attr('action');
return false;
});
});
</script>
{/literal}

View File

@@ -0,0 +1,23 @@
{set layout="one_column"}
<div id="payment">
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="PayU"}
</div>
<div class="panel-body text-center">
<p>
<img src="/plugins/stPlatnosciPlPlugin/images/payu.png" alt="" style="width: 150px" />
</p>
<p>
{__ text="Płatność nie została zrealizowana."}<br/>
</p>
{if $contact_url}
<p>
<a href="{$contact_url}" class="btn btn-primary">
{__ text="Skontaktuj się z nami"}
</a>
</p>
{/if}
</div>
</div>
</div>

View File

@@ -0,0 +1,15 @@
{set layout="one_column"}
<div id="payment">
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="PayU"}
</div>
<div class="panel-body text-center">
<p>
<img src="/plugins/stPlatnosciPlPlugin/images/payu.png" alt="" style="width: 150px" />
</p>
<p>{__ text="Dziękujemy za dokonanie płatności."}</p>
<a href="{$homepage_url}" class="btn btn-primary">{__ text="Wróć do zakupów" langCatalogue="stBasket"}</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,20 @@
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="PayU"}
</div>
<div id="payu-panel-body" class="panel-body text-center">
<p>
<img src="/plugins/stPlatnosciPlPlugin/images/payu.png" alt="" style="width: 150px" />
</p>
<p>
{__ text="Wystąpił problem z połączeniem się z serwisem PayU."}
</p>
{if $contact_url}
<p>
<a href="{$contact_url}" class="btn btn-primary">
{__ text="Skontaktuj się z nami"}
</a>
</p>
{/if}
</div>
</div>