Reputation: 1174
How to get transaction details using transaction id ?
I tried generate access token and then tried to get transaction details.But its showing me INVALID_RESOURCE_ID
To generate access token :
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "EOJ2S-Z60oN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EC1usMEUk8e9ihI7ZdXLF5cz6y0SFdVsY9183IvxFyZp"
-d "grant_type=client_credentials"
To get transaction details :
$access_token = '<ACCESS_TOKEN>';
$curl = curl_init("https://api.sandbox.paypal.com/v1/checkout/orders/<TXN_ID>");
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' .$access_token,
'Accept: application/json',
'Content-Type: application/json'
));
$response = curl_exec($curl);
$result = json_decode($response);
print_r($result);exit;
Response :
stdClass Object ( [name] => VALIDATION_ERROR [details] => Array ( [0] => stdClass Object ( [field] => #/id [location] => body [issue] => INVALID_RESOURCE_ID ) ) [message] => Invalid request - see details [information_link] => https://developer.paypal.com/docs/api/orders/v1/#error-VALIDATION_ERROR [debug_id] => 447f920460e84 )
I would like to know how can i get transaction details using transaction id in sandbox mode ?
Upvotes: 1
Views: 747
Reputation: 565
It seems that you provide a invalid resource id in your request.
I recommend to use the official PayPal PHP SDK. You can download it here: PayPal-PHP-SDK Github and there is a good example for getting a transaction here
Upvotes: 0