Web development of websites and digital services

How to Integrate PayPal Tracking API in PHP

The PayPal Tracking API a robust, simple to use API for adding and updating shipment tracking details to PayPal transactions.

PayPal Tracking API Access Token

Client ID and Secret:

To get the access token we need to make a POST request to  with our PayPal application’s client_id and secret.api.sandbox.paypal.com/v1

If you have created a PayPal app as suggested earlier, you will find the client_id and secret in your application’s detail page.

API credentials (paypal.com)






Fetch Access Token Using Curl and PHP:

We can get an access token from PayPal Tracking API using the Client Id and Secret.
$curl = curl_init();

$url = "https://api.sandbox.paypal.com/v1/oauth2/token";
$clientId = "your client Id";
$secret = "your secret key";

curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_POSTFIELDS => "grant_type=client_credentials",

CURLOPT_USERPWD => $clientId.":".$secret,

CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded"),)
); 

$result = curl_exec($curl);

curl_close($curl);

$response = json_decode($result, true);

echo $response['access_token'];