0
沒有支付價值我是很新的貝寶API和REST請求/響應。因此,我一直在嘗試關注如何使用PayPal的REST Api處理付款的在線示例(大部分來自GitHub)。寶PHP REST API - 顯示在結帳
不過,我遇到了一個問題。當我點擊生成的鏈接時,我已成功重定向到PayPal的網站。但是,在結帳頁面上,沒有任何內容表示購買金額。這個問題可能是什麼?謝謝!
<?php
require __DIR__ . '/bootstrap.php';
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal('5.55');
$transaction = new Transaction();
$transaction->setAmount($amount)->setDescription("Purchase from Leisurely Diversion")->setInvoiceNumber(uniqid());
$redirectURLs = new RedirectUrls();
$redirectURLs->setReturnUrl("http://localhost/leisurelydiversion/confirmation.php")->setCancelUrl("http://localhost/leisurelydiversion/confirmation.php");
$payment = new Payment();
$payment->setIntent("sale")->setPayer($payer)->setTransactions(array($transaction))->setRedirectUrls($redirectURLs);
try {
$payment->create($apiContext);
} catch(Exception $e) {
echo "<h2> Error Sending Payment! $e</h2>";
}
$url = $payment->getApprovalLink();
echo $url;
?>