• PHP Automatic Donation with paypal.
    12 replies, posted
I'm trying to get this code to work, but everytime I have it run it returns fail, even though I know they sent the money. [PHP]<?php // 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"; $fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30); // VARIBLES Sent From Paypal $email = $_POST['payer_email']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { echo("Pass"); echo("<br>"); echo($email); } else if (strcmp ($res, "INVALID") == 0) { echo("Fail"); } } fclose ($fp); } ?> [/PHP] Does anyone know why this is returning Fail?
Have you attempted to debug anything in the paypal sandbox?
Paypal sandbox is terribly slow for me and nothing will load.. so no i haven't tried.
How are you seeing what it prints.. because if you're manually navigating to the file ofc its going to print fail..
Its okay, I got it all working.
It's more recommended that you use an already-established API if you know what I mean.
[QUOTE=Brodster55;36094508]Its okay, I got it all working.[/QUOTE] what was the problem? Might help some people in future
i would like to know as well because wanted to have a donation system as well
anyone??
[QUOTE=sciaschi;36111890]i would like to know as well because wanted to have a donation system as well[/QUOTE] My guess is that he should have used "ssl://www.paypal.com" for the fsock instead, or it could just be that he forgot to set the notify url in his buttons.
well the ssl was correct but it still is coming up as fail
I would like to know this as well for my server
Oh gee golly need paypal donationz for my gmod server!
Sorry, you need to Log In to post a reply to this thread.