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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.