Advertisement
Guest User

Untitled

a guest
Dec 6th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 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.sandbox.paypal.com/cgi-bin/webscr");
  16. //curl_setopt($ch,CURLOPT_URL,"https://www.paypal.com");
  17. curl_setopt($ch,CURLOPT_POST,true);
  18. curl_setopt($ch,CURLOPT_POSTFIELDS,$request);
  19. curl_setopt($ch,CURLOPT_FOLLOWLOCATION,false);
  20. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  21. $result = curl_exec($ch);
  22. curl_close($ch);
  23. switch($result){
  24.     case "VERIFIED":
  25.         // verified payment
  26.         break;
  27.     case "INVALID":
  28.         // invalid/fake payment
  29.         break;
  30.     default:
  31.         // any other case (such as no response, connection timeout...)
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement