Advertisement
Guest User

Untitled

a guest
May 11th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. $req = 'cmd=_notify-synch';
  2.  
  3. $tx_token = $_GET['tx'];
  4.  
  5. // For sandbox testing
  6. //$pp_hostname = "www.sandbox.paypal.com";
  7.  
  8. //live
  9. $pp_hostname = "www.paypal.com";
  10.  
  11. //sandbox token
  12. //$auth_token = "FBO_RlnSKMrFCJlPOvghIonpJx2uiXH_ICIeh8-VMIUWtVjM5vhPJV0LCUW";
  13.  
  14. //real token
  15. $auth_token = "P0d7_HmQSAuXh9r-7hG1Rzf_npI2LaFgYHQJyWUsjQHg7WhZARqs3sq6IW4";
  16. $req .= "&tx=$tx_token&at=$auth_token";
  17.  
  18. $ch = curl_init();
  19. curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
  20. curl_setopt($ch, CURLOPT_POST, 1);
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
  23. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
  24. //set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
  25. //if your server does not bundled with default verisign certificates.
  26. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  27. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
  28. $res = curl_exec($ch);
  29. curl_close($ch);
  30.  
  31. if(!$res){
  32.     //HTTP ERROR
  33. }else{
  34.      // parse the data
  35.     $lines = explode("\n", $res);
  36.     $keyarray = array();
  37.     if (strcmp ($lines[0], "SUCCESS") == 0) {
  38.         for ($i=1; $i<count($lines);$i++){
  39.         list($key,$val) = explode("=", $lines[$i]);
  40.         $keyarray[urldecode($key)] = urldecode($val);
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement