<?php

/**
* Входящий платеж
*/

if (isset($_POST['m_operation_id'])) {
  
  $set_paytype = $payment->getSettings('payeer');

  $checkPOST = array(
                  'id' => (int) $_POST['m_orderid'], 
                  'wmr' => round($_POST['m_amount'], 2), 
                  'array' => serialize($_POST),
                  'paytype' => 'payeer',
                  'method' => 'Payeer',
                  'resp' => (int) $_POST['m_orderid'] . '|success',
                  );
  
  if ($request === 'result' && $_POST['m_status'] === 'success') 
  {
    $data = array(
            		$_POST['m_operation_id'],
            		$_POST['m_operation_ps'],
            		$_POST['m_operation_date'],
            		$_POST['m_operation_pay_date'],
            		$_POST['m_shop'],
            		$_POST['m_orderid'],
            		$_POST['m_amount'],
            		$_POST['m_curr'],
            		$_POST['m_desc'],
            		$_POST['m_status'],
                $set_paytype['PAYMENT']['SECRET_KEY']
                );
    
    $hash = strtoupper(hash('sha256', implode(":", $data)));

    if ($hash === $_POST['m_sign']) {
      $pay_result = 'result';
    }  
  } 
  
  else {
    die($_POST['m_orderid'] . '|error');
  }
}

if (isset($_GET['m_orderid'])) {
  $set_paytype = $payment->getSettings('payeer');
  
  $checkPOST = array(
                  'id' => (int) $_GET['m_orderid'], 
                  'paytype' => 'payeer',
                  );
                  
  $pay_result = ($_GET['m_status'] == 'success' ? 'success' : 'fail');
}