Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury
Author Message
stravides
New Member
New Member



Joined: Aug 26, 2006
Posts: 5

PostPosted: Wed Aug 30, 2006 2:22 am Reply with quote

Hi! I downloaded the treasury module 2006 (aka 1.1.1) and have a a few problems.

Server Info:
OS: Windows 2003 - IIS6
CMS: PHPNuke 7.9
DB: MySQL 5
Mod: Nuke Treasury 1.1 (2006 UK)

I am a bit of a noob on this, so bear with me, please. I have read lots of posts with the subject "treasury", "IPN" and/or "Donat-o-meter" none has helped so far...

Problem: As always cannot get the donate-o-meter (ref as DOM) to play ball and receive updates from the IPN.

After 6 days of trying I have decided that its about time to post up and get this beast working.

History so far (its getting to be a bit of a saga now).
Installed phpnuke7.9
configured and working - installed nuke treasury
didnt work so set all permissions for IIS to full control (testing purposes) (chmod 777 basically)
Paypal - Set it to ON and then entered the URL for the ipndd.php
changed internal config for username etc... thought everything ok.
Made donation - whoo hooo a whole £1, but DOM says Zip.
Looked in the database for the log and got
Code:
Connection to db - OK!

Opening connection and validating request with PayPal...
OK!
Logging events<br>

Debug was fine - no errors
Still not working
visited this website tried numerous fixes
visited some page where I could test out my ipn script and got this result
Code:


Connection to db - OK!
Opening connection and validating request with PayPal...
OK!
Invalid IPN transaction, this is an abnormal condition
payment_date => 12:04:22 Aug 29, 2006 PDT
txn_type => web_accept
last_name => <DETAILS HERE BLANKED>
option_selection1 => Yes
residence_country => GB
item_name => Donation
payment_gross =>
mc_currency => GBP
business => [ Only registered users can see links on this board! Get registered or login! ]
payment_type => instant
verify_sign => <DETAILS HERE BLANKED>
payer_status => unverified
tax => 0.00
payer_email => [ Only registered users can see links on this board! Get registered or login! ]
txn_id => 74X199133B1215237
quantity => 1
receiver_email => [ Only registered users can see links on this board! Get registered or login! ]
first_name => Ken
option_name1 => List your name?
payer_id => 4ZUDJFKKF4K38
receiver_id => 5WSA4BFCPGKBC
item_number => 110
payment_status => Completed
payment_fee =>
mc_fee => 0.23
shipping => 0.00
mc_gross => 1.00
custom => ffiona
charset => windows-1252
notify_version => 2.1
Logging events<br>

No idea why, but needless to say that this still did not update as it was INVALID.
Have never got the DB to replicate this since...
Opened port 443 as per some external fix re 503 errors all to no joy..
I tried the raven nuke port, but as it uses short_open_tags I would have to convert every single <? to <php and every <?= to <php echo.
So an hour of diddlin about and the tags were sorted in the installer.
RavenNuke installed (most recent on homepage). Unfortunately the DOM also was not working.

I really am unfortunately feeling that this may not work as intended for me and therefore humbly ask for some more assistance in the matter.

Kind regards

Stravides
 
View user's profile Send private message
stravides







PostPosted: Fri Sep 01, 2006 3:18 pm Reply with quote

sorry - bump
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Sep 02, 2006 10:19 am Reply with quote

Sorry, never have used this particular version of the block/module. You might want to check over at [ Only registered users can see links on this board! Get registered or login! ] as I believe Guardian2003 has a version there to download that he has working on RavenNuke AND it handle UK.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
stravides







PostPosted: Sat Sep 02, 2006 1:41 pm Reply with quote

montego wrote:
Sorry, never have used this particular version of the block/module. You might want to check over at [ Only registered users can see links on this board! Get registered or login! ] as I believe Guardian2003 has a version there to download that he has working on RavenNuke AND it handle UK.
Yea Seen that - thats the version I have - but their site says forums are not for support Sad bit of a bugger really Wink

Still trying - even got my paypal account suspended - they say using it fraudulently with 2 accounts and they didn't want to release my second account - But thats another story...

Strav (still hoping for a miracle)
 
montego







PostPosted: Sat Sep 02, 2006 2:04 pm Reply with quote

Quote:

Yea Seen that - thats the version I have - but their site says forums are not for support

Oopss. Sorry about that. Didn't know that. Guardian2003 is an admin on this site, so if he sees this... Wink
 
stravides







PostPosted: Sat Sep 02, 2006 2:59 pm Reply with quote

Also for further information, I amended my ipn script to change it to a tester server [ Only registered users can see links on this board! Get registered or login! ]

and it came back with the following error

Your simulated IPN has been sent successfully


Your status report appears below:


IPN Creation Date: PDT
IPN Expiration Date: PDT
Send Count:
Target IPN Script: [ Only registered users can see links on this board! Get registered or login! ]


Quote:

IPN Sent: PDT
HTTP Status: HTTP/1.1 200 OK
IPN Received: Your script did not reply!
Post Back: N/A


Variables Sent:
Variables Expected: 1
Variables Received: 0


String Length Sent:
String Length Expected: 21
String Length Received: 0


Desired Response:
Actual Response: None
Intentional Response: No!


Summary: Your script is not posting back to us!


So might it be something with the IPN script, or do you think it to be a server issue ??

Code:


<?php
/************************************************************************/
/* NukeTreasury - Financial management for PHP-Nuke                      */
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash                       */
/*                       thrash@fragnastika.com                         */
/*                       thrashn8r@hotmail.com                          */
/*                                                                      */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This program is distributed in the hope that it will be useful, but  */
/* WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU     */
/* General Public License for more details.                             */
/*                                                                      */
/* You should have received a copy of the GNU General Public License    */
/* along with this program; if not, write to the Free Software          */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  */
/* USA                                                                  */
/************************************************************************/

/* NOTE: This file is accessed by PayPal directly, and not through PHP-Nuke */

include("../config.inc.php");
$ERR = 0;
$log = "";
$loglvl = $tr_config[ipn_dbg_lvl];
define(_ERR, 1);
define(_INF, 2);

if( isset($_GET[dbg]) )
   $dbg = 1;
else
   $dbg = 0;

if( $dbg )
{
   dprt("Debug mode activated", _INF);
   echo "<br>PHP-Nuke Treasury mod<br><br>PayPal Instant Payment Notification script<br><br>See below for status:<br>";
   echo "----------------------------------------------------------------<br>";
   $receiver_email = $tr_config['receiver_email'];
}

$ipnppd = mysql_pconnect($hostname_ipnppd, $username_ipnppd, $password_ipnppd) or die(mysql_error());

if( $ipnppd )
   dprt("Connection to db - OK!", _INF);
else
   dprt("Connection to db - **FAILED**", _ERR);

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value)
{
   $value = urlencode(stripslashes($value));
   $req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// 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'];
$txn_type = $_POST['txn_type'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

dprt("Opening connection and validating request with PayPal...", _INF);

$fp = fsockopen ('www.eliteweaver.co.uk/cgi-bin/webscr', 80, $errno, $errstr, 30);

if (!$fp) {
   // HTTP ERROR
   dprt("FAILED to connect to PayPAl", _ERR);
   die();
}

dprt("OK!", _INF);

fputs ($fp, $header . $req);

// Perform PayPal email account verification
if( !$dbg && strcasecmp( $_POST['business'], $tr_config['receiver_email']) != 0)
{
   dprt("Incorrect receiver email: $receiver_email , aborting", _ERR) ;
   $ERR = 1;
}

$insertSQL = "";
// Look for duplicate txn_id's
if( $txn_id )
{
   $sql = "SELECT * FROM transactions WHERE txn_id = '$txn_id'";
   $Recordset1 = mysql_query($sql, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   $NumDups = mysql_num_rows($Recordset1);
}

while (!$dbg && !$ERR && !feof($fp))
{
   $res = fgets ($fp, 1024);
   if (strcmp ($res, "VERIFIED") == 0)
   {
      dprt("PayPal Verified", _INF);
      // Ok, PayPal has told us we have a valid IPN here

      // Check for a reversal for a refund
      if( strcmp($payment_status, "Refunded") == 0)
      {
         // Verify the reversal
         dprt("Transaction is a Refund", _INF);
         if( ($NumDups == 0) || strcmp($row_Recordset1[payment_status], "Completed") ||
            (strcmp($row_Recordset1[txn_type], "web_accept") != 0 && strcmp($row_Recordset1[txn_type], "send_money") != 0) )
         {
            // This is an error.  A reversal implies a pre-existing completed transaction
            dprt("IPN Error: Received refund but missing prior completed transaction", _ERR);
            foreach( $_POST as $key => $val )
            {
               dprt("$key => $val", $_ERR);
            }
            break;
         }
         if( $NumDups != 1 )
         {
            dprt("IPN Error: Received refund but multiple prior txn_id's encountered, aborting", _ERR);
            foreach( $_POST as $key => $val )
            {
               dprt("$key => $val", $_ERR);
            }
            break;
         }
         
         // We flip the sign of these amount so refunds can be handled correctly
         $mc_gross = -$_POST['mc_gross'];
         $mc_fee = -$_POST['mc_fee'];
         $insertSQL = sprintf("INSERT INTO transactions (`txn_id`,`business`,`item_name`, `item_number`, `quantity`, `invoice`, `custom`, `memo`, `tax`, `option_name1`, `option_selection1`, `option_name2`, `option_selection2`, `payment_status`, `payment_date`, `txn_type`, `mc_gross`, `mc_fee`, `mc_currency`, `settle_amount`, `exchange_rate`, `first_name`, `last_name`, `address_street`, `address_city`, `address_state`, `address_zip`, `address_country`, `address_status`, `payer_email`, `payer_status`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
            $_POST['txn_id'],$_POST['business'],$_POST['item_name'],$_POST['item_number'],$_POST['quantity'],$_POST['invoice'],$_POST['custom'],$_POST['memo'],$_POST['tax'],$_POST['option_name1'],$_POST['option_selection1'],$_POST['option_name2'],$_POST['option_selection2'],$_POST['payment_status'],strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])),$_POST['txn_type'],$mc_gross,$mc_fee,$_POST['mc_currency'],$_POST['settle_amount'],$_POST['exchange_rate'],$_POST['first_name'],$_POST['last_name'],$_POST['address_street'],$_POST['address_city'],$_POST['address_state'],$_POST['address_zip'],$_POST['address_country'],$_POST['address_status'],$_POST['payer_email'],$_POST['payer_status']);

         // We're cleared to add this record
         dprt($insertSQL, _INF);
         $Result1 = mysql_query($insertSQL, $ipnppd) or die(mysql_error());
         dprt("SQL result = " . $Result1, _INF);
   
         break;
      } else // Look for anormal payment
      if( (strcmp($payment_status, "Completed") == 0) && ((strcmp($txn_type, "web_accept")== 0) || (strcmp($txn_type, "send_money")== 0)) )
      {
         dprt("Normal transaction", _INF);
         if( $lp ) fputs($lp, $payer_email . " " . $payment_status . " " . $_POST['payment_date'] . "\n");

         // Check for a duplicate txn_id
         if( $NumDups != 0 )
         {
            dprt("Valid IPN, but DUPLICATE txn_id! aborting", _ERR);
            foreach( $_POST as $key => $val )
            {
               dprt("$key => $val", $_ERR);
            }
            break;
         }
         
         $insertSQL = sprintf("INSERT INTO transactions (`txn_id`,`business`,`item_name`, `item_number`, `quantity`, `invoice`, `custom`, `memo`, `tax`, `option_name1`, `option_selection1`, `option_name2`, `option_selection2`, `payment_status`, `payment_date`, `txn_type`, `mc_gross`, `mc_fee`, `mc_currency`, `settle_amount`, `exchange_rate`, `first_name`, `last_name`, `address_street`, `address_city`, `address_state`, `address_zip`, `address_country`, `address_status`, `payer_email`, `payer_status`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
            $_POST['txn_id'],$_POST['business'],$_POST['item_name'],$_POST['item_number'],$_POST['quantity'],$_POST['invoice'],$_POST['custom'],$_POST['memo'],$_POST['tax'],$_POST['option_name1'],$_POST['option_selection1'],$_POST['option_name2'],$_POST['option_selection2'],$_POST['payment_status'],strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])),$_POST['txn_type'],$_POST['mc_gross'],$_POST['mc_fee'],$_POST['mc_currency'],$_POST['settle_amount'],$_POST['exchange_rate'],$_POST['first_name'],$_POST['last_name'],$_POST['address_street'],$_POST['address_city'],$_POST['address_state'],$_POST['address_zip'],$_POST['address_country'],$_POST['address_status'],$_POST['payer_email'],$_POST['payer_status']);

         // We're cleared to add this record
         dprt($insertSQL, _INF);
         $Result1 = mysql_query($insertSQL, $ipnppd) or die(mysql_error());
         dprt("SQL result = " . $Result1, _INF);

         break;
      } else // We're not interested in this transaction, so we're done
      {
         dprt("Valid IPN, but not interested in this transaction", _ERR);
         foreach( $_POST as $key => $val )
         {
            dprt("$key => $val", $_ERR);
         }
         break;
      }
   }
   else if (strcmp ($res, "INVALID") == 0)
   {
      // log for manual investigation
      dprt("Invalid IPN transaction, this is an abnormal condition", _ERR);
      foreach( $_POST as $key => $val )
      {
         dprt("$key => $val", $_ERR);
      }
      break;
   }
}

if( $dbg )
{
   $sql = "SELECT * FROM transactions LIMIT 10";
   echo "Selecting database...";
   $res = mysql_select_db($database_ipnppd, $ipnppd);
   if($res)
      echo "OK!<br>";
    else
      echo "<b>FAILED - err: $res</b><br>";
   echo "Executing test query...";
   $Result1 = mysql_query($sql, $ipnppd) or die(mysql_error());
   if($Result1)
      echo "PASSED!<br>";
   else
      echo "<b>FAILED</b><br>";
   echo "PayPal Receiver Email: $tr_config[receiver_email]" ;
}

if( $log )
{
   dprt("Logging events<br>\n", _INF);
   // Insert the log entry
   $sql = "INSERT INTO translog VALUES ('','" . strftime('%Y-%m-%d %H:%M:%S',mktime()) . "', '"
       . strftime('%Y-%m-%d %H:%M:%S',strtotime($_POST['payment_date'])) . "','" . addslashes($log) . "')";
   $Result1 = mysql_query($sql, $ipnppd) or die(mysql_error());

   // Clear out old log entries
   $sql = "SELECT id as lowid FROM translog ORDER BY id DESC LIMIT " . $tr_config[ipn_log_entries];
   $Result1 = mysql_query($sql, $ipnppd) or die(mysql_error());
   while($recordSet = mysql_fetch_assoc($Result1))
   {
      $lowid = $recordSet[lowid];
   }
   $sql =  "DELETE FROM translog WHERE id < '" . $lowid . "'";
   $Result1 = mysql_query($sql, $ipnppd) or die(mysql_error());
}

fclose ($fp);
if( $lp ) fputs($lp,"Exiting\n");
if( $lp ) fclose ($lp);

if( $dbg)
{
   echo "<br>----------------------------------------------------------------<br>";
   echo "If you don't see any error messages, you should be good to go!<br>";
}
   
function dprt($str, $clvl)
{
   global $dbg, $ipnppd, $lp, $log, $loglvl;

   if( $lp ) fputs($lp, $str . "\n");
   if( $dbg ) echo $str . "<br>";
   if( $clvl <= $loglvl )
      $log .= $str . "\n";
}


?>

Sorry for the long post...

Kind regards
Stravides
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©