Jump to content

PayPal - IPN


shab

Recommended Posts

Hi guys,

I am having problems with receiving post data from paypal. I have enabled IPN and the URL for it, and have used the code supplied from the book 'Professional Web API with PHP'. After making successful payments using sandbox, the database table is not being updated, i do send my self an email to confirm notification is being sent to that URL. But I am not getting the POST DATA.

 

I am able to enable the redirect and go back to my website and using some of the $_GET data, but i really need to get that POST DATA. I have set up an IPN script . Is the following socket correct?

 

 

function verifyIPN($data) {

  $postdata = "";

  $response = array();

 

  foreach($data as $i=>$v) {

    $postdata .= $i . "=" . urlencode($v) . "&";

  }

 

  $postdata.="cmd=_notify-validate";

  $fp=@fsockopen("ssl://www.sandbox.paypal.com" ,"443",$errnum,$errstr,30);

 

  if(!$fp) {

      return "$errnum: $errstr";

  }

else {

   

    fputs($fp, "POST /cgi-bin/webscr HTTP/1.1\r\n");

    fputs($fp, "Host: www.sandbox.paypal.com\r\n");

    fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");

    fputs($fp, "Content-length: ".strlen($postdata)."\r\n");

    fputs($fp, "Connection: close\r\n\r\n");

    fputs($fp, $postdata . "\r\n\r\n");

    while(!feof($fp)) { $response[]=@fgets($fp, 1024); } 

    fclose($fp);

   

  }

  $response = implode("\n", $response);

  if(eregi("VERIFIED",$response)) {

    return true;

  }

else{

    return false;

  }

 

}

 

 

 

Can anyone please advise me what to do? Or what im doing wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/69163-paypal-ipn/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.