ПРОБЛЕМА Интеграция Payeer в скрипт

Darek

Участник
Всем привет. Столкнулся с проблемой интеграции Payeer в скрипт.
Поскольку навыков не хватает, пытался написать на основе Perfect Money
PHP:
<?php
  class perfectmoney extends APayments implements IPayment, IPaymentCallback {
    public $pay_name = "Perfect Money";
    public $settings = array();
    private $amount;
    private $inv_id;
    private $inv_desc;

    public function isCallback() {
      if (!isset($_POST['V2_HASH']))
        return false;
      else
        return true;
    }


    public function process() {
      global $sql;
      if($this->checkSignature()) {
        $inv_id = (integer)$_POST['PAYMENT_ID'];
        $res = $sql->fetchOne("SELECT * FROM pay_outcomming WHERE id = $inv_id");
        if (!empty($res) and ($_POST['PAYMENT_AMOUNT']==$res['paycost'])) {
          if ($res['status']==0) {
            $sql->exec("UPDATE pay_outcomming SET status=1 WHERE id=$inv_id");
            makeOrder($res);
            }
            exit("OK" . $inv_id);
            }
      }
      else
        exit("Bad signature");
    }


    public function getFormBalance($amount) {
      global $sql, $translator;
      $sql->exec("INSERT INTO pay_outcomming(userid, payvariant, paycost, date, status, comments, type)
        VALUES('{$_SESSION['ID']}', 'perfectmoney', $amount, NOW(), '0', '".$translator->_('balance_replenishment')."', 'balance')");
      $this->inv_id = $sql->lastInsertId();
      $this->inv_desc = $translator->_('Deposit_on') . $_SERVER['HTTP_HOST'];
      $this->amount = $amount;
      $output = $this->constructHtml();
      return $output;
    }


    public function getBuyForm($options) {
      global $sql, $translator;
      $sql->exec("INSERT INTO pay_outcomming(userid, payvariant, paycost, paycount, date, status, comments, purchase_id, type)
        VALUES('{$_SESSION['ID']}', 'perfectmoney', {$options['amount']}, {$options['count']}, NOW(), 0, '{$options['desc']}', {$options['purchase_id']}, '{$options['type']}')");
      $this->inv_id = $sql->lastInsertId();
      $this->inv_desc = $translator->_('purchase_of_bids');
      $this->amount = $options['amount'];
      $output = $this->constructHtml();
      return $output;
      }

    protected function constructHtml() {
      $form = '
        <form name="pay" action="https://perfectmoney.com/api/step1.asp" method="post">
          <input type="hidden" name="PAYEE_ACCOUNT" value="'.$this->settings['pmy_account'].'">
          <input type="hidden" name="PAYEE_NAME" value="'.$_SERVER['HTTP_HOST'].'">
          <input type="hidden" name="PAYMENT_ID" value="'.$this->inv_id.'">
          <input type="hidden" name="PAYMENT_AMOUNT" value="'.$this->amount.'">
          <input type="hidden" name="PAYMENT_UNITS" value="'.$this->settings['pmy_cur'].'">
          <input type="hidden" name="STATUS_URL" value="http://'.$_SERVER['HTTP_HOST'].'/payments/payments-callback.php">
          <input type="hidden" name="STATUS_URL_METHOD" value="POST">
          <input type="hidden" name="PAYMENT_URL" value="http://'.$_SERVER['HTTP_HOST'].'/article/success.htm">
          <input type="hidden" name="PAYMENT_URL_METHOD" value="POST">
          <input type="hidden" name="NOPAYMENT_URL" value="http://'.$_SERVER['HTTP_HOST'].'/article/fail.htm">
          <input type="hidden" name="NOPAYMENT_URL_METHOD" value="POST">
          <input type="hidden" name="SUGGESTED_MEMO" value="'.$this->inv_desc.'" >
          <input type="hidden" name="INTERFACE_LANGUAGE" value="ru_RU" >
        </form>';
      return $form;
      }


    public function checkSignature() {
          return strtoupper(md5(implode(':', array($_POST['PAYMENT_ID'], $_POST['PAYEE_ACCOUNT'], $_POST['PAYMENT_AMOUNT'], $_POST['PAYMENT_UNITS'], $_POST['PAYMENT_BATCH_NUM'], $_POST['PAYER_ACCOUNT'], strtoupper(md5($this->settings['pmy_alterpass'])), $_POST['TIMESTAMPGMT'])))) == strtoupper($_POST['V2_HASH']);
      }

    public function writelog($title, $data) {
      $file = 'perfectmoney.log';
      $mode = (file_exists($file) && is_writeable($file)) ? "a" : "w";
      $fp = @fopen($file, $mode);
      fwrite($fp, date('Y-m-d H:i:s') . ": " . $title . ":\r\n");
      if (is_array($data))
        fwrite($fp, var_export($data, true) . "\r\n");
      else
        fwrite($fp, $data . "\r\n");
      fwrite($fp, "\r\n");
      fclose($fp);
    }

  }
?>
Помогите на его основе написать класс для Payeer. Тапками не кидайтесь, сам начал недавно углубляться в эту сферу.
 

pligin

Команда форума
Администратор
Всем привет. Столкнулся с проблемой интеграции Payeer в скрипт.
Поскольку навыков не хватает, пытался написать на основе Perfect Money
PHP:
<?php
  class perfectmoney extends APayments implements IPayment, IPaymentCallback {
    public $pay_name = "Perfect Money";
    public $settings = array();
    private $amount;
    private $inv_id;
    private $inv_desc;

    public function isCallback() {
      if (!isset($_POST['V2_HASH']))
        return false;
      else
        return true;
    }


    public function process() {
      global $sql;
      if($this->checkSignature()) {
        $inv_id = (integer)$_POST['PAYMENT_ID'];
        $res = $sql->fetchOne("SELECT * FROM pay_outcomming WHERE id = $inv_id");
        if (!empty($res) and ($_POST['PAYMENT_AMOUNT']==$res['paycost'])) {
          if ($res['status']==0) {
            $sql->exec("UPDATE pay_outcomming SET status=1 WHERE id=$inv_id");
            makeOrder($res);
            }
            exit("OK" . $inv_id);
            }
      }
      else
        exit("Bad signature");
    }


    public function getFormBalance($amount) {
      global $sql, $translator;
      $sql->exec("INSERT INTO pay_outcomming(userid, payvariant, paycost, date, status, comments, type)
        VALUES('{$_SESSION['ID']}', 'perfectmoney', $amount, NOW(), '0', '".$translator->_('balance_replenishment')."', 'balance')");
      $this->inv_id = $sql->lastInsertId();
      $this->inv_desc = $translator->_('Deposit_on') . $_SERVER['HTTP_HOST'];
      $this->amount = $amount;
      $output = $this->constructHtml();
      return $output;
    }


    public function getBuyForm($options) {
      global $sql, $translator;
      $sql->exec("INSERT INTO pay_outcomming(userid, payvariant, paycost, paycount, date, status, comments, purchase_id, type)
        VALUES('{$_SESSION['ID']}', 'perfectmoney', {$options['amount']}, {$options['count']}, NOW(), 0, '{$options['desc']}', {$options['purchase_id']}, '{$options['type']}')");
      $this->inv_id = $sql->lastInsertId();
      $this->inv_desc = $translator->_('purchase_of_bids');
      $this->amount = $options['amount'];
      $output = $this->constructHtml();
      return $output;
      }

    protected function constructHtml() {
      $form = '
        <form name="pay" action="https://perfectmoney.com/api/step1.asp" method="post">
          <input type="hidden" name="PAYEE_ACCOUNT" value="'.$this->settings['pmy_account'].'">
          <input type="hidden" name="PAYEE_NAME" value="'.$_SERVER['HTTP_HOST'].'">
          <input type="hidden" name="PAYMENT_ID" value="'.$this->inv_id.'">
          <input type="hidden" name="PAYMENT_AMOUNT" value="'.$this->amount.'">
          <input type="hidden" name="PAYMENT_UNITS" value="'.$this->settings['pmy_cur'].'">
          <input type="hidden" name="STATUS_URL" value="http://'.$_SERVER['HTTP_HOST'].'/payments/payments-callback.php">
          <input type="hidden" name="STATUS_URL_METHOD" value="POST">
          <input type="hidden" name="PAYMENT_URL" value="http://'.$_SERVER['HTTP_HOST'].'/article/success.htm">
          <input type="hidden" name="PAYMENT_URL_METHOD" value="POST">
          <input type="hidden" name="NOPAYMENT_URL" value="http://'.$_SERVER['HTTP_HOST'].'/article/fail.htm">
          <input type="hidden" name="NOPAYMENT_URL_METHOD" value="POST">
          <input type="hidden" name="SUGGESTED_MEMO" value="'.$this->inv_desc.'" >
          <input type="hidden" name="INTERFACE_LANGUAGE" value="ru_RU" >
        </form>';
      return $form;
      }


    public function checkSignature() {
          return strtoupper(md5(implode(':', array($_POST['PAYMENT_ID'], $_POST['PAYEE_ACCOUNT'], $_POST['PAYMENT_AMOUNT'], $_POST['PAYMENT_UNITS'], $_POST['PAYMENT_BATCH_NUM'], $_POST['PAYER_ACCOUNT'], strtoupper(md5($this->settings['pmy_alterpass'])), $_POST['TIMESTAMPGMT'])))) == strtoupper($_POST['V2_HASH']);
      }

    public function writelog($title, $data) {
      $file = 'perfectmoney.log';
      $mode = (file_exists($file) && is_writeable($file)) ? "a" : "w";
      $fp = @fopen($file, $mode);
      fwrite($fp, date('Y-m-d H:i:s') . ": " . $title . ":\r\n");
      if (is_array($data))
        fwrite($fp, var_export($data, true) . "\r\n");
      else
        fwrite($fp, $data . "\r\n");
      fwrite($fp, "\r\n");
      fclose($fp);
    }

  }
?>
Помогите на его основе написать класс для Payeer. Тапками не кидайтесь, сам начал недавно углубляться в эту сферу.
"Помогите" - это когда нужна помощь и у самого не получается, а не "сделайте за меня".
В данном случае тут просьба "сделайте за меня". А кому это нужно? Помочь мы всегда рады, а бесплатно работать нет.
Да и ты даже не сказал что за CMS
Могу на завтра принять заказ на написание класса Payeer
 

Darek

Участник
"Помогите" - это когда нужна помощь и у самого не получается, а не "сделайте за меня".
В данном случае тут просьба "сделайте за меня". А кому это нужно? Помочь мы всегда рады, а бесплатно работать нет.
Да и ты даже не сказал что за CMS
Могу на завтра принять заказ на написание класса Payeer
CMS аукциона Scandy.

Стоимость напиши. А по поводу помочь, мне нужен был совет, только почему то не прикрепился код самого Payeer класса который написал.

PHP:
<?php

  class payeer extends APayments implements IPayment, IPaymentCallback {
    public $pay_name = "Payeer";
    public $settings = array();
    private $amount;
    private $inv_id;
    private $inv_desc;

    public function isCallback() {
      if (!isset($_POST['m_shop']))
        return false;
      else
        return true;
    }


    public function process() {
      global $sql;
      if (!$this->checkSignHash())
        exit("bad sign");
      $inv_id = (integer)$_POST['pe_inv_id'];
      $res = $sql->fetchOne("SELECT * FROM pay_outcomming WHERE id = $inv_id");
      if (!empty($res) and ($_POST['m_amount']==$res['paycost'])) {
        if ($res['status']==0) {
          $sql->exec("UPDATE pay_outcomming SET status=1 WHERE id=$inv_id");
          makeOrder($res);
          }
          exit("OK" . $inv_id);
          }
    }


    public function getFormBalance($amount) {
      global $sql, $translator;
      $sql->exec("INSERT INTO pay_outcomming(userid, payvariant, paycost, date, status, comments, type)
        VALUES('{$_SESSION['ID']}', 'payeer', $amount, NOW(), 0, '".$translator->_('balance_replenishment')."', 'balance')");
      $this->inv_id = $sql->lastInsertId();
      $this->inv_desc = $translator->_('Deposit_on') . $_SERVER['HTTP_HOST'];
      $this->amount = $amount;
      $output = $this->constructHtml();
      return $output;
    }


    public function getBuyForm($options) {
      global $sql, $translator;
      $sql->exec("INSERT INTO pay_outcomming(userid, payvariant, paycost, paycount, date, status, comments, purchase_id, type)
        VALUES('{$_SESSION['ID']}', 'payeer', {$options['amount']}, {$options['count']}, NOW(), 0, '{$options['desc']}', {$options['purchase_id']}, '{$options['type']}')");
      $this->inv_id = $sql->lastInsertId();
      $this->inv_desc = $translator->_('purchase_of_bids');
      $this->amount = $options['amount'];
      $output = $this->constructHtml();
      return $output;
      }


    protected function constructHtml() {
      $form = '
                <form method="GET" id="payeer_form_real" action="//payeer.com/merchant/">
                <input type="hidden" name="m_shop" value="'.$this->settings['m_shop'].'">
                <input type="hidden" name="m_orderid" value="'.$this->inv_id.'">
                <input type="hidden" name="m_amount" value="'.$this->amount.'">
                <input type="hidden" name="m_curr" value="'.$this->settings['m_curr'].'">
                <input type="hidden" name="m_desc" value="'.$this->inv_desc.'">
                <input type="hidden" name="m_sign" value="'.$this->generateSignHash().'">
                <input type="submit" name="m_process"  value="Payeer" />
            </form>';
      return $form;
    }


    private function generateSignHash() {
      return sha1($this->settings['m_shop'].":".$this->amount.":".$this->inv_id.":".$this->settings['m_key']);
    }


    private function checkSignHash() {
      if (sha1($this->settings['m_shop'].":".$_POST["m_amount"].":".$_POST["pe_inv_id"].":".$this->settings['m_key'])==$_POST["m_sign"])
        return true;
      else
        return false;
    }


    public function writelog($title, $data) {
        $file = 'payeer.log';
        $mode = (file_exists($file) && is_writeable($file)) ? "a" : "w";
        $fp = @fopen($file, $mode);
        fwrite($fp, date('Y-m-d H:i:s') . ": " . $title . ":\r\n");
        if (is_array($data))
            fwrite($fp, var_export($data, true) . "\r\n");
        else
            fwrite($fp, $data . "\r\n");
        fwrite($fp, "\r\n");
        fclose($fp);
    }

  }
?>
 

pligin

Команда форума
Администратор
 
Верх