我正在使用Paypal PHP Rest API。我试图让我的回复显示交易ID和他们使用回声支付的金额,但我无法弄清楚如何做到这一点。到目前为止,这是我的代码。
<?php
require '/start.php';
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
if ($_GET['success'] === "false") {
header("Location: /home");
die('Payment was canceled.');
}
if(!isset($_GET['success'], $_GET['paymentId'], $_GET['PayerID'])){
header("Location: /home");
die('You are missing fields!');
}
$paymentID = $_GET['paymentId'];
$payerId = $_GET['PayerID'];
$payment = Payment::get($paymentID, $apiContext);
$execute = new PaymentExecution();
$execute->setPayerId($payerId);
try{
$result = $payment->execute($execute, $apiContext);
}catch(Exception $e){
header("Location: /home");
die('The authorization code has expired.');
}
echo "<!DOCTYPE html>\n";
echo "<head>\n";
echo " <title>PureGaming\n";
echo " </title>\n";
echo " <meta charset=\"utf-8\">\n";
echo " <meta name=\"author\" content=\"PureGaming\">\n";
echo " <meta name=\"description\" content=\"PureGaming is a Arma 2/3 Life community project\">\n";
echo " <link rel=\"shortcut icon\" href=\"/favicon.ico\">\n";
echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"/css/googletext.css\">\n";
echo " <link rel=\"stylesheet\" href=\"/css/global.css\">\n";
echo " <link rel=\"stylesheet\" href=\"/css/donate/donate.css\">\n";
echo " <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js\">\n";
echo " </script>\n";
echo "</head>\n";
echo "<body>\n";
echo " <div class=\"nav-container\">\n";
echo " <div class=\"nav-header\">\n";
echo " <a class=\"nav-header-title\" href=\"/home\">PureGaming\n";
echo " </a>\n";
echo " <a class=\"btn btn-primary btn-reportbug\" href=\"/bugreport\" target=\"_blank\">Report a bug\n";
echo " </a>\n";
echo " </div>\n";
echo " </div>\n";
echo " <div class=\"page-content\" id=\"page-content\" style=\"opacity: 1;\">\n";
echo " <div class=\"tab-content\" id=\"tabcontent-donate\">\n";
echo " <div class=\"donate-tab\">\n";
echo " <img src=\"/images/pgemblem\" style=\"border-radius: 100%; width: 128px; height: 128px;\">\n";
echo " <h1>Thank you so much!\n";
echo " </h1>\n";
echo " <h2>We can't thank you enough for the donation. Every donation is used for the PureGaming community and \n";
echo " <b>only\n";
echo " </b> the PureGaming community. After you leave this page, its authorization token will expire. We do currently have a limited-refund policy. Only in certain situations that the owners think are applicable, a refund will be issued. Your receipt should have been sent to the email that was used in the payment by Paypal themselves.\n";
echo " </h2>\n";
echo " <a class=\"paypal-link\" id=\"donate-btn\" href=\"/home\">Home\n";
echo " </a>\n";
echo " </div>\n";
echo " </div>\n";
echo " </div>\n";
echo " <div class=\"footer\">\n";
echo " Copyright © 2016 PureGaming\n";
echo " </div>\n";
echo "</body>\n";
?>
有谁知道我会怎么做并让它显示他们支付的金额和订单中的交易ID?代码的回声部分仅在付款后显示。