Example #1
0
 function plgVmOnPaymentNotification()
 {
     if (empty($_POST)) {
         $fap = json_decode(file_get_contents("php://input"));
         $_POST = array();
         foreach ($fap as $key => $val) {
             $_POST[$key] = $val;
         }
     }
     $_SERVER['REQUEST_URI'] = '';
     $_SERVER['SCRIPT_NAME'] = '';
     $_SERVER['QUERY_STRING'] = '';
     define('_JEXEC', 1);
     define('DS', DIRECTORY_SEPARATOR);
     $option = 'com_virtuemart';
     $my_path = dirname(__FILE__);
     $my_path = explode(DS . 'plugins', $my_path);
     $my_path = $my_path[0];
     if (file_exists($my_path . '/defines.php')) {
         include_once $my_path . '/defines.php';
     }
     if (!defined('_JDEFINES')) {
         define('JPATH_BASE', $my_path);
         require_once JPATH_BASE . '/includes/defines.php';
     }
     define('JPATH_COMPONENT', JPATH_BASE . '/components/' . $option);
     define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/' . $option);
     define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option);
     require_once JPATH_BASE . '/includes/framework.php';
     $app = JFactory::getApplication('site');
     $app->initialise();
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.fphp';
     }
     if (!class_exists('plgVmPaymentFondy')) {
         require dirname(__FILE__) . DS . 'fondy.php';
     }
     require dirname(__FILE__) . DS . 'Fondy.cls.php';
     //print_r ($_POST);die;
     list($order_id, ) = explode(Fondy::ORDER_SEPARATOR, $_POST['order_id']);
     $order = new VirtueMartModelOrders();
     $method = new plgVmPaymentFondy();
     $order_s_id = $order->getOrderIdByOrderNumber($order_id);
     $orderitems = $order->getOrder($order_s_id);
     $methoditems = $method->__getVmPluginMethod($orderitems['details']['BT']->virtuemart_paymentmethod_id);
     $option = array('merchant_id' => $methoditems->FONDY_MERCHANT, 'secret_key' => $methoditems->FONDY_SECRET_KEY);
     $response = Fondy::isPaymentValid($option, $_POST);
     if ($response === true) {
         $red = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $paymentMethodID);
         header('Location:' . $red);
         $datetime = date("YmdHis");
         echo "OK";
     } else {
         echo "<!-- {$response} -->";
     }
     $orderitems['order_status'] = $methoditems->status_success;
     $orderitems['customer_notified'] = 0;
     $orderitems['virtuemart_order_id'] = $order_s_id;
     $orderitems['comments'] = 'Fondy ID: ' . $order_id . " Ref ID : " . $_POST['payment_id'];
     $order->updateStatusForOneOrder($order_s_id, $orderitems, true);
 }
Example #2
0
/**
 * Function pay_get
 **/
function pay_get()
{
    global $gData;
    //    echo "<pre>";
    //    print_r($_POST);
    //    exit;
    // Connect to Data
    $gData = data_connect();
    list($orderId, ) = explode(FONDY::ORDER_SEPARATOR, $_POST['order_id']);
    list(, $orderId) = explode('-', $orderId);
    $order = $gData->GetArchiveOrder($orderId * 1);
    $fondy = new Fondy();
    $settings = array('merchant' => MERCHANT_ID, 'secretkey' => MERCHANT_SECRET);
    $invoice_url = HOST_NAME . 'invoice.php?order_id=' . $orderId . '&order_sid=' . $order['sid'];
    if ($_POST['order_status'] == Fondy::ORDER_DECLINED) {
        header('location: ' . $invoice_url);
    }
    $paymentInfo = $fondy->isPaymentValid($settings, $_REQUEST);
    if ($paymentInfo === true && isset($_REQUEST['send_email']) && !empty($_REQUEST['send_email'])) {
        $content = sendEmailToAdmin($order);
        return $content;
    } else {
        header('location: ' . $invoice_url);
    }
}