Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. //ButtonManager API
  2. $ret = ch_post();
  3. error_log($ret);
  4. echo urldecode($ret);
  5. function ch_post(){
  6. //API Credentials
  7. $accID = urlencode("accID");
  8. $username = urlencode("username_api1.website");
  9. $password = urlencode("password");
  10. $signature = urlencode("signature");
  11. $appID = urlencode("APP-ID");
  12.  
  13. $endpoint = "https://api-3t.sandbox.paypal.com/nvp";
  14. $certpath = "C:certpath.pem";
  15.  
  16. $ch_headers = array(
  17. "USER"=>$username,
  18. "PWD"=>$password,
  19. "SIGNATURE"=>$signature,
  20. "APPID"=>$appID,
  21. "VERSION"=>"51.0"
  22. );
  23.  
  24. $ch_params = array(
  25. "METHOD"=>urlencode("BMCreateButton"),
  26. "OTHERPARAMS"=>urlencode("OTHER")
  27. );
  28.  
  29. $ch = curl_init($endpoint);
  30. curl_setopt($ch,CURLOPT_HTTPHEADER,http_build_query($ch_headers));
  31. curl_setopt($ch,CURLOPT_CAINFO,$certpath);
  32. curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($ch_params));
  33. curl_setopt($ch,CURLOPT_POST,TRUE);
  34. curl_setopt($ch,CURLOPT_HEADER,TRUE);
  35. curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
  36. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  37. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  38. curl_setopt($ch,CURLOPT_SSLVERSION, 6);
  39. $cexec = curl_exec($ch);
  40. if(!$cexec) {
  41. $response = "Failed: ".curl_error($ch)."(".curl_errno($ch).")";
  42. curl_close($ch);
  43. return $response;
  44. }
  45. curl_close($ch);
  46. return $cexec;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement