如何使用交易ID获取交易明细?
我尝试生成访问令牌,然后尝试获取交易详细信息。但是它向我显示了INVALID_RESOURCE_ID
要生成访问令牌:
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"
获取交易详细信息:
$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;
响应:
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 )
我想知道如何在沙盒模式下使用交易ID获取交易详细信息?
答案 0 :(得分:0)
似乎您在请求中提供了无效的资源ID。
我建议使用官方的PayPal PHP SDK。你可以在这里下载: PayPal-PHP-SDK Github,这是获得交易here
的一个很好的例子