first commit
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stPayNowPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDotpayPlugin 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 stPayNowPlugin
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: actions.class.php 34060 2021-03-01 08:28:14Z marcin $
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stPayNowBackendActions
|
||||
*
|
||||
* @package stPayNowPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stPayNowBackendActions extends stActions
|
||||
{
|
||||
public function preExecute()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
|
||||
|
||||
parent::preExecute();
|
||||
}
|
||||
|
||||
public function executeIndex()
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$modules = PaymentTypePeer::doSelectByModuleName('stPayNow');
|
||||
|
||||
if (!$modules)
|
||||
{
|
||||
$paymentType = new PaymentType();
|
||||
$paymentType->setCulture(stLanguage::getOptLanguage());
|
||||
$paymentType->setName('Paynow');
|
||||
$paymentType->setModuleName('stPayNow');
|
||||
}
|
||||
else
|
||||
{
|
||||
$paymentType = current($modules);
|
||||
}
|
||||
|
||||
$paymentType->setActive($this->config->get('enabled'));
|
||||
$paymentType->save();
|
||||
|
||||
$this->config->save();
|
||||
$this->setFlash('notice', $i18n->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
|
||||
|
||||
if ($this->hasRequestParameter('debug'))
|
||||
{
|
||||
return $this->redirect('@stPayNowPlugin?action=index&debug=1');
|
||||
}
|
||||
|
||||
return $this->redirect('@stPayNowPlugin?action=index');
|
||||
}
|
||||
|
||||
$this->labels = $this->getLabels();
|
||||
}
|
||||
|
||||
|
||||
public function executeLogDownload()
|
||||
{
|
||||
$filename = sfConfig::get('sf_log_dir') . '/paynow.log';
|
||||
|
||||
$this->setLayout(false);
|
||||
|
||||
$response = $this->getContext()->getResponse();
|
||||
$response->setContentType("application/octet-stream");
|
||||
$response->setHttpHeader('Content-Disposition', 'attachment; filename="paynow.log"');
|
||||
$response->sendHttpHeaders();
|
||||
|
||||
if (is_file($filename))
|
||||
{
|
||||
$handle = fopen($filename,'r');
|
||||
|
||||
if ($handle)
|
||||
{
|
||||
while (!feof($handle))
|
||||
{
|
||||
print fread($handle, 8192);
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
public function validateIndex()
|
||||
{
|
||||
$this->config = stConfig::getInstance('stPayNow');
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
|
||||
$this->config->setFromRequest('config');
|
||||
|
||||
if (!$this->config->get('api_key'))
|
||||
{
|
||||
$this->getRequest()->setError('config{api_key}', $i18n->__('Proszę uzupełnić pole.'));
|
||||
}
|
||||
|
||||
if (!$this->config->get('api_signature_key'))
|
||||
{
|
||||
$this->getRequest()->setError('config{api_signature_key}', $i18n->__('Proszę uzupełnić pole.'));
|
||||
}
|
||||
|
||||
if (!$request->hasErrors())
|
||||
{
|
||||
$api = new stPayNow();
|
||||
|
||||
if (!$api->validateConfiguration())
|
||||
{
|
||||
$request->setError('api', $i18n->__('Wystąpił błąd podczas próby połączenia się z serwisem. Proszę sprawdzić czy wprowadzone dane są poprawne i spróbować ponownie.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !$request->hasErrors();
|
||||
}
|
||||
|
||||
public function handleErrorIndex()
|
||||
{
|
||||
$this->labels = $this->getLabels();
|
||||
|
||||
return sfView::SUCCESS;
|
||||
}
|
||||
|
||||
public function getLabels()
|
||||
{
|
||||
$i18n = $this->getContext()->getI18n();
|
||||
|
||||
return array(
|
||||
'api' => 'Paynow',
|
||||
'config{api_key}' => $i18n->__('Klucz dostępu do API'),
|
||||
'config{api_signature_key}' => $i18n->__('Klucz obliczania podpisu'),
|
||||
'config{enabled}' => $i18n->__('Włącz'),
|
||||
'config{autoredirect}' => $i18n->__('Automatyczne przekierowanie', null, 'stPayment'),
|
||||
'config{sandbox}' => $i18n->__('Tryb testowy'),
|
||||
'notify_url' => $i18n->__('Adres powiadomień'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class stPayNowBackendComponents extends sfComponents
|
||||
{
|
||||
|
||||
public function executeListMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="list-menu">
|
||||
<ul>
|
||||
|
||||
<li class="selected">
|
||||
<?php echo link_to(__('PayNow'),'stPayNowBackend/index')?>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
|
||||
<a href="https://www.sote.pl/docs/paynow-mbank" target="_blank"><?php echo __('Dokumentacja'); ?></a>
|
||||
<?php else: ?>
|
||||
<a href="https://www.soteshop.com/docs/paynow-mbank" target="_blank"><?php echo __('Documentation'); ?></a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="clr"></div>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php use_helper('I18N', 'stAdminGenerator', 'Validation') ?>
|
||||
<?php echo st_get_admin_head(array('@stPayNowPlugin', __('Paynow'), 'stPayNowPlugin'), __('Paynow')) ?>
|
||||
|
||||
<?php st_view_slot_start('application-menu') ?>
|
||||
<?php st_include_component('stPayNowBackend', 'listMenu') ?>
|
||||
<?php st_view_slot_end() ?>
|
||||
|
||||
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels));?>
|
||||
|
||||
<?php echo form_tag('@stPayNowPlugin?action=index', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form', 'class' => 'admin_form'));?>
|
||||
<?php if ($sf_request->hasParameter('debug')): ?>
|
||||
<input type="hidden" name="debug" value="1">
|
||||
<?php endif ?>
|
||||
<?php if (!$config->get('api_key') && !$config->get('api_signature_key')): ?>
|
||||
<fieldset>
|
||||
<h2><?php echo __('Zakładanie konta');?></h2>
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<a href="https://www.mbank.pl/lp2/2021/w1/paynow-sote/" target="_blank" style="margin-left: 5px; text-decoration: underline;"><?php echo __('Aktywuj Paynow na promocyjnych warunkach');?></a>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif ?>
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('config[enabled]', $labels['config{enabled}'], 1, 'checkbox_tag', array('checked' => $config->get('enabled'))) ?>
|
||||
<?php echo st_admin_get_form_field('config[autoredirect]', $labels['config{autoredirect}'], 1, 'checkbox_tag', array('checked' => $config->get('autoredirect'), 'help' => __('Przekieruj automatycznie na stronę płatności po złożeniu zamówienia', null, 'stPayment'))) ?>
|
||||
<?php if (SF_ENVIRONMENT == 'dev' || $sf_request->hasParameter('debug')): ?>
|
||||
<?php echo st_admin_get_form_field('config[sandbox]', $labels['config{sandbox}'], 1, 'checkbox_tag', array('checked' => $config->get('sandbox'))) ?>
|
||||
<?php endif ?>
|
||||
<?php echo st_admin_get_form_field('config[api_key]', $labels['config{api_key}'], $config->get('api_key'), 'input_password_tag', array('required' => true, 'autocomplete' => false, 'size' => 40)) ?>
|
||||
<?php echo st_admin_get_form_field('config[api_signature_key]', $labels['config{api_signature_key}'], $config->get('api_signature_key'), 'input_password_tag', array('required' => true, 'autocomplete' => false, 'size' => 40)) ?>
|
||||
<?php echo st_admin_get_form_field('ecard_notify_url', $labels['notify_url'], stPayNow::getNotifyUrl(), 'input_tag', array('readonly' => true, 'size' => 100, 'clipboard' => true)) ?>
|
||||
<?php if (SF_ENVIRONMENT == 'dev' || $sf_request->hasParameter('debug')): ?>
|
||||
<?php echo st_admin_get_form_field('payment_logs', __('Logi'), link_to(__('Pobierz'), '@stPayNowPlugin?action=logDownload'), 'plain'); ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php echo st_get_admin_actions_head('style="margin-top: 10px; float: right"') ?>
|
||||
<?php echo st_get_admin_action('save', __('Zapisz', array(), 'stAdminGeneratorPlugin'), null, array('name' => 'save')) ?>
|
||||
<?php echo st_get_admin_actions_foot() ?>
|
||||
</form>
|
||||
|
||||
|
||||
<?php echo st_get_admin_foot() ?>
|
||||
Reference in New Issue
Block a user