Example #1
0
 protected function _toHtml()
 {
     // echo "<pre>";
     //  echo "Response\n";
     //  print_r($_POST);die;
     //  return var_export($_POST, true);
     include_once "Fondy.cls.php";
     $fodny = Mage::getModel('FondyOnPage/FondyOnPage');
     $settings = array('merchant_id' => $fodny->getConfigData('merchant'), 'secret_key' => $fodny->getConfigData('secret_key'));
     try {
         $validated = FondyForm::isPaymentValid($settings, $_POST);
         if ($validated === true) {
             //if ($_POST[])
             list($orderId, ) = explode(FondyForm::ORDER_SEPARATOR, $_POST['order_id']);
             // Payment was successful, so update the order's state, send order email and move to the success page
             $order = Mage::getModel('sales/order');
             $order->loadByIncrementId($orderId);
             if ($fodny->getConfigData('after_pay_status') == Mage_Sales_Model_Order::STATE_PROCESSING) {
                 $order->setState($fodny->getConfigData('after_pay_status'), true, 'Gateway has authorized the payment.');
             } elseif ($fodny->getConfigData('after_pay_status') == Mage_Sales_Model_Order::STATE_HOLDED) {
                 $order->setState($fodny->getConfigData('after_pay_status'), true, 'Gateway has authorized the payment.');
             } else {
                 $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
             }
             $order->sendNewOrderEmail();
             $order->setEmailSent(true);
             $order->save();
             Mage::getSingleton('checkout/session')->unsQuoteId();
             $url = Mage::getUrl('checkout/onepage/success', array('_secure' => true));
             Mage::app()->getFrontController()->getResponse()->setRedirect($url);
         } else {
             // case all is valid but order is not approved
             $url = Mage::getUrl('checkout/onepage/success', array('_secure' => true));
             Mage::app()->getFrontController()->getResponse()->setRedirect($url);
         }
     } catch (Exception $e) {
         // There is a problem in the response we got
         if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
             $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
             if ($order->getId()) {
                 // Flag the order as 'cancelled' and save it
                 $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, $e->getMessage())->save();
             }
         }
         $url = Mage::getUrl('checkout/onepage/failure', array('_secure' => true));
         Mage::app()->getFrontController()->getResponse()->setRedirect($url);
     }
 }
Example #2
0
 public function receive(msOrder $order)
 {
     if (empty($_POST)) {
         $fap = json_decode(file_get_contents("php://input"));
         $_POST = array();
         foreach ($fap as $key => $val) {
             $_POST[$key] = $val;
         }
         $request = $_POST;
     }
     $oplataSettings = array('merchant_id' => FONDY_MERCHANT_ID, 'secret_key' => FONDY_SECRET_KEY);
     $isPaymentValid = FondyForm::isPaymentValid($oplataSettings, $_POST);
     if ($isPaymentValid == true) {
         $id = explode('#', $_POST['order_id']);
         $miniShop2 = $this->modx->getService('miniShop2');
         @($this->modx->context->key = 'mgr');
         $miniShop2->changeOrderStatus($id[0], 2);
         // Setting status "paid"
     } else {
         $this->paymentError($isPaymentValid, $_POST);
     }
 }
Example #3
0
    exit(header("Location: /"));
}
global $SysValue, $link_db;
// Определение платежной системы по $_GET['payment']
if (!empty($_REQUEST['payment'])) {
    if ($_REQUEST['payment'] == 'fondy') {
        if (empty($_POST)) {
            $fap = json_decode(file_get_contents("php://input"));
            $_POST = array();
            foreach ($fap as $key => $val) {
                $_POST[$key] = $val;
            }
        }
        $settings['merchant_id'] = $SysValue['fondy']['fondy_merchant_id'];
        $settings['secret_key'] = $SysValue['fondy']['fondy_secret_key'];
        $valid = FondyForm::isPaymentValid($settings, $_POST);
        if ($valid == true && $_POST['order_status'] == FondyForm::ORDER_APPROVED) {
            $order_metod = "fondy";
            $success_function = true;
            // Выключаем функцию обновления статуса заказа, операция уже выполнена в result.php
            $my_crc = "NoN";
            $crc = "NoN";
            $inv_id = $_GET['inv_id'];
        } else {
            WriteLog($valid);
        }
    }
}
function WriteLog($MY_LMI_HASH)
{
    $handle = fopen("../paymentlog.log", "a+");
Example #4
0
function pmpro_fondyValidate()
{
    $settings = array('merchant_id' => pmpro_getOption("fondy_merchantid"), 'secret_key' => pmpro_getOption("fondy_securitykey"));
    $validated = FondyForm::isPaymentValid($settings, $_POST);
    if ($validated != true) {
        return $validated;
    } else {
        return true;
    }
}
Example #5
0
 /**
  * @return bool
  * оплачивает заказ
  */
 function ProcessResult()
 {
     if (!$_POST['order_status']) {
         return false;
     }
     $oplataSettings = array('merchant_id' => $this->_fondy_merchant_id, 'secret_key' => $this->_fondy_secret_key);
     $isPaymentValid = FondyForm::isPaymentValid($oplataSettings, $_POST);
     if ($isPaymentValid == true) {
         $oShop_Order = $this->_shopOrder;
         $oShop_Order->system_information = "Заказ оплачен через сервис Fondy. Paymant ID заказа в системе - ." . $_POST['payment_id'] . "\n";
         $oShop_Order->paid();
         $this->setXSLs();
         $this->send();
     } else {
         echo $isPaymentValid;
     }
 }