*/ /** * Klasa stInBankBackendActions * * @package stInBankPlugin * @subpackage actions */ class stInBankBackendActions extends stActions { /** * Wyświetla konfigurację modułu */ public function executeIndex() { $this->labels = $this->getLabels(); if ($this->getRequest()->getMethod() == sfRequest::POST) { $this->config->save(); if (!stInBank::hasPaymentType()) { $activeGateway = new PaymentType(); $activeGateway->setActive(true); $activeGateway->setCulture(stLanguage::getOptLanguage()); $activeGateway->setName('RATY Inbank'); $activeGateway->setModuleName('stInBank'); $activeGateway->save(); } stTheme::clearSmartyCache(true); $this->setFlash('notice', 'Twoje zmiany zostały zapisane'); } } public function validateIndex() { $this->config = stConfig::getInstance('stInBank'); $payments = appBlueMedia::getPayments(false); $ok = true; if ($this->getRequest()->getMethod() == sfRequest::POST) { stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName()); $i18n = $this->getContext()->getI18N(); if (stTheme::getInstance($this->getContext())->getVersion() < 7) { $this->getRequest()->setError('api', $i18n->__('Funkcjonalność dostępna tylko i wyłącznie dla nowych tematów responsywnych')); return false; } $data = $this->getRequestParameter('config'); // if (stTheme::getInstance($this->getContext())->getVersion() < 7) // { // $this->getRequest()->setError('api', $i18n->__('Funkcjonalność dostępna tylko i wyłącznie dla nowych tematów responsywnych')); // $ok = false; // } if (!$data['api_key']) { $this->getRequest()->setError('config{api_key}', $i18n->__('Proszę uzupełnić pole.')); } if (!$data['product_code']) { $this->getRequest()->setError('config{product_code}', $i18n->__('Proszę uzupełnić pole.')); } if (!$data['uuid']) { $this->getRequest()->setError('config{uuid}', $i18n->__('Proszę uzupełnić pole.')); } $this->config->setFromRequest('config'); if (!$this->getRequest()->hasErrors()) { if (!stInBank::validateCredentials($data['product_code'], $data['uuid'], $data['api_key'], isset($data['sandbox']))) { $this->getRequest()->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.')); } $this->config->set('configuration_check', true); } } return !$this->getRequest()->hasErrors(); } public function getLabels() { return array( 'config{uuid}' => 'UUID', 'config{product_code}' => $this->getContext()->getI18n()->__('Kod produktu'), 'config{api_key}' => $this->getContext()->getI18n()->__('Klucz API'), 'api' => 'Inbank', ); } /** * Akcja w przypadku błędu w uzupełnianiu pól */ public function handleErrorIndex() { $this->labels = $this->getLabels(); return sfView::SUCCESS; } }