Модуль оплаты liqpay. Ошибка

Автор om, 26 октября 2012, 19:06:54

« назад - далее »

om

Добрый день!
Прошу у Вас помощи. В магазине есть модуль liqpay (способ оплаты).
Все работает, переходит на сайт платежного модуля, все данные клиент вводит, оплата происходит, нам деньги доходят.
Но после этого вылетает ошибка:
Warning: number_format() expects parameter 1 to be double, object given in /home/idealmar/public_html/classes/PaymentModule.php on line 137

Warning: Illegal offset type in /home/idealmar/public_html/modules/liqpay/liqpay.php on line 161


К сожалению, моих знаний не хватает. Уже 3день мучаюсь. Помогите исправить.
Код:
<?php

class liqpay extends PaymentModule
{
   private
$_html = '';
   private
$_postErrors = array();
   public function
__construct()
   {
       
$this->name = 'liqpay';        
       
$this->tab = 'payments_gateways';
       
$this->version = 1.2;
       
$this->author = 'shop';
       
       
$this->currencies = true;
       
$this->currencies_mode = 'radio';
   
       
       
$config = Configuration::getMultiple(array('LIQPAY_MERCHANT_PASS', 'LIQPAY_MERCHANT_ID'));    
       if (isset(
$config['LIQPAY_MERCHANT_PASS']))
           
$this->liqpay_merchant_pass = $config['LIQPAY_MERCHANT_PASS'];
       if (isset(
$config['LIQPAY_MERCHANT_ID']))
           
$this->liqpay_merchant_id = $config['LIQPAY_MERCHANT_ID'];
           
       
parent::__construct();
       
       
/* The parent construct is required for translations */
       
$this->page = basename(__FILE__, '.php');
       
$this->displayName = 'LiqPay';
       
$this->description = $this->l('Accept payments with LiqPay');
       
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
       
       if (!isset(
$this->liqpay_merchant_pass) OR !isset($this->liqpay_merchant_id))
           
$this->warning = $this->l('Your LiqPay account must be set correctly (specify a password and a unique id merchant');
   }        

   function
install()
   {        
       if (!
parent::install() OR !$this->registerHook('payment'))
           return
false;
       return
true;
   }
   
   function
uninstall()
   {
       if (!
Configuration::deleteByName('LIQPAY_MERCHANT_PASS') OR !Configuration::deleteByName('LIQPAY_MERCHANT_ID') OR !parent::uninstall())
           return
false;
       return
true;
   }
   
   private function
_postValidation()
   {
       if (isset(
$_POST['btnSubmit']))
       {
           if (empty(
$_POST['merchant_id']))
               
$this->_postErrors[] = $this->l('Merchant ID is required');
           elseif (empty(
$_POST['merchant_pass']))
               
$this->_postErrors[] = $this->l('Merchant password is required.');
       }
   }

   private function
_postProcess()
   {
       if (isset(
$_POST['btnSubmit']))
       {
           
Configuration::updateValue('LIQPAY_MERCHANT_ID', $_POST['merchant_id']);
           
Configuration::updateValue('LIQPAY_MERCHANT_PASS', $_POST['merchant_pass']);
       }
       
$this->_html .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('OK').'" /> '.$this->l('Settings updated').'</div>';
   }
   
   private function
_displayLiqpay()
   {
       
$this->_html .= '<img src="../modules/liqpay/LiqPay.gif" style="float:left; margin-right:15px;"><b>'.$this->l('This module allows you to accept payments by LiqPay.').'</b><br /><br />
       '
.$this->l('You need to register on the site').' <a href="https://liqpay.com" target="blank">liqpay.com</a> <br /><br /><br />';
   }
   
   private function
_displayForm()
   {
       
$this->_html .=
       
'<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
           <fieldset>
           <legend><img src="../img/admin/contact.gif" />'
.$this->l('Contact details').'</legend>
               <table border="0" width="500" cellpadding="0" cellspacing="0" id="form">
                   <tr><td colspan="2">'
.$this->l('Please specify the password and a unique id merchant registered in the LiqPay system').'.<br /><br /></td></tr>
                   <tr><td width="140" style="height: 35px;">'
.$this->l('Merchant ID').'</td><td><input type="text" name="merchant_id" value="'.htmlentities(Tools::getValue('merchant_id', $this->liqpay_merchant_id), ENT_COMPAT, 'UTF-8').'" style="width: 300px;" /></td></tr>
                   <tr><td width="140" style="height: 35px;">'
.$this->l('Merchant password').'</td><td><input type="text" name="merchant_pass" value="'.htmlentities(Tools::getValue('merchant_pass', $this->liqpay_merchant_pass), ENT_COMPAT, 'UTF-8').'" style="width: 300px;" /></td></tr>
                   <tr><td colspan="2" align="center"><br /><input class="button" name="btnSubmit" value="'
.$this->l('Update settings').'" type="submit" /></td></tr>
               </table>
           </fieldset>
       </form>'
;
   }

   function
getContent()
   {
       
$this->_html = '<h2>'.$this->displayName.'</h2>';

       if (!empty(
$_POST))
       {
           
$this->_postValidation();
           if (!
sizeof($this->_postErrors))
               
$this->_postProcess();
           else
               foreach (
$this->_postErrors AS $err)
                   
$this->_html .= '<div class="alert error">'. $err .'</div>';
       }
       else
           
$this->_html .= '<br />';

       
$this->_displayLiqpay();
       
$this->_displayForm();

       return
$this->_html;
   }

   function
hookPayment($params)
   {
       global
$smarty;
       
       
$delivery = new Address(intval($params['cart']->id_address_delivery));
       
$invoice = new Address(intval($params['cart']->id_address_invoice));
       
$customer = new Customer(intval($params['cart']->id_customer));                
               
       
$return_url    = 'http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'modules/liqpay/validation.php';            
       
$currency = $this->getCurrency();
       
$amount         = number_format(Tools::convertPrice($params['cart']->getOrderTotal(true, 3), $currency), 2, '.', '');
       
$order_id      = $_SERVER['SERVER_NAME'].'_'.$params['cart']->id;
       
$description   = 'Payment of goods on the site '.$_SERVER['SERVER_NAME'];              

       
$xml = '<?xml version="1.0" encoding="utf-8"?>
                <request>
                    <version>1.2</version>
                    <result_url>'.$return_url.'</result_url>
                    <server_url>'.$return_url.'</server_url>
                    <merchant_id>'.Configuration::get('LIQPAY_MERCHANT_ID').'</merchant_id>
                    <order_id>'.$order_id.'</order_id>
                    <amount>'.$amount.'</amount>
                    <currency>'.$currency->iso_code.'</currency>
                    <description>'.$description.'</description>
                </request>';
        $merchant_pass = Configuration::get('LIQPAY_MERCHANT_PASS');
        $operation_xml = base64_encode($xml);
        $signature = base64_encode(sha1($merchant_pass.$xml.$merchant_pass, 1));       
               
        $smarty->assign(array(
            'liqpayUrl'         => 'https://liqpay.com/?do=clickNbuy',
            'operation_xml'     => $operation_xml,
            'signature'         => $signature,       
            'this_path'         => $this->_path,
            'this_path_ssl'     => Configuration::get('PS_FO_PROTOCOL').$_SERVER['HTTP_HOST'].__PS_BASE_URI__."modules/{$this->name}/"));

        return $this->display(__FILE__, 'liqpay.tpl');
    }
   
    public function getL($key)
    {
        $translations = array(
            'success'=> 'The LiqPay transaction is carried out successfully.',
            'wait_secure'=> 'The LiqPay transaction is processed.',
            'failure'=> 'The LiqPay transaction is refused.'
        );
        return $translations[$key];
    }
   
}

?>

DarinSr

ЦитироватьWarning: number_format() expects parameter 1 to be double, object given in /home/idealmar/public_html/classes/PaymentModule.php on line 137
Warning: Illegal offset type in /home/idealmar/public_html/modules/liqpay/liqpay.php on line 161
Нужно перейти на php 5.2 или переделать модуль под 5.3


om

Разве это очень сложно, отредактировать под 5.3?
Модуль коротенький. Помогите, пожалуйста!
Вам это 2 мин, а мне 2 недели!
Пожалуйста!

coder

Это нужно вам, совсем не сложно сменить на php5.2
Модуль устарел, зачем с ним мучаться?
Напишите в суппорт liqpay, попросите последнюю версию, опишите проблему они помогут.

om

#4
Обратился к ним. Выдали модуль. Все переустановил настроил.
Та же история. только теперь одна ошибка:
Warning: Illegal offset type in /home/idealmar/public_html/modules/liqpay/liqpay.php on line 161
Строка 161:
        return $translations[$key];

Виталий

Скорее всего , Warning: Illegal offset type говорит о том что $key является массивом или объектом.
Массивы и объекты не могут быть использованы в качестве ключей.
отключите вывод предупреждений
error_reporting(E_ALL & ~E_NOTICE);
или найдите где используется function getL($key) и проверьте, что передается в эту функцию.
Cоздание интернет сайтов Webstudio UwK

mAgency

Можно так
$result = ' ';
$result = is_array($key) ? $key[0] : $key;
return $translations[$result];
Интернет-магазин под ключ.
Какой выбрать движок для интернет магазина ?
Какой движок лучше ?
Magento или Prestashop ?
Решение всех Ваших вопросов в создании Интернет-магазина.