gp_LogGatewayTrans("PayPal", $ipnValid[1], "Invalid IPN"); exit; } // Check that the payment status is completed if ($ipnValid[1]['payment_status'] !== "Completed") { gp_LogGatewayTrans("PayPal", $ipnValid[1], $ipnValid[1]['payment_status']); exit; } //Check that we havn't credited for it already $query = 'SELECT * FROM tblaccounts WHERE transid=\'' . $ipnValid[1]['txn_id'] . '\''; if (mysql_num_rows(mysql_query($query))) { exit; } $gpSettings = gp_LoadSettings(); //Begin to credit the client //TODO: Uncomment //$clientId = 1; $clientId = gp_LoadUserFromHash($ipnValid[1]['custom']); gp_LogGatewayTrans("PayPal", $ipnValid[1], "Successful"); if ($clientId) { //Apply the Credit // Get the clients currency and apply the rate $currency = getCurrency($clientId); //Write the Transactions mysql_query("INSERT INTO `tblaccounts` (userid,gateway,`date`,description,amountin,fees,transid,invoiceid,`rate`)\n \t\t\t\t\t\t values ({$clientId},'paypal',now(),'" . $gpSettings['SystemName'] . " Credit'," . $ipnValid[1]['mc_gross'] . "," . $ipnValid[1]['mc_fee'] . ",'" . $ipnValid[1]['txn_id'] . "',0,'" . $currency['rate'] . "')"); //Increase the credit balance mysql_query("UPDATE `tblclients` set credit = credit + " . $ipnValid[1]['mc_gross'] . " where id = {$clientId}"); //Add it to the credit log mysql_query("INSERT INTO `tblcredit` (clientid,date,description,amount)\n\t\t\t\t\t values ({$clientId},now(),'" . $gpSettings['SystemName'] . " Credit " . $ipnValid[1]['payer_email'] . "'," . $ipnValid[1]['mc_gross'] . ")"); run_hook("groupPay_paymentComplete", array("clientId" => $clientId, "paypalInfo" => $ipnValid[1])); }
$breadcrumbnav = '<a href="index.php">' . $_LANG['globalsystemname'] . '</a> > <a href="grouppay.php">' . $gpSettings['SystemName'] . '</a>'; initialiseClientArea($pagetitle, $pageicon, $breadcrumbnav); //require("init.php"); # Define the template filename to be used without the .tpl extension $templatefile = "grouppay"; $userHash = $_GET['hash']; $fromPaypal = $_GET['fromPaypal'] == 'true'; //Load the grouppay settings $gpPayPalEmail = gp_LoadPayPayEmail(); //Define up some smarty vars for the template $loggedInClientHash = $_SESSION['uid'] ? gp_HashUserId($_SESSION['uid']) : ""; $smartyvalues["loggedInClientHash"] = $loggedInClientHash; //If we are loading this for a user (other than logged in if applicable) if (isset($userHash) && ($userHash != "" && $userHash != $loggedInClientHash)) { $smartyvalues["anotherClientHash"] = true; $clientId = gp_LoadUserFromHash($userHash); $result = mysql_query("SELECT * from tblclients where id = {$clientId}"); $smartyvalues["clientFound"] = $clientInfo = mysql_fetch_assoc($result); $smartyvalues["clientInfo"] = $clientInfo; $smartyvalues["clientHash"] = $userHash; } else { $smartyvalues["anotherClientHash"] = false; // Load the past payments $clientId = $_SESSION['uid']; $smartyvalues["clientFound"] = false; } // Load the past Payments $pastPayments = array(); if (!$smartyvalues['anotherClientHash'] || $gpSettings['HidePublicPayments'] != "on") { $dbPastPayments = mysql_query("SELECT * from `tblcredit` where `clientid` = " . $clientId . " and `description` LIKE '{$gpSettings['SystemName']}%'"); while ($pastPayment = mysql_fetch_array($dbPastPayments)) {