以下是我的返回页面的代码。它运行良好并成功完成。我假设,由于页面成功,因此$ requestParams中的变量在页面上可用。在$ requestParams
中显示变量值的正确语法是什么<?php
require_once '../library/DPayPal.php'; //Import library
$token=$_GET["token"];//Returned by paypal, you can save this in SESSION too
$paypal = new DPaypal();
$requestParams = array('TOKEN' => $token);
$response = $paypal->GetExpressCheckoutDetails($requestParams);
$payerId=$response["PAYERID"];//Payer id returned by paypal
//Create request for DoExpressCheckoutPayment
$requestParams=array(
"TOKEN"=>$token,
"PAYERID"=>$payerId,
"PAYMENTREQUEST_0_AMT"=>"20",//Payment amount. This value should be sum of of item values, if there are more items in order
"PAYMENTREQUEST_0_CURRENCYCODE"=>"USD",//Payment currency
"PAYMENTREQUEST_0_ITEMAMT"=>"20"//Item amount
);
$transactionResponse=$paypal->DoExpressCheckoutPayment($requestParams);//Execute transaction
if(is_array($transactionResponse) && $transactionResponse["ACK"]=="Success"){//Payment was successfull
echo "Successfull";
// Displays Successfull, but NONE of the following commands display any results
print_r($transactionResponse["PAYMENTREQUEST_0_CURRENCYCODE"]);
echo $transactionResponse["PAYMENTREQUEST_0_CURRENCYCODE"];
print_r($transactionResponse);
echo $transactionResponse;
}
else{
echo "Failed";
}
?>
答案 0 :(得分:0)
如果您只是需要查看转出的数据供您自己参考,您可以使用$ transactionResponse执行相同的操作。如果您想显示用户的值,可以看到您可以这样做。
foreach($requestParams as $var => $val)
{
echo $var . ': ' . $val . '<br />';
}