Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1.  
  2. #
  3. # FIRST CURL TO GET TOKEN
  4. #
  5. $ch = curl_init();
  6. curl_setopt($ch, CURLOPT_URL, $PAYPAL_OAUTH_API);
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
  9. curl_setopt($ch, CURLOPT_POST, 1);
  10. curl_setopt($ch, CURLOPT_USERPWD, $PAYPAL_CLIENT . ':' . $PAYPAL_SECRET);
  11. $headers = array();
  12. $headers[] = 'Accept: application/json';
  13. $headers[] = 'Accept-Language: en_US';
  14. $headers[] = 'Content-Type: application/x-www-form-urlencoded';
  15. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  16. $auth = curl_exec($ch);
  17. if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
  18. curl_close ($ch);
  19. $auth = json_decode($auth);
  20.  
  21.  
  22.  
  23. #
  24. # SECOND CURL TO GET ORDER DETAILS
  25. #
  26. $ch = curl_init();
  27. curl_setopt($ch, CURLOPT_URL, $PAYPAL_ORDER_API);
  28. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  29. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  30. $headers = array();
  31. $headers[] = 'Content-Type: application/json';
  32. $headers[] = 'Authorization: Bearer ' . $token;
  33. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  34. $details = curl_exec($ch);
  35. if (curl_errno($ch)) {
  36.     echo 'Error:' . curl_errno($ch);
  37. }
  38. curl_close ($ch);
  39. $details = json_decode($details);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement