|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/19/2003 Posts: 6 Location: ,
|
I completely take the sample PHP script shown below. Why $res is always INVALID when I test it? Thanks.
// 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";
//echo $key." : ". $value."<br>\n"
}
// 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
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_gross = $_POST['payment_gross'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp)
{
// HTTP ERROR
header("Location: subscribe.php");
exit;
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// Access the database here.
}
else if (strcmp ($res, "INVALID") == 0)
{
// log for manual investigation
header("Location: subscribe.php");
exit;
}
} // while
fclose ($fp);
}
|
|
|
|
|
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/16/2002 Posts: 2,960 Location: ,
|
Do you have IPN activated? Can you try this: http://www.paypaldev.org/topic.asp?TOPIC_ID=1658
Patrick Breitenbach PayPal, Inc. Dev Net: https://www.paypal.com/pdn
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/19/2003 Posts: 6 Location: ,
|
IPN is activated. I tried http://www.paypaldev.org/topic.asp?TOPIC_ID=1658 and it worked. I got valid $res. But I still get INVALID $res when I test IPN in my site. Please tell me why. Thanks a lot.
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/16/2002 Posts: 2,960 Location: ,
|
How are you determining that it's invalid? It doesn't appear that your script logs anything. Are you counting hits to subscription.php? Can you do any logging? Specifically of $req? Patrick Breitenbach PayPal, Inc. Dev Net: https://www.paypal.com/pdn
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/19/2003 Posts: 6 Location: ,
|
When I try to log $req, I find nothing posted from Paypal. For example, when the following script is implemented, nothing is displayed.
foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value";
echo $key." : ". $value."<br>\n" }
I did log $res as follows:
else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation echo "res is invalid"; }
Then "res is invalid" is always the output when I test. That's why I say $res is always invalid.
Please help me solve this issue. Thanks a lot.
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/16/2002 Posts: 2,960 Location: ,
|
It sounds like IPN isn't active. Are you including "notify_url" in your buy button or did you turn IPN on in your Profile? Patrick Breitenbach PayPal, Inc. Dev Net: https://www.paypal.com/pdn
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/19/2003 Posts: 6 Location: ,
|
Of course, I turned on IPN in my profile. I copied a part of my profile as follows to prove it. PayPal's Instant Payment Notification (IPN) allows you to integrate PayPal payments with your website back-end operations. Instant Payment Notification (IPN) On Instant Payment Notification (IPN) URL: http://www.shinybid.com/paypal_return.php Thanks.
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 9/16/2002 Posts: 2,960 Location: ,
|
You're not going to see anything your PHP script echoes because the IPN is a hidden post directly from our server to your server. Is there some way that you can log the $req or email it to yourself? Patrick Breitenbach PayPal, Inc. Dev Net: https://www.paypal.com/pdn
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 4/30/2003 Posts: 105 Location: ,
|
Hi, Do you know what version of PHP you have on your server. I belive if the PHP version is older than 4.2.x then $_POST is not supported. Try using $HTTP_POST_VARS instead and then see what gets printed. Cheers, Sharad Goel Well Drafted Consultants Inc. http://www.welldrafted.net
|
|
|
|
Rank: Starting Member
Groups: Registered
Joined: 7/19/2003 Posts: 6 Location: ,
|
I try to log $req, which is only 'cmd=_notify-validate'. That means there is nothing posted from Paypal. I once tried http://www.paypaldev.org/topic.asp?TOPIC_ID=1658 you told me before. All values could be displayed. Please help me solve this headache. Thanks a lot.
|
|
|
|
Guest
|
YAFVision Theme by Jaben Cargman (Tiny Gecko)Powered by YAF |
YAF © 2003-2009, Yet Another Forum.NETThis page was generated in 0.220 seconds.