Помогите допилить окультурить код обработчика LiqPay 1.2

#
Помогите допилить окультурить код обработчика LiqPay 1.2
Предупреждаю я не программист!! Потому делал на основе старой версии

Если будете что-то дописывать или изменять прошу объяснять почему так!!!

Код в ТДС:
// ------------------------------------------------
// Обработка формы "Оплата через систему LiqPay"
// ------------------------------------------------
if (isset($_POST['operation_xml']) and isset($_POST['signature']))
{
   $xml_liqpay = $_POST['operation_xml'];
   $xml_decoded=base64_decode($xml_liqpay);

   $xml = simplexml_load_string($xml_decoded);
   $json = json_encode($xml);
   $array = json_decode($json,TRUE);

   // Получаем ID заказа
   $order_id = intval($array['order_id']);

   $oShop_Order = Core_Entity::factory('Shop_Order')->find($order_id);

   if (!is_null($oShop_Order->id))
   {
      // Вызов обработчика платежной системы
      Shop_Payment_System_Handler::factory($oShop_Order->Shop_Payment_System)
         ->shopOrder($oShop_Order)
         ->paymentProcessing();
      return TRUE;
   }
}


Код обработчика:

<?php

/**
* LiqPay
*/
class Shop_Payment_System_Handler20 extends Shop_Payment_System_Handler
{
   /**
    * Номер мерчанта
    * @var string
    */
   protected $_merchant_id = 'КОД МЕРЧАНДА';
   
   /**
    * Пароль мерчанта
    * @var string
    */
   protected $_merchant_sig = 'ПАРОЛЬ МЕРЧАНДА';

   /**
    * Международное название валюты из списка валют магазина
    * @var string
    */
   protected $_currency_name = 'RUR';
   
   /**
    * Идентификатор валюты
    * @var string
    */
   protected $_currency_id = 1;
   
   /**
    * Acquirer ID
    * 414963 – Украина
    * 469584 – Россия
    * @var string
    */
   protected $_acqid = 469584;
   
   /**
    * Валюта покупки
    * 980 — украинская гривна
    * 643 — российский рубль
    * @var string
    */
   protected $_currency = 643;
   
   /**
    * Метод, запускающий выполнение обработчика
    * @return self
    */
   public function execute()
   {
      parent::execute();

      $this->printNotification();

      return $this;
   }
   
   public function __construct(Shop_Payment_System_Model $oShop_Payment_System_Model)
   {
      parent::__construct($oShop_Payment_System_Model);
      $oCurrency = Core_Entity::factory('Shop_Currency')->getByCode($this->_currency_name);
      !is_null($oCurrency) && $this->_currency_id = $oCurrency->id;
   }
   
   protected function _processOrder()
   {
      parent::_processOrder();

      // Установка XSL-шаблонов в соответствии с настройками в узле структуры
      $this->setXSLs();

      // Отправка писем клиенту и пользователю
      $this->send();

      return $this;
   }
   
   public function paymentProcessing()
   {
      // Пришло подтверждение оплаты, обработаем его
      if (isset($_POST['operation_xml']) and isset($_POST['signature']))
      {
         $this->ProcessResult();
         return TRUE;
      }
   }
   
   public function hexbin($temp)
   {
      $data="";
      $len = strlen($temp);
      for ($i=0;$i<$len;$i+=2) $data.=chr(hexdec(substr($temp,$i,2)));
      return $data;
   }
   
   /*
    * Обработка статуса оплаты
    */
   function ProcessResult()
   {
      if($this->_shopOrder->paid)
      {
         return FALSE;
      }

      $xml_liqpay = $_POST['operation_xml'];
      $xml_decoded=base64_decode($xml_liqpay);

      $xml = simplexml_load_string($xml_decoded);
      $json = json_encode($xml);
      $array = json_decode($json,TRUE);

      $password = $this->_merchant_sig;
      $merid = $this->_merchant_id;
      $orderid = $array['order_id'];
      $responsecode = $array['transaction_id'];
      $reasoncode = $array['status'];
      $reasoncodedesc = $array['description'];

      $sign=base64_encode(sha1($password.$xml_liqpay.$password,1));
   
      if($reasoncode == 'success' and isset($responsecode))
      {
         //$this->_shopOrder->system_information = sprintf("Заказ оплачен через LiqPay, данные заказа:\n№ заказа: %s\nКод ответа: %s\nОписание ответа: %s", $orderid, $responsecode, $reasoncodedesc);

         $this->_shopOrder->paid();
         $this->setXSLs();
         $this->send();
         print_r('<h2>Заказ №'.$orderid.' оплачен через LiqPay</h2>');
         //print_r($this->_shopOrder);
      }
      else
      {
         //$this->_shopOrder->system_information = sprintf("Заказ НЕ оплачен через LiqPay, данные заказа:\n№ заказа: %s\nAcquirer ID: %s\nКод ответа: %s\nОписание ответа: %s", $orderid, $responsecode, $reasoncodedesc);
         $this->_shopOrder->save();
         print_r('<h2>Заказ №'.$orderid.' НЕ оплачен через LiqPay или находится в процессе выполнения</h2>');
      }
   }
   
   public function getInvoice()
   {
      return $this->getNotification();
   }
   
   public function getSumWithCoeff()
   {
      return Shop_Controller::instance()->round(($this->_currency_id > 0
      && $this->_shopOrder->shop_currency_id > 0
      ? Shop_Controller::instance()->getCurrencyCoefficientInShopCurrency(
      $this->_shopOrder->Shop_Currency,
      Core_Entity::factory('Shop_Currency', $this->_currency_id)
      )
      : 0) * $this->_shopOrder->getAmount());
   }
   
   public function getNotification()
   {
      $oSite_Alias = $this->_shopOrder->Shop->Site->getCurrentAlias();
      $sum = $this->getSumWithCoeff();
      
      if (is_null($oSite_Alias))
      {
         throw new Core_Exception('Site does not have default alias!');
      }
   
      $shop_path = $this->_shopOrder->Shop->Structure->getPath();
      $handler_url = 'http://' . $oSite_Alias->name . $shop_path . "cart/";

      $default_phone = Core_Array::getPost('phone');

      $Password=$this->_merchant_sig;
      $MerID=$this->_merchant_id;
      $AcqID=$this->_acqid;
      $OrderID=$this->_shopOrder->id;
      $PurchaseCurrencyExponent='2';
      $PurchaseCurrency=$this->_currency;
      $PurchaseCurrencyName=$this->_currency_name;
      $OrderDescription='Zakaz_'.$OrderID;
      $Default_Phone = $this->_shopOrder->phone;

      $xml="<request>      
         <version>1.2</version>
         <merchant_id>$MerID</merchant_id>
         <result_url>$handler_url</result_url>
         <server_url>$handler_url</server_url>
         <order_id>$OrderID</order_id>
         <amount>$sum</amount>
         <currency>$PurchaseCurrencyName</currency>
         <description>$OrderDescription</description>
         <default_phone>$Default_Phone</default_phone>
         <pay_way>card</pay_way>
      </request>";


      $sign=base64_encode(sha1($Password.$xml.$Password,1));
      $xml_encoded=base64_encode($xml);
      ?>

             <h1>Оплата кредитной картой через систему LiqPay</h1>
   
      <p>Сумма к оплате составляет <strong><?php echo $this->_shopOrder->sum()?></strong></p>

      <p>Для оплаты нажмите кнопку "Оплатить".</p>

      <p style="color: rgb(112, 112, 112);">
      Внимание! Нажимая &laquo;Оплатить&raquo; Вы подтверждаете передачу контактных данных на сервер LiqPay для оплаты.
      </p>


      <form action="https://www.liqpay.com/?do=clickNbuy" method="POST" />
             <input type="hidden" name="operation_xml" value="<?php echo $xml_encoded ?>" />
              <input type="hidden" name="signature" value="<?php echo $sign ?>" />
         <input type="submit" value="Оплатить">
      </form>
      <?php
   }
}


Вот ссылка АПИ https://www.liqpay.com/?do=pages&p=cnb12

Буду благодарен за любое содействие
Skype:ferdinant1988 ICQ:311960596 E-mail: ferdinant@i.ua
#
Re: Помогите допилить окультурить код обработчика LiqPay 1.2
Огромное спасибо за код, я сам не программист, просто вставил и все заработало! Единственное что уточню - код ТДС нужно вставлять в третью вкладку - Код страницы
#
Re: Помогите допилить окультурить код обработчика LiqPay 1.2
Огромное спасибо за код, я сам не программист, просто вставил и все заработало! Единственное что уточню - код ТДС нужно вставлять в третью вкладку - Код страницы
Авторизация