The problem is within paypalplatform.php
In the hashcall function, $API_Endpoint is declared as global and then $methodname is appended to it. $methodname is the operation that hashcall is instructed to carry out. Because $API_Endpoint is being appended to directly (as it is then global), any subsequent calls to hashcall will use the modified $API_Endpoint.
On the first call to hashcall from CallPaymentDetails $API_Endpoint is: https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails
On the second call to hashcall from CallPay $API_Endpoint is: https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails/Pay
It is this that is causing the unexpected results.
Edit paypalplatform.php to remove the line stated and modify the line stated:
function hash_call($methodName, $nvpStr){
global $API_Endpoint, $API_UserName, $API_Password, $API_Signature, $API_AppID;
global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;
$API_Endpoint .= "/" . $methodName; //REMOVE THIS LINE
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$API_Endpoint); //MODIFY THIS LINE
So that the beginning of hashcall is as follows:
function hash_call($methodName,$nvpStr){
global $API_Endpoint,$API_UserName,$API_Password,$API_Signature,$API_AppID;
global $USE_PROXY,$PROXY_HOST,$PROXY_PORT;
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"$API_Endpoint/$methodName");