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,226 @@
<?php
/**
* SOTESHOP/stPrzelewy24Plugin
*
* Ten plik należy do aplikacji stPrzelewy24Plugin 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 stPrzelewy24Plugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: actions.class.php 10909 2011-02-09 09:43:43Z pawel $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stPrzelewy24BackendActions
*
* @package stPrzelewy24Plugin
* @subpackage actions
*/
class stPrzelewy24BackendActions extends autoStPrzelewy24BackendActions
{
public function executeConfig()
{
$result = parent::executeConfig();
if (!$this->config->get('enabled'))
{
$i18n = $this->getContext()->getI18n();
$this->setFlash('info', '<a target="_parent" href="https://panel.przelewy24.pl//rejestracja.php?a=assign_partner&idp=153178" >'.$i18n->__('Zarejestruj się w Przelewy24, aby utworzyć konto.').'</a>');
}
return $result;
}
protected function loadConfigOrCreate()
{
$config = parent::loadConfigOrCreate();
if ($this->getRequest()->getMethod() != sfRequest::POST)
{
$this->hideFields($config);
}
return $config;
}
protected function updateConfigFromRequest()
{
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
parent::updateConfigFromRequest();
$data = $this->getRequestParameter('config');
if (!isset($data['highlighted_for_product']))
{
$this->config->set('highlighted_for_product', []);
}
if (!isset($data['highlighted_for_basket']))
{
$this->config->set('highlighted_for_basket', []);
}
}
$this->hideFields($this->config);
}
protected function saveConfig()
{
$this->config->set('has_valid_configuration', true);
parent::saveConfig();
$api = new stPrzelewy24();
$paymentTypes = $api->getBasketPaymentTypes(true);
$paymentMethods = $api->getPaymentMethods();
if ($paymentMethods)
{
if ($this->hasRequestParameter('fake_paypo'))
{
$paymentMethods[227] = new stdClass();
$paymentMethods[227]->status = true;
}
foreach (stPrzelewy24::HIGHLIGHTED as $type => $current)
{
$id = $current['id'];
if (!isset($paymentTypes[$type]))
{
$paymentType = new PaymentType();
$paymentType->setCulture(stLanguage::getOptLanguage());
$paymentType->setName($current['name']);
$paymentType->setHideForDeliveryConfiguration(true);
$paymentType->setModuleName('stPrzelewy24');
if (isset($id))
{
$paymentType->setConfigurationParameter('payment_channel', $id);
}
$paymentType->setConfigurationParameter('type', $type);
$paymentTypes[$type] = $paymentType;
}
$paymentTypes[$type]->setActive($this->config->get('enabled') && isset($paymentMethods[$id]) && $paymentMethods[$id]->status && in_array($type, $this->config->get('highlighted_for_basket', [])));
}
}
if (!isset($paymentTypes['default']))
{
$paymentType = new PaymentType();
$paymentType->setCulture(stLanguage::getOptLanguage());
$paymentType->setName('Przelewy24');
$paymentType->setModuleName('stPrzelewy24');
$paymentTypes['default'] = $paymentType;
}
$paymentTypes['default']->setActive($this->config->get('enabled'));
foreach ($paymentTypes as $paymentType)
{
$paymentType->save();
}
stNotification::getInstance()->markAllAsRead('stPrzelewy24Plugin');
}
protected function getConfigLabels()
{
$i18n = $this->getContext()->getI18n();
$labels = parent::getConfigLabels();
$labels['api'] = 'Przelewy24';
return $labels;
}
public function validateConfig()
{
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
$i18n = $this->getContext()->getI18N();
$request = $this->getRequest();
if ($request->getMethod() == sfRequest::POST)
{
$data = $this->getRequestParameter('config');
if (!isset($data['enabled']))
{
return true;
}
if (!$data['przelewy24_id'])
{
$request->setError('config{przelewy24_id}', $i18n->__('Uzupełnij pole'));
}
if (!$data['salt'])
{
$request->setError('config{salt}', $i18n->__('Uzupełnij pole'));
}
if (!$data['report_key'] && $data['payment_channels_enabled'])
{
$request->setError('config{report_key}', $i18n->__('Uzupełnij pole'));
}
if (!$request->hasErrors())
{
$api = new stPrzelewy24($data['przelewy24_id'], $data['salt'], $data['report_key'], isset($data['test']) && $data['test']);
try
{
$api->testConnection();
}
catch(stPrzelewyException $e)
{
$error = $i18n->__($e->getMessage());
$request->setError('api', $i18n->__('Wystąpił problem z połączeniem sprawdź czy wprowadzone dane są prawidłowe (Zwrócony błąd: "%error%")', array(
'%error%' => $error
)));
}
}
}
elseif (stConfig::getInstance('stPrzelewy24Backend')->get('enabled'))
{
$api = new stPrzelewy24();
try
{
$api->testConnection();
}
catch(stPrzelewyException $e)
{
$error = $i18n->__($e->getMessage());
$request->setError('api', $i18n->__('Wystąpił problem z połączeniem sprawdź czy wprowadzone dane są prawidłowe (Zwrócony błąd: "%error%")', array(
'%error%' => $error
)));
}
}
return !$request->hasErrors();
}
protected function hideFields(stConfig $config)
{
if (!$config->get('payment_channels_enabled'))
{
$this->hideField('report_key');
$this->hideField('channels');
$this->hideField('highlighted_for_product');
$this->hideField('highlighted_for_basket');
}
}
}

View File

@@ -0,0 +1,5 @@
<?php
class stPrzelewy24BackendComponents extends autoStPrzelewy24BackendComponents
{
}

View File

@@ -0,0 +1,30 @@
generator:
param:
model_class: false
title: "Przelewy24"
route: "@stPrzelewy24Plugin"
icon: "stPrzelewy24Plugin"
documentation:
pl: "https://www.sote.pl/docs/przelewy24"
en: "https://www.soteshop.com/docs/przelewy24"
config:
use_helper: [stPrzelewy24]
display:
"NONE": [enabled, payment_channels_enabled, test, autoredirect, przelewy24_id, salt, report_key, _channels, highlighted_for_product, highlighted_for_basket]
fields:
enabled: {name: "Włącz", type: checkbox_tag}
payment_channels_enabled: {name: "Włącz wybór kanałów płatności", type: "checkbox_tag"}
test: {name: "Tryb testowy", type: checkbox_tag}
autoredirect: {name: "Automatyczne przekierowanie", type: checkbox_tag, help: "Przekierowuje automatycznie na stronę płatności po złożeniu zamówienia"}
przelewy24_id: {name: "ID sprzedawcy", required: true}
salt: {name: "Klucz CRC", required: true, type: input_password_tag}
report_key: {name: "Klucz raportów", required: true, type: input_password_tag}
channels: {name: "Kanały płatności", type: "select_tag", params: multiple=true}
highlighted_for_product: {name: "Wyróżnij płatności na karcie produktu", type: "st_przelewy24_highlighted_payments_select_tag"}
highlighted_for_basket: {name: "Wyróżnij płatności w koszyku", type: "st_przelewy24_highlighted_payments_select_tag"}
actions:
_save: -

View File

@@ -0,0 +1,8 @@
<?php
if ($sf_request->hasParameter('fake_paypo'))
{
echo input_hidden_tag('fake_paypo', true);
}
echo st_przelewy24_payment_methods_select_tag('config[channels]', $config->get('channels'));
?>

View File

@@ -0,0 +1,14 @@
<?php include st_admin_get_template_path(__FILE__) ?>
<script>
jQuery(function($) {
$('#config_payment_channels_enabled').change(function() {
const fields = $('.row_report_key, .row_channels, .row_highlighted_for_product, .row_highlighted_for_basket');
if ($(this).prop('checked')) {
fields.removeClass('hidden');
} else {
fields.addClass('hidden');
}
});
});
</script>

View File

@@ -0,0 +1,22 @@
<?php use_helper('I18N', 'stAdminGenerator');?>
<?php echo st_get_admin_head('stPrzelewy24Plugin', __('Przelewy24'), '', array('stPayment')); ?>
<?php st_view_slot_start('application-menu') ?>
<?php st_include_component('stPrzelewy24Backend', 'listMenu') ?>
<?php st_view_slot_end() ?>
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels));?>
<?php echo form_tag('przelewy24/index', array('id' => 'sf_admin_config_form', 'class' => 'admin_form'));?>
<fieldset>
<div class="content">
<?php echo st_admin_get_form_field('config[autoredirect]', $labels['config{autoredirect}'], true, 'checkbox_tag', array('checked' => $config->get('autoredirect'), 'help' => __('Przekierowuje automatycznie na stronę płatności po złożeniu zamówienia'))) ?>
<?php echo st_admin_get_form_field('config[test]', $labels['config{test}'], true, 'checkbox_tag', array('checked' => $config->get('test'))) ?>
<?php echo st_admin_get_form_field('config[przelewy24_id]', $labels['config{przelewy24_id}'], $config->get('przelewy24_id'), 'input_tag', array('required' => true)) ?>
<?php echo st_admin_get_form_field('config[salt]', $labels['config{salt}'], $config->get('salt'), 'input_tag', array('required' => true)) ?>
</div>
</fieldset>
<?php echo st_get_admin_actions_head('style="margin-top: 10px; float: right"');?>
<?php echo st_get_admin_action('save', __('Zapisz', null, 'stAdminGeneratorPlugin'), null, array('name' => 'save'));?>
<?php echo st_get_admin_actions_foot();?>
</form>
<?php echo st_get_admin_foot();?>

View File

@@ -0,0 +1,121 @@
<?php
/**
* SOTESHOP/stPrzelewy24Plugin
*
* Ten plik należy do aplikacji stPrzelewy24Plugin 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 stPrzelewy24Plugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: actions.class.php 10 2009-08-24 09:32:18Z michal $
* @author Michal Prochowski <michal.prochowski@sote.pl>
*/
/**
* Klasa stPrzelewy24FrontendActions
*
* @package stPrzelewy24Plugin
* @subpackage actions
*/
class stPrzelewy24FrontendActions extends stActions
{
/**
* Pozytywny powrót z płatności
*/
public function executeReturnSuccess()
{
$this->smarty = new stSmarty($this->getModuleName());
}
/**
* Negatywny powrót z płatności
*/
public function executeReturnFail()
{
$this->smarty = new stSmarty('stPrzelewy24Frontend');
$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()
{
$request = $this->getRequest();
$order = OrderPeer::retrieveByIdAndHashCode($this->getRequestParameter('id'), $this->getRequestParameter('hash'));
if ($order)
{
$this->api = new stPrzelewy24();
try
{
$url = $this->api->getPaymentUrl($order);
stPayment::log("przelewy24", "Generate payment url for order with id {$order->getId()}: $url");
if ($url)
{
return $this->renderJSON(array('redirect' => $url));
}
}
catch (Exception $e)
{
stPayment::log("przelewy24", "Generate payment url exception for order with id {$order->getId()}: {$e->getMessage()}");
}
}
return $this->renderJSON(array('redirect' => $this->getController()->genUrl('stPrzelewy24Frontend/returnFail')));
}
public function executeStatus()
{
$request = $this->getRequest();
$order = OrderPeer::retrieveByIdAndHashCode($request->getParameter('id'), $request->getParameter('hash'));
if ($order)
{
$api = new stPrzelewy24();
try
{
if ($api->verify($order, $request))
{
$payment = $order->getOrderPayment();
if ($payment)
{
$payment->setStatus(true);
$payment->save();
stPayment::log("przelewy24", "Payment status update for order with id {$order->getId()}: successful");
}
else
{
stPayment::log("przelewy24", "Payment status update: Payment for order with id {$order->getId()} does not exist");
}
}
} catch (Exception $e)
{
stPayment::log("przelewy24", "Payment status update exception for order with id {$order->getId()}: ". $e->getMessage());
}
}
else
{
stPayment::log("przelewy24", "Payment status update: Order with id {$request->getParameter('id')} does not exist");
}
return $this->renderText("OK");
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* SOTESHOP/stPrzelewy24Plugin
*
* Ten plik należy do aplikacji stPrzelewy24Plugin 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 stPrzelewy24Plugin
* @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 stPrzelewy24Components
*
* @package stPrzelewy24Plugin
* @subpackage actions
*/
class stPrzelewy24FrontendComponents extends sfComponents
{
/**
* Pokazywanie formularza płatności
*/
public function executeShowPayment()
{
$request = $this->getRequest();
if ($this->order)
{
$this->api = new stPrzelewy24();
try
{
$url = $this->api->getPaymentUrl($this->order);
stPayment::log("przelewy24", "Generate payment url for order with id {$this->order->getId()}: $url");
}
catch (Exception $e)
{
stPayment::log("przelewy24", "Generate payment url exception for order with id {$this->order->getId()}: {$e->getMessage()}");
}
if ($url)
{
$this->getContext()->getController()->redirect($url);
throw new sfStopException();
}
}
$this->smarty = new stSmarty('stPrzelewy24Frontend');
$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');
$smarty->display('przelewy24_show_payment.html');

View File

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

View File

@@ -0,0 +1,3 @@
<?php
st_theme_use_stylesheet('stPayment.css');
$smarty->display('przelewy24_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,38 @@
<div id="st_frame_przelewy24">
{if $check_configuration == true}
<div id="st_txt_przelewy24">
<p>{__ text="Kliknij przycisk"} <b>{__ text='"Zapłać"'}</b> {__ text="aby przejść do serwisu Przelewy24."}</p>
</div>
<div class="st_logo_przelewy24">
<img src="/images/frontend/theme/default/stPrzelewy24Plugin/logo.jpg" alt="Przelewy24.pl"/>
</div>
{$form_start}
{$hidden_p24_session_id}
{$hidden_p24_id_sprzedawcy}
{$hidden_p24_kwota}
{$hidden_p24_klient}
{$hidden_p24_adres}
{$hidden_p24_kod}
{$hidden_p24_miasto}
{$hidden_p24_kraj}
{$hidden_p24_email}
{$hidden_p24_return_url_ok}
{$hidden_p24_return_url_error}
{$hidden_p24_opis}
{if $show_payment_table}
<script type="text/javascript" src="https://secure.przelewy24.pl/external/formy.php?id={$p24_id_sprzedawcy}&encoding=utf-8&style=0&opis=0&cols={$payment_table_cols}&lang={$lang}"></script>
<script type="text/javascript">m_formy();</script>
{/if}
{$hidden_p24_language}
<div id="st_form-payment-submit" class="st_button-container">
<div class="st_button st_align-right">
<div class="st_button-left">
{$submit_button}
</div>
</div>
</div>
</form>
{else}
{__ text="Płatność została błędnie skonfigurowana."}
{/if}
</div>

View File

@@ -0,0 +1,24 @@
<div id="st_box_payment" class="box roundies">
<div class="content">
<p><img src="/plugins/stPrzelewy24Plugin/images/logo.png" /></p>
<p>{__ text="Trwa przetwarzanie płatności w systemie Przelewy24. Status płatności zostanie wysłany w wiadomości e-mail."}</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" style="text-align: center">
<p><img src="/plugins/stPrzelewy24Plugin/images/logo.png" alt="Przelewy24.pl" /></p>
<p style="text-align: center">
{__ text="Wystąpił problem z połączeniem się z serwisem Przelewy24."}
{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,13 @@
{set layout="one_column"}
<div id="payment">
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="Przelewy24"}
</div>
<div class="panel-body text-center">
<p><img src="/plugins/stPrzelewy24Plugin/images/logo.png" alt="" /></p>
<p>{__ text="Trwa przetwarzanie płatności w systemie Przelewy24. Status płatności zostanie wysłany w wiadomości e-mail."}</p>
<a href="{$homepage_url}" class="btn btn-primary">{__ text="Wróć do zakupów" catalogue="stBasket"}</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,16 @@
<div class="panel panel-default center-block">
<div class="panel-heading">
{__ text="Przelewy24"}
</div>
<div class="panel-body text-center">
<p><img src="/plugins/stPrzelewy24Plugin/images/logo.png" alt="" /></p>
<p>{__ text="Wystąpił problem z połączeniem się z serwisem Przelewy24."}</p>
{if $contact_url}
<p>
<a href="{$contact_url}" class="btn btn-primary">
{__ text="Skontaktuj się z nami"}
</a>
</p>
{/if}
</div>
</div>