Jump to content


Photo

IPN with php


  • This topic is locked This topic is locked
1 reply to this topic

#1 amathur347

amathur347

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 24 November 2002 - 09:48 PM

HELP!
I am stuck trying to get the IPN thing working. I directed the notification_url to a php page on my website. I have copied the php code in the sample provided on the paypal site. Added the bit to update my mysql database. When I am testing , i do not see anything happening. No errors, no database getting updated.. nothing! Where and how do i start the troubleshooting ?? I have see n posts where people talk about error messages... where do they get them ???

Pl help
. My code is as below.
<?php
include "common_db.inc.php";
include "saec_functions.inc.php";
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($HTTP_POST_VARS 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";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);

// assign posted variables to local variables
// note: additional IPN variables also available -- see IPN documentation
$item_name = $HTTP_POST_VARS['item_name'];
$item_number = $HTTP_POST_VARS['item_number'];
$custom = $HTTP_POST_VARS['custom'];
$payment_status = $HTTP_POST_VARS['payment_status'];
$payment_gross = $HTTP_POST_VARS['payment_gross'];
$txn_id = $HTTP_POST_VARS['txn_id'];
$payer_email = $HTTP_POST_VARS['payment_date'];

if (!$fp) {
// ERROR
echo "$errstr ($errno)";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {


$sql = "INSERT INTO Payment set PaypalID=$txn_id, set SAECID=$custom, ItemNo=$item_number";
$sql .= ",set ItemName = $item_name, set Amount=$payment_gross,set PmtDate=$payment_date,";
$sql .= "PmtStatus=$payment_status";
$db=connect_to_database();
$i=mysql_query($sql);
if (!$i) echo mysql_error();
}
else if (strcmp ($res, "INVALID") == 0) {
$sql = "INSERT INTO Payment set PaypalID=$txn_id, set SAECID=$custom, ItemNo=$item_number";
$sql .= ",set ItemName = $item_name, set Amount=$payment_gross,set PmtDate=$payment_date,";
$sql .= "PmtStatus=$payment_status";
$db=connect_to_database();
$i=mysql_query($sql);
if (!$i) echo mysql_error();
}
}
fclose ($fp);
}
?>

#2 amathur347

amathur347

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 24 November 2002 - 10:01 PM

I checked the error log and the access log. There is nothing on the error log, and on the access log i see
65.206.229.140 - - [24/Nov/2002:23:20:03 -0500] "POST /Membership/testpaypal.php HTTP/1.0" 200 135 "-" "-"

so my script is being accessed. But it does not seem to do anything




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users