示例#1
0
 function validate_callback($proc)
 {
     global $Itemid, $JLMS_CONFIG, $JLMS_DB;
     $params = new JLMSParameters($proc->params);
     $req = 'cmd=_notify-validate';
     foreach ($_POST as $key => $value) {
         $value = urlencode(stripslashes($value));
         $req .= "&{$key}={$value}";
     }
     // post back to PayPal system to validate
     $server_url2 = str_replace('https://', '', str_replace('/cgi-bin/webscr', '', $params->get('server_url')));
     $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
     $header .= "Host: " . $server_url2 . "\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
     $fp = fsockopen($server_url2, 80, $errno, $errstr, 30);
     //mosMail( '*****@*****.**', 'BOT LMS Trial', '*****@*****.**', 'Paypal', $server_url2, false, NULL, NULL );
     // assign posted variables to local variables
     $item_name = $_POST['item_name'];
     $item_number = $_POST['item_number'];
     $payment_status = $_POST['payment_status'];
     $payment_amount = $_POST['mc_gross'];
     $payment_currency = $_POST['mc_currency'];
     $txn_id = $_POST['txn_id'];
     $receiver_email = $_POST['receiver_email'];
     $business = $_POST['business'];
     $payer_email = $_POST['payer_email'];
     $payment_date = $_POST['payment_date'];
     $tax_amount = $_POST['option_selection1'];
     $tax_paypal = isset($_POST['tax']) ? $_POST['tax'] : 0;
     if (!$fp) {
         // nothing here ?!
     } else {
         fputs($fp, $header . $req);
         while (!feof($fp)) {
             $res_pp = fgets($fp, 1024);
             if (strcmp($res_pp, "VERIFIED") == 0) {
                 /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  VERIFIED  !!!!!!!!!!!!!!!!!11
                 require_once _JOOMLMS_FRONT_HOME . '/includes/joomla_lms.subscription.lib.php';
                 if ($payment_status == 'Completed') {
                     // check that receiver_email is your Primary PayPal email
                     if ($receiver_email != $params->get('business_email') && $business != $params->get('business_email')) {
                         die;
                     }
                     if ($payment_currency != $JLMS_CONFIG->get('jlms_cur_code')) {
                         die;
                     }
                     if (!jlms_check_payment_transaction($payment_amount - $tax_paypal, $item_number)) {
                         die('Invalid payment amount');
                     }
                     $query = "SELECT status FROM `#__lms_payments` WHERE id = {$item_number} ";
                     $JLMS_DB->setQuery($query);
                     $prev_payment = $JLMS_DB->LoadResult();
                     jlms_update_payment($item_number, $txn_id, 'Completed', $payment_date, $tax_amount + $tax_paypal, $tax_paypal);
                     if ($prev_payment == 'Completed') {
                     } else {
                         jlms_register_new_user($item_number);
                     }
                 } elseif ($payment_status == 'Pending') {
                     jlms_update_payment($item_number, $txn_id, 'Pending', $payment_date, $tax_amount, $tax_paypal);
                 }
             } elseif (strcmp($res_pp, "INVALID") == 0) {
                 JLMSRedirect(sefRelToAbs("index.php?option=com_joomla_lms&Itemid={$Itemid}"));
             }
         }
         fclose($fp);
     }
 }
示例#2
0
    function validate_callback($proc)
    {
        global $JLMS_DB, $Itemid, $JLMS_CONFIG, $JLMS_DB;
        $params = new JLMSParameters($proc->params);
        // assign posted variables to local variables
        $payment_status = $_REQUEST['transStatus'];
        $payment_amount = $_REQUEST['authAmount'];
        $payment_currency = $_REQUEST['authCurrency'];
        $txn_id = $_REQUEST['transId'];
        $payment_date = date("Y-m-d H:i:s", mktime());
        $order = $_REQUEST['MC_order'];
        $tax_amount = $_REQUEST['MC_tax'];
        $user_id = $_REQUEST['MC_user'];
        $callback_pw = @$_REQUEST['callbackPW'];
        if ($payment_status != 'Y') {
            die('Invalid transaction status');
        }
        if ($callback_pw != $params->get('callback_pw')) {
            die('Invalid callback password');
        }
        // check that txn_id has not been previously processed
        $query = "SELECT id FROM `#__lms_payments` WHERE txn_id='" . $txn_id . "'  ";
        $JLMS_DB->setQuery($query);
        $res = $JLMS_DB->query();
        if (mysql_num_rows($res)) {
            die;
        }
        // check that payment_currency is correct
        if ($payment_currency != $JLMS_CONFIG->get('jlms_cur_code')) {
            die;
        }
        require_once _JOOMLMS_FRONT_HOME . '/includes/joomla_lms.subscription.lib.php';
        if ($payment_status == 'Y') {
            if (!jlms_check_payment_transaction($payment_amount - $tax_amount, $order)) {
                die('Invalid payment amount');
            }
            $query = "SELECT status FROM `#__lms_payments` WHERE id = {$order} ";
            $JLMS_DB->setQuery($query);
            $prev_payment = $JLMS_DB->LoadResult();
            jlms_update_payment($order, $txn_id, 'Completed', $payment_date);
            if ($prev_payment == 'Completed') {
            } else {
                jlms_register_new_user($order);
            }
            ?>
		Thanks for your payment, you were successfully added to the course.
<?php 
        } elseif ($payment_status == 'C') {
            jlms_update_payment($order, $txn_id, 'Pending', $payment_date);
            ?>
		Your payment status is still 'pending'. You will be added to the course as soon as your payment is confirmed.
<?php 
        }
    }
示例#3
0
 function validate_callback($proc)
 {
     global $Itemid, $JLMS_CONFIG, $JLMS_DB;
     $params = new JLMSParameters($proc->params);
     if (!isset($_REQUEST["x_invoice_num"]) || empty($_REQUEST["x_invoice_num"])) {
         echo "Order ID is not set or empty!";
     } else {
         if ($_REQUEST['x_Login'] != $params->get('x_login', '')) {
             die('Invalid account number.');
         }
         // demo transaction
         if (isset($_REQUEST['demo']) && $_REQUEST['demo'] == "Y" && !$params->get('demo', '')) {
             die('Demo mode is switched off.');
         }
         $order_number = mosGetParam($_REQUEST, "x_invoice_num");
         $compare_string = $params->get('x_secret') . $params->get('x_login') . $_REQUEST['order_number'] . $_REQUEST['x_amount'];
         $payment_date = date("Y-m-d H:i:s", mktime());
         $compare_hash1 = strtoupper(md5($compare_string));
         $compare_hash2 = $_REQUEST['x_MD5_Hash'];
         if ($compare_hash1 != $compare_hash2 && !$params->get('demo')) {
             die('Invalid secret hash.');
         }
         if ($_REQUEST['x_response_code'] == '1' && $_REQUEST['x_2checked'] == 'Y') {
             $payment_amount = $_REQUEST['x_amount'];
             $tax_amount = $_REQUEST['tax_amount'];
             $txn_id = $_REQUEST['x_trans_id'];
             if ($params->get('demo')) {
                 $txn_id .= ' - demo mode';
             }
             $payment_date = date("Y-m-d H:i:s");
             $order_id = $_REQUEST['custom'];
             $user_id = $_REQUEST['userid'];
             $payment_currency = $JLMS_CONFIG->get('jlms_cur_code');
             require_once _JOOMLMS_FRONT_HOME . '/includes/joomla_lms.subscription.lib.php';
             if (!jlms_check_payment_transaction($payment_amount - $tax_amount, $order_id)) {
                 die('Invalid payment amount');
             }
             $query = "SELECT status FROM `#__lms_payments` WHERE id = {$order_id} ";
             $JLMS_DB->setQuery($query);
             $prev_payment = $JLMS_DB->LoadResult();
             jlms_update_payment($order_id, $txn_id, 'Completed', $payment_date);
             if ($prev_payment == 'Completed') {
             } else {
                 jlms_register_new_user($order_id);
             }
         }
         if ($params->get('return_url') == '') {
             JLMSRedirect($JLMS_CONFIG->get('live_site'));
         } else {
             JLMSRedirect($params->get('return_url'));
         }
     }
 }