zymtom

Paypal IPN

Sep 19th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. $request = "cmd=_notify-validate";
  4. foreach ($_POST as $varname => $varvalue){
  5.  $email .= "$varname: $varvalue\n";  
  6.  if(function_exists('get_magic_quotes_gpc') and get_magic_quotes_gpc()){  
  7.   $varvalue = urlencode(stripslashes($varvalue));
  8.  }
  9.  else {
  10.   $value = urlencode($value);
  11.  }
  12.  $request .= "&$varname=$varvalue";
  13. }
  14. $ch = curl_init();
  15. curl_setopt($ch,CURLOPT_URL,"https://www.paypal.com/cgi-bin/webscr");
  16. curl_setopt($ch,CURLOPT_POST,true);
  17. curl_setopt($ch,CURLOPT_POSTFIELDS,$request);
  18. curl_setopt($ch,CURLOPT_FOLLOWLOCATION,false);
  19. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  20. $result = curl_exec($ch);
  21. curl_close($ch);
  22. switch($result){
  23.  case "VERIFIED": //Payment went through all right,
  24.    
  25.   break;
  26.  case "INVALID": // Invalid or fake payment.
  27.  
  28.   break;
  29.  default:
  30.   // any other case (such as no response, connection timeout...)
  31. }
  32.  
  33. ?>
Add Comment
Please, Sign In to add comment