Member Avatar

Hi everyone. I watched Alex's PayPal IPN series and I was testing it on the PayPal IPN Sandbox and it won't work. Here is my code.


<br />To verify your account click the button below.<br /><br />
                                        <form action="" method="post">
                                            <input type="hidden" name="cmd" value="_xclick">
                                            <input type="hidden" name="business" value="">
                                            <input type="hidden" name="item_name" value="Verification">
                                            <input type="hidden" name="item_number" value="1">
                                            <input type="hidden" name="amount" value="1.25"> 
                                            <input type="hidden" name="no_shipping" value="1">
                                            <input type="hidden" name="no_note" value="1">
                                            <input type="hidden" name="currency_code" value="GBP">
                                            <input type="hidden" name="lc" value="GB">
                                            <input type="hidden" name="bn" value="PP-BuyNowBF">
                                            <input type="hidden" name="return" value="">
                                            <input type="hidden" name="cancel_return" value="">
                                            <input type="hidden" name="rm" value="2">
                                            <input type="hidden" name="notify_url" value="" />
                                            <input type="hidden" name="custom" value="<?php echo $_SESSION["uid"]; ?>">
                                            <input type="submit" value="Verify Your Account" class="input-submit" style="width: 180px;" />


include "";
// 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://", 443, $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_amount = $_POST["mc_gross"];
$payment_currency = $_POST["mc_currency"];
$txn_id = $_POST["txn_id"];
$receiver_email = $_POST["receiver_email"];
$payer_email = $_POST["payer_email"];

if (!$fp) {
} else {
  fputs ($fp, $header . $req);
  while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, "VERIFIED") == 0)
			$txn_check = mysql_query("SELECT `txn_id` FROM `upgrade_logs` WHERE `txn_id`='" . $txn_id . "'");
						//insert `upgrade_logs`
						$insert_upgradelogs = mysql_query("INSERT INTO `upgrade_logs` VALUES('', '" . $txn_id . "', '" . $prokey->encrypt($payer_email) . "')");
						//update candownload to 1
						$update_candownlaad = mysql_query("UPDATE `users` SET `candownload`='1' WHERE paypal_email='" . $prokey->encrypt($payer_email) . "'");
    else if (strcmp ($res, "INVALID") == 0) {
         // log for manual investigation
  fclose ($fp);

I have set up my PayPal account to allow IPN's and I have set the URL to I can't see what the problem is. I have tested it with a member of my family's PayPal account and it won't work.

Thanks in advance.

Recommended Answers

All 3 Replies

Member Avatar


Member Avatar the Night...

Member Avatar

Downvote? Where's your sense of humour? I didn't BUMP it!

Damn, I did now, with this post. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.