0
PayPal APIとRESTのリクエスト/レスポンスでは非常に新しいです。そのため、PayPalのREST APIを使用して支払いを処理する方法については、オンラインサンプル(主にGitHubのもの)に従っています。Paypal 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;
?>