name = 'webmoney'; $this->tab = 'Payment'; $this->version = '0.4'; $this->currencies = true; $this->currencies_mode = 'checkbox'; $config = Configuration::getMultiple(array('WEBMONEY_PURSE_R', 'WEBMONEY_PURSE_Z', 'WEBMONEY_PURSE_E', 'WEBMONEY_KEY')); if (isset($config['WEBMONEY_PURSE_R'])) $this->purse_r = $config['WEBMONEY_PURSE_R']; if (isset($config['WEBMONEY_PURSE_Z'])) $this->purse_z = $config['WEBMONEY_PURSE_Z']; if (isset($config['WEBMONEY_PURSE_E'])) $this->purse_e = $config['WEBMONEY_PURSE_E']; if (isset($config['WEBMONEY_PURSE_U'])) $this->purse_e = $config['WEBMONEY_PURSE_U']; if (isset($config['WEBMONEY_KEY'])) $this->ikey = $config['WEBMONEY_KEY']; parent::__construct(); $this->displayName = $this->l('WebMoney'); $this->description = $this->l('Accepts payments by WebMoney'); $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?'); if (!isset($this->purse_r) OR !isset($this->purse_z) OR !isset($this->purse_e)) $this->warning = $this->l('Add any purse'); if (!isset($this->ikey)) $this->warning = $this->l('Add secret key'); } public function install() { if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn')) return false; return true; } public function uninstall() { if (!Configuration::deleteByName('WEBMONEY_PURSE_R') OR !Configuration::deleteByName('WEBMONEY_PURSE_Z') OR !Configuration::deleteByName('WEBMONEY_PURSE_E') OR !Configuration::deleteByName('WEBMONEY_PURSE_U') OR !Configuration::deleteByName('WEBMONEY_KEY') OR !parent::uninstall()) return false; return true; } private function _postValidation() { if (isset($_POST['submitWebmoney'])) { if (empty($_POST['purse_r']) && empty($_POST['purse_z']) && empty($_POST['purse_e'])) $this->_postErrors[] = $this->l('Add any purse'); if (empty($_POST['ikey'])) $this->_postErrors[] = $this->l('Add secret key'); } } private function _postProcess() { if (isset($_POST['submitWebmoney'])) { Configuration::updateValue('WEBMONEY_PURSE_R', $_POST['purse_r']); Configuration::updateValue('WEBMONEY_PURSE_Z', $_POST['purse_z']); Configuration::updateValue('WEBMONEY_PURSE_E', $_POST['purse_e']); Configuration::updateValue('WEBMONEY_PURSE_U', $_POST['purse_u']); Configuration::updateValue('WEBMONEY_KEY', $_POST['ikey']); } $this->_html .= '
'.$this->l('ok').' '.$this->l('Settings updated').'
'; } private function _displayWebMoney() { $this->_html .= ' '.$this->l('This module allows you to accept payments by WebMoney.').'



'; } private function _displayForm() { $this->_html .= '
'.$this->l('Settings').'

Формат: буква и 12 цифр

Формат: буква и 12 цифр

Формат: буква и 12 цифр

Формат: буква и 12 цифр




'.$this->l('Information').' '.$this->l('What connect WebMoney:').'
На сайте https://merchant.webmoney.ru выберите пункт меню "Настройки". Пройдите авторизацию и выберите кошелек, на который вы будете принимать платежи через сервис Web Merchant Interface. Вы получите страницу для настройки параметров.

Ниже приведен перечень заполняемых значений:


'; } public function getContent() { $this->_html = '

'.$this->displayName.'

'; if (!empty($_POST)) { $this->_postValidation(); if (!sizeof($this->_postErrors)) $this->_postProcess(); else foreach ($this->_postErrors AS $err) $this->_html .= '
'. $err .'
'; } else $this->_html .= '
'; $this->_displayWebMoney(); $this->_displayForm(); return $this->_html; } public function hookPayment($params) { if (!$this->active) return ; global $smarty; $id_currency = intval($params['cart']->id_currency); $currency = new Currency(intval($id_currency)); if ($currency->iso_code == 'RUB' && Configuration::get('WEBMONEY_PURSE_R')) {$purse = Configuration::get('WEBMONEY_PURSE_R');} elseif ($currency->iso_code == 'USD' && Configuration::get('WEBMONEY_PURSE_Z')) {$purse = Configuration::get('WEBMONEY_PURSE_Z');} elseif ($currency->iso_code == 'EUR' && Configuration::get('WEBMONEY_PURSE_E')) {$purse = Configuration::get('WEBMONEY_PURSE_E');} elseif ($currency->iso_code == 'UAH' && Configuration::get('WEBMONEY_PURSE_U')) {$purse = Configuration::get('WEBMONEY_PURSE_U');} else {$purse = Configuration::get('WEBMONEY_PURSE_U'); $currency = $this->getCurrency();} $smarty->assign(array( 'purse' => $purse, 'total' => number_format(Tools::convertPrice($params['cart']->getOrderTotal(true, 3), $currency), 2, '.', ''), 'id_cart' => intval($params['cart']->id), 'returnUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/webmoney/validation.php', 'cancelUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'order.php', 'this_path' => $this->_path )); return $this->display(__FILE__, 'webmoney.tpl'); } } ?>