Czolem.

problemmam taki. Za kazdym razem gdy place (sandboxowe konta) , strona paypala wyswietla ze platnosc zostala dokonana i przekierowuje mnie do mojego example.php ktory jednoczesnie jest IPNem. Mimo uz w paypalu wsio gra skrypt ipn mowi mi ze transakcja jest nie VERIFIED tongue.gif

oto class z kroter kozystam

  1. <?php
  2.  
  3. // Original Author: Pineapple Technologies 
  4. // License: Free (GPL)
  5. //
  6. // Modified By: ScriptDevelopers.NET (http://www.scriptdevelopers.net)
  7. // Modified Date: September 14, 2003
  8. // 
  9. // Modified to use cURL as PayPal now does a redirect no matter
  10. // whether you use http or https, or get or post. Using cURL, you
  11. // can have php properly follow the redirect and have the expected
  12. // VERIFIED or INVALID responses.
  13. //
  14.  
  15. class paypal_ipn
  16. {
  17. var $paypal_post_vars;
  18. var $paypal_response;
  19. var $protocol;
  20. var $url_string;
  21.  
  22. var $timeout;
  23.  
  24. // error logging info
  25. var $error_log_file;
  26. var $error_email;
  27.  
  28. function paypal_ipn($paypal_post_vars, $protocol = "s")
  29. {
  30. $this->paypal_post_vars = $paypal_post_vars;
  31. $this->protocol = $protocol;
  32.  
  33. $this->timeout = 120;
  34. $this->url_string = "http" . $this->protocol . "://www.paypal.com/cgi-bin/webscr?";
  35. }
  36.  
  37. // sends response back to paypal
  38. function send_response()
  39. {
  40. // put all POST variables received from Paypal back into a URL encoded string
  41. foreach($this->paypal_post_vars AS $key => $value)
  42. {
  43. // if magic quotes gpc is on, php added slashes to the values so we need
  44. // to strip them before we send the data back to Paypal.
  45. {
  46. $value = stripslashes($value);
  47. }
  48.  
  49. // make an array of URL encoded values
  50. $values[] = "$key" . "=" . urlencode($value);
  51. }
  52.  
  53. // join the values together into one url encoded string
  54. $this->url_string .= @implode("&", $values);
  55.  
  56. // add paypal cmd variable
  57. $this->url_string .= "&cmd=_notify-validate";
  58.  
  59. $ch = curl_init();
  60. curl_setopt ($ch, CURLOPT_URL, $this->url_string);
  61.  curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; www.ScriptDevelopers.NET; PayPal IPN Class)");
  62. curl_setopt ($ch, CURLOPT_HEADER, 1);
  63. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  64. curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
  65. curl_setopt ($ch, CURLOPT_TIMEOUT, $this->timeout);
  66. $this->paypal_response = curl_exec ($ch);
  67. curl_close($ch);
  68.  
  69. } // end function send_response()
  70.  
  71. // returns true if paypal says the order is good, false if not
  72. function is_verified()
  73. {
  74. if( ereg("VERIFIED", $this->paypal_response) )
  75. {
  76. return true;
  77. }
  78. else
  79. {
  80. return false;
  81. }
  82.  
  83. } // end function is_verified
  84.  
  85. // returns the paypal payment status
  86. function get_payment_status()
  87. {
  88. return $this->paypal_post_vars['payment_status'];
  89. }
  90.  
  91. // writes error to logfile, exits script
  92. function error_out($message)
  93. {
  94.  
  95. $date = date("D M j G:i:s T Y", time());
  96.  
  97. // add on the data we sent:
  98. $message .= "nnThe following input was received from (and sent back to) PayPal:nn";
  99.  
  100. @reset($this->paypal_post_vars);
  101. while( @list($key,$value) = @each($this->paypal_post_vars) )
  102. {
  103. $message .= $key . ':' . " t$valuen";
  104. }
  105.  
  106. $message .= "nn" . $this->url_string . "nn" . $this->paypal_response;
  107.  
  108. // log to file?
  109. if( $this->error_log_file )
  110. {
  111. @fopen($this->error_log_file, 'a');
  112. $message = "$datenn" . $message . "nn";
  113. @fputs($fp, $message);
  114. @fclose($fp);
  115. }
  116.  
  117. // email errors?
  118. if( $this->error_email )
  119. {
  120. $additional_headers = "From: "$fromname" <$from>nReply-To: $from";
  121. mail($this->error_email, "[$date] paypay_ipn error", $message, $additional_headers);
  122. }
  123.  
  124.  
  125. } // end function error_out
  126.  
  127. } // end class paypal_ipn
  128.  
  129. ?>

A tutaj moj skrypt ipn korzystajacy z classy ^

example.php

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // example.php
  4. // php paypal_ipn class example
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7. require("paypal_ipn.php");
  8.  
  9. // PayPal will send the information through a POST
  10. $paypal_info = $HTTP_POST_VARS;
  11.  
  12. // To disable https posting to PayPal uncomment the following
  13. // $paypal_ipn = new paypal_ipn($paypal_info, "");
  14.  
  15. // Then comment out this one
  16. $paypal_ipn = new paypal_ipn($paypal_info);
  17.  
  18. // where to contact us if something goes wrong
  19. $paypal_ipn->error_email = "thornag@hychsohn.org";
  20.  
  21. // We send an identical response back to PayPal for verification
  22. $paypal_ipn->send_response();
  23.  
  24. // PayPal will tell us whether or not this order is valid.
  25. // This will prevent people from simply running your order script
  26. // manually
  27. if( !$paypal_ipn->is_verified() )
  28. {
  29. // bad order, someone must have tried to run this script manually
  30. echo "INV";
  31. }
  32.  
  33. // payment status
  34. switch( $paypal_ipn->get_payment_status() )
  35. {
  36. case 'Completed':
  37. echo "status: com";
  38. break;
  39.  
  40. case 'Pending':
  41. echo "status: pen";
  42. break;
  43.  
  44. case 'Failed':
  45. echo "status: fasil";
  46. break;
  47.  
  48. case 'Denied':
  49. echo "status: den";
  50. break;
  51.  
  52. default:
  53. // order is no good
  54. echo "status: unk";
  55. break;
  56.  
  57. } // end switch
  58.  
  59.  
  60. ?>



Czy ktos kiedykolwiek bawil sie paypalem ? Mial podobne problemy ?