Exemplo n.º 1
0
 function _notify_url()
 {
     $db = JFactory::getDBO();
     $par =& JComponentHelper::getParams('com_djclassifieds');
     $account_type = $this->params["testmode"];
     $user = JFactory::getUser();
     $id = JRequest::getInt('id', '0');
     $paypal_info = $_POST;
     /*$fil = fopen('ppraport/pp_raport.txt', 'a');
     		fwrite($fil, "\n\n--------------------post_first-----------------\n");
     		$post = $_POST;
     		foreach ($post as $key => $value) {
     		fwrite($fil, $key.' - '.$value."\n");
     		}
     		fclose($fil);*/
     $paypal_ipn = new paypal_ipn($paypal_info);
     foreach ($paypal_ipn->paypal_post_vars as $key => $value) {
         if (getType($key) == "string") {
             eval("\${$key}=\$value;");
         }
     }
     $paypal_ipn->send_response($account_type);
     if (!$paypal_ipn->is_verified()) {
         die;
     }
     $paymentstatus = 0;
     $status = $paypal_ipn->get_payment_status();
     $txn_id = $paypal_ipn->paypal_post_vars['txn_id'];
     if ($status == 'Completed' || $status == 'Pending' && $account_type == 1) {
         $query = "SELECT p.*  FROM #__djcf_payments p " . "WHERE p.id='" . $id . "' ";
         $db->setQuery($query);
         $payment = $db->loadObject();
         if ($payment) {
             $query = "UPDATE #__djcf_payments SET status='Completed',transaction_id='" . $txn_id . "' " . "WHERE id=" . $id . " AND method='djcfPaypal'";
             $db->setQuery($query);
             $db->query();
             if ($payment->type == 2) {
                 $date_sort = date("Y-m-d H:i:s");
                 $query = "UPDATE #__djcf_items SET date_sort='" . $date_sort . "' " . "WHERE id=" . $payment->item_id . " ";
                 $db->setQuery($query);
                 $db->query();
             } else {
                 if ($payment->type == 1) {
                     $query = "SELECT p.points  FROM #__djcf_points p WHERE p.id='" . $payment->item_id . "' ";
                     $db->setQuery($query);
                     $points = $db->loadResult();
                     $query = "INSERT INTO #__djcf_users_points (`user_id`,`points`,`description`) " . "VALUES ('" . $payment->user_id . "','" . $points . "','" . JText::_('COM_DJCLASSIFIEDS_POINTS_PACKAGE') . " PayPal <br />" . JText::_('COM_DJCLASSIFIEDS_PAYMENT_ID') . ' ' . $payment->id . "')";
                     $db->setQuery($query);
                     $db->query();
                 } else {
                     $query = "SELECT c.*  FROM #__djcf_items i, #__djcf_categories c " . "WHERE i.cat_id=c.id AND i.id='" . $payment->item_id . "' ";
                     $db->setQuery($query);
                     $cat = $db->loadObject();
                     $pub = 0;
                     if ($cat->autopublish == '1' || $cat->autopublish == '0' && $par->get('autopublish') == '1') {
                         $pub = 1;
                     }
                     $query = "UPDATE #__djcf_items SET payed=1, pay_type='', published='" . $pub . "' " . "WHERE id=" . $payment->item_id . " ";
                     $db->setQuery($query);
                     $db->query();
                 }
             }
         }
     } else {
         $query = "UPDATE #__djcf_payments SET status='" . $status . "',transaction_id='" . $txn_id . "' " . "WHERE id=" . $id . " AND method='djcfPaypal'";
         $db->setQuery($query);
         $db->query();
     }
 }
Exemplo n.º 2
0
include RelativePath . "/Navigator.php";
require "paypal_ipn.php";
//End Include Common Files
$EP = array("EMAIL:SITE_NAME" => $now["sitename"], "EMAIL:SITE_EMAIL" => $now["siteemail"], "EMAIL:SITE_EMAIL_LINK" => "<a href=\"mailto:" . $now["siteemail"] . "\">" . $now["siteemail"] . "</a>", "EMAIL:HOME_URL" => $now["homeurl"], "EMAIL:HOME_PAGE_LINK" => "<a href=\"" . $now["homeurl"] . "index.php\">Home</a>", "EMAIL:BROWSE_LINK" => "<a href=\"" . $now["homeurl"] . "browse.php\">Browse</a>", "EMAIL:SEARCH_LINK" => "<a href=\"" . $now["homeurl"] . "search.php\">Search</a>", "EMAIL:MY_ACCOUNT_LINK" => "<a href=\"" . $now["homeurl"] . "myaccount.php\">My Account</a>", "EMAIL:PAYMENT_LINK_SSL" => "<a href=\"" . $now["secureurl"] . "MakePayment.php\">Make a Payment</a>", "EMAIL:PAYMENT_LINK" => "<a href=\"" . $now["homeurl"] . "MakePayment.php\">Make a Payment</a>", "EMAIL:CURRENCY" => $charges["currency"], "EMAIL:LISTING_FEE" => $charges["listing_fee"], "EMAIL:HOMEPAGE_FEATURED_FEE" => $charges["homepage_fee"], "EMAIL:CATEGORY_FEATURED_FEE" => $charges["category_fee"], "EMAIL:GALLERY_FEE" => $charges["gallery_fee"], "EMAIL:IMAGE_PREVIEW_FEE" => $charges["image_preview_fee"], "EMAIL:SLIDE_SHOW_FEE" => $charges["slide_fee"], "EMAIL:COUNTER_FEE" => $charges["counter_fee"], "EMAIL:BOLD_FEE" => $charges["bold_fee"], "EMAIL:BACKGROUND_FEE" => $charges["highlight_fee"], "EMAIL:IMAGE_UPLOAD_FEE" => $charges["upload_fee"], "EMAIL:CURRENT_TIME" => date("F j, Y, g:i a"));
$item_name = $_POST['item_name'];
$receiver_email = $_POST['receiver_email'];
$item_number = $_POST['item_number'];
$invoice = $_POST['invoice'];
$payment_status = $_POST['payment_status'];
$payment_gross = $_POST['mc_gross'];
$txn_id = $_POST['txn_id'];
$payer_email = $_POST['payer_email'];
$payer_id = $_POST['custom'];
// PayPal will send the information through a POST
$paypal_info = $_POST;
$paypal_ipn = new paypal_ipn($paypal_info);
// where to contact us if something goes wrong
$paypal_ipn->error_email = $now["siteemail"];
// We send an identical response back to PayPal for verification
$paypal_ipn->send_response();
// PayPal will tell us whether or not this order is valid.
// This will prevent people from simply running your order script
// manually
if (!$paypal_ipn->is_verified()) {
    // bad order, someone must have tried to run this script manually
    $paypal_ipn->error_out("Bad order (PayPal says it's invalid)");
}
// payment status
switch ($paypal_ipn->get_payment_status()) {
    case 'Completed':
        // order is good
Exemplo n.º 3
0
 function _notify_url()
 {
     $db = JFactory::getDBO();
     $par =& JComponentHelper::getParams('com_djclassifieds');
     $account_type = $this->params["testmode"];
     $user = JFactory::getUser();
     $id = JRequest::getInt('id', '0');
     $paypal_info = $_POST;
     /*$fil = fopen('ppraport/pp_raport.txt', 'a');
     		fwrite($fil, "\n\n--------------------post_first-----------------\n");
     		$post = $_POST;
     		foreach ($post as $key => $value) {
     		fwrite($fil, $key.' - '.$value."\n");
     		}
     		fclose($fil);*/
     $paypal_ipn = new paypal_ipn($paypal_info);
     foreach ($paypal_ipn->paypal_post_vars as $key => $value) {
         if (getType($key) == "string") {
             eval("\${$key}=\$value;");
         }
     }
     $paypal_ipn->send_response($account_type);
     if (!$paypal_ipn->is_verified()) {
         die;
     }
     $paymentstatus = 0;
     $status = $paypal_ipn->get_payment_status();
     $txn_id = $paypal_ipn->paypal_post_vars['txn_id'];
     if ($status == 'Completed' || $status == 'Pending' && $account_type == 1) {
         $query = "SELECT p.*  FROM #__djcf_payments p " . "WHERE p.id='" . $id . "' ";
         $db->setQuery($query);
         $payment = $db->loadObject();
         if ($payment) {
             if (JRequest::getVar('mc_gross') != $payment->price) {
                 die('Wrong amount');
             }
             $query = "UPDATE #__djcf_payments SET status='Completed',transaction_id='" . $txn_id . "' " . "WHERE id=" . $id . " AND method='djcfPaypal'";
             $db->setQuery($query);
             $db->query();
             if ($row->type == 3) {
                 //subscription plans
                 $query = "SELECT p.*  FROM #__djcf_plans p WHERE p.id='" . $row->item_id . "' ";
                 $db->setQuery($query);
                 $plan = $db->loadObject();
                 $registry = new JRegistry();
                 $registry->loadString($plan->params);
                 $plan_params = $registry->toObject();
                 //echo '<pre>';print_r($plan_params);die();
                 $date_start = date("Y-m-d H:i:s");
                 $date_exp = '';
                 if ($plan_params->days_limit) {
                     $date_exp_time = time() + $plan_params->days_limit * 24 * 60 * 60;
                     $date_exp = date("Y-m-d H:i:s", $date_exp_time);
                 }
                 $query = "INSERT INTO #__djcf_plans_subscr (`user_id`,`plan_id`,`adverts_limit`,`adverts_available`,`date_start`,`date_exp`,`plan_params`) " . "VALUES ('" . $row->user_id . "','" . $plan->id . "','" . $plan_params->ad_limit . "','" . $plan_params->ad_limit . "','" . $date_start . "','" . $date_exp . "','" . addslashes($plan->params) . "')";
                 $db->setQuery($query);
                 $db->query();
                 $message = JText::_('COM_DJCLASSIFIEDS_STATUS_CHANGED_SUBSCRIPTION_PLAN_ADDED');
             } else {
                 if ($payment->type == 2) {
                     $date_sort = date("Y-m-d H:i:s");
                     $query = "UPDATE #__djcf_items SET date_sort='" . $date_sort . "' " . "WHERE id=" . $payment->item_id . " ";
                     $db->setQuery($query);
                     $db->query();
                 } else {
                     if ($payment->type == 1) {
                         $query = "SELECT p.points  FROM #__djcf_points p WHERE p.id='" . $payment->item_id . "' ";
                         $db->setQuery($query);
                         $points = $db->loadResult();
                         $query = "INSERT INTO #__djcf_users_points (`user_id`,`points`,`description`) " . "VALUES ('" . $payment->user_id . "','" . $points . "','" . JText::_('COM_DJCLASSIFIEDS_POINTS_PACKAGE') . " PayPal <br />" . JText::_('COM_DJCLASSIFIEDS_PAYMENT_ID') . ' ' . $payment->id . "')";
                         $db->setQuery($query);
                         $db->query();
                     } else {
                         $query = "SELECT c.*  FROM #__djcf_items i, #__djcf_categories c " . "WHERE i.cat_id=c.id AND i.id='" . $payment->item_id . "' ";
                         $db->setQuery($query);
                         $cat = $db->loadObject();
                         $pub = 0;
                         if ($cat->autopublish == '1' || $cat->autopublish == '0' && $par->get('autopublish') == '1') {
                             $pub = 1;
                         }
                         $query = "UPDATE #__djcf_items SET payed=1, pay_type='',extra_images_to_pay='0',extra_chars_to_pay='0', published='" . $pub . "' " . "WHERE id=" . $payment->item_id . " ";
                         $db->setQuery($query);
                         $db->query();
                         if ($pub) {
                             DJClassifiedsNotify::notifyUserPublication($payment->item_id, '1');
                         }
                     }
                 }
             }
             $payment->status = 'Completed';
             $dispatcher = JDispatcher::getInstance();
             $dispatcher->trigger('onAfterPaymentStatusChange', array($payment));
         }
     } else {
         $query = "UPDATE #__djcf_payments SET status='" . $status . "',transaction_id='" . $txn_id . "' " . "WHERE id=" . $id . " AND method='djcfPaypal'";
         $db->setQuery($query);
         $db->query();
     }
 }
Exemplo n.º 4
0
        @reset($this->paypal_post_vars);
        while (@(list($key, $value) = @each($this->paypal_post_vars))) {
            $message .= $key . ':' . " \t{$value}\n";
        }
        mail($this->error_email, "[{$date}] paypay_ipn notification", $message, $em_headers);
    }
}
// get the userid out of the first part of the POSTed $custom value from paypal
$n27_userid = trim($_POST['custom']);
// email header used for the payment notifications
$em_headers = "From: noreply@mydomain.com <from_email>\n";
$em_headers .= "Reply-To: from_email\n";
$em_headers .= "Return-Path: from_email\n";
$em_headers .= "Organization: Network27\n";
$em_headers .= "X-Priority: 3\n";
$paypal_ipn = new paypal_ipn($_POST);
foreach ($paypal_ipn->paypal_post_vars as $key => $value) {
    if (getType($key) == "string") {
        eval("\${$key}=\$value;");
    }
}
$paypal_ipn->send_response();
$paypal_ipn->error_email = $_SESSION['PAYPAL_NOTIFICATION_EMAIL'];
if (!$paypal_ipn->is_verified()) {
    $paypal_ipn->error_out("Bad order (PayPal says it's invalid)" . $paypal_ipn->paypal_response, $em_headers);
    die;
}
switch ($paypal_ipn->get_payment_status()) {
    case 'Pending':
        $pending_reason = $paypal_ipn->paypal_post_vars['pending_reason'];
        if ($pending_reason != "intl") {
<?php

// ---- PayPal IPN pocessing ------------
include "../include/payment/class.paypal_ipn.php";
include "../include/config.php";
include "../include/function.php";
global $config, $conn;
$paypal_info = $_POST;
$paypal_ipn = new paypal_ipn($paypal_info, "*****@*****.**", "*****@*****.**", 'Hello');
$paypal_ipn->send_response();
if (!isset($receiver_email)) {
    $paypal_ipn->error_out("Fraud attempt was detected. (PayPal's receiver email is not set)");
    exit;
}
$paypal_currency = 'USD';
if ($paypal_currency != $mc_currency) {
    $paypal_ipn->error_out("Fraud attempt was detected. (Payer uses another currency then site)");
    exit;
}
// should be changed:
if (strtolower($receiver_email) != strtolower($config[paypal_receiver_email])) {
    $paypal_ipn->error_out("Fraud attempt was detected. (PayPal's receiver email is not equal to attempting's receiver email: {$receiver_email})");
    exit;
}
if ($paypal_ipn->is_verified()) {
    $uniqueid = explode("|", $custom);
    $userid = $uniqueid[0];
    $pack_id = $uniqueid[1];
    $period = $uniqueid[2];
    $theprice = $uniqueid[3];
    //                mailing("*****@*****.**","Stream it Now","*****@*****.**","$userid, $pack, $period, $mailto","Test email");
Exemplo n.º 6
0
 function run()
 {
     $debug = array();
     $ipn = new paypal_ipn($this->app->config->paypal_email, 0);
     $payments = $this->app->loadClass('paypalpayments');
     $users = $this->app->loadClass('users');
     $config = $this->app->config;
     // 1) Check it is a valid paypal ipn post...
     if ($ipn->process() == true) {
         // 2) check that the payment has been made to us
         if ($ipn->data['receiver_email'] == $config->paypal_email || $ipn->data['receiver_email'] == $config->paypal_account_email) {
             $debug[] = "Business checked ok...\n";
             // 3) check that payment made by a valid user (and get that user)
             $username = $ipn->data['item_number'];
             $user = $users->getuser(array('username' => $username));
             if ($user) {
                 $debug[] = "Got User<br />\n";
                 // 4a) Handle subscription signup notifications...
                 if ($ipn->data['txn_type'] == 'subscr_signup') {
                     $debug[] = "Signup notification<br />\n";
                     // i) if user doesn't already have this subscription id, check that the months and price is valid and update user...
                     if ($ipn->data['subscr_id'] != $user->sub_id) {
                         $months = 0;
                         if (preg_match('/^([0-9]+).*?m/i', $ipn->data['period3'], $match)) {
                             $months = (int) $match[1];
                         }
                         $amount = (double) $ipn->data['amount3'];
                         if (in_array($months, array(1, 3, 6, 12))) {
                             $avar = 'price_' . $months;
                             $realprice = $config->{$avar};
                             if ($realprice == $amount) {
                                 $ups = array('sub_id' => $ipn->data['subscr_id'], 'sub_months' => $months, 'sub_amount' => $amount);
                                 $users->updateusers(array($user->user_id), $ups);
                             }
                         }
                     }
                     $debug[] = "Signup notification processed...<br />";
                 } elseif ($ipn->data['txn_type'] == 'subscr_payment') {
                     $debug[] = "Subscription payment<br />";
                     // i) check that the payment is complete
                     if ($ipn->isComplete()) {
                         $debug[] = "Status is complete<br />\n";
                         // ii) check that the currency is correct...
                         if ($ipn->data['mc_currency'] == 'USD') {
                             $debug[] = "currency ok<br />";
                             // iii) check that the price / duration is valid - first see if the user has these values set...
                             $valid = false;
                             $amount = (double) $ipn->data['mc_gross'];
                             $months = 0;
                             if ($user->sub_id != '' && $user->sub_id == $ipn->data['subscr_id']) {
                                 if ($user->sub_amount != 0 && $user->sub_amount == $amount) {
                                     $months = $user->sub_months;
                                     $valid = true;
                                 }
                             }
                             // couldn't validate payment against user, so check our plans instead...
                             if (!$valid) {
                                 if ($config->price_1 == $amount) {
                                     $months = 1;
                                 } elseif ($config->price_3 == $amount) {
                                     $months = 3;
                                 } elseif ($config->price_6 == $amount) {
                                     $months = 6;
                                 } elseif ($config->price_12 == $amount) {
                                     $months = 12;
                                 }
                                 if ($months != 0) {
                                     $valid = true;
                                 }
                             }
                             // if everything so far is valid, continue
                             if ($valid) {
                                 $debug[] = "Valid Payment<br />";
                                 // confirm this isn't a duplicate payment...
                                 if (!$payments->getpayments(array('count' => true, 'txnid' => $ipn->data['txn_id']))) {
                                     $debug[] = "Not a duplicate<br />";
                                     // add this payment to the database
                                     $pid = $payments->addpayment($ipn->data['txn_id'], $ipn->data['subscr_id'], $user->user_id, $ipn->data['payer_email'], $ipn->data['mc_gross'], 1, $ipn->data);
                                     if ($pid) {
                                         $debug[] = "Payment added<br />\n";
                                         // set the user to "paid account" and extend their days of paid
                                         $users->upgradeuser($user, $months, $ipn);
                                         // if we are sending upgrade confirmation emails, send 1 :)
                                         $debug[] = "Payment added OK!";
                                     }
                                     // end payment inserted ok
                                 } else {
                                     // end no duplicate payment
                                     $debug[] = "Duplicate payment\n";
                                 }
                             } else {
                                 // end everything is valid
                                 $debug[] = "Everything is not valid\n";
                             }
                         } else {
                             // end currency ok
                             $debug[] = "Wrong currency\n";
                         }
                     } else {
                         // end complete
                         $debug[] = "Payment is  not complete.";
                     }
                 } else {
                     // end payment type check
                     $debug[] = "Payment type is wrong\n";
                 }
             } else {
                 // end user check
                 $debug[] = "User doesn't exist.\n";
             }
         } else {
             // end business check
             $debug[] = "Receiver email (" . $ipn->data['receiver_email'] . " != {$config->paypal_email}\n";
         }
     } else {
         $debug[] = "No bloody ipn.";
         switch ($ipn->error_code) {
             case ERR_INVALID:
                 break;
             case ERR_SOCKETS:
                 break;
         }
     }
     print_r($debug);
     exit;
 }