gpt4 book ai didi

php - Paypal REST API 不会在 Paypal 沙盒或实时网站上显示付款金额

转载 作者:太空宇宙 更新时间:2023-11-03 15:52:04 25 4
gpt4 key购买 nike

Rest api 工作正常,但它没有按夏季顺序显示金额“In Order summery amount is not showed but description is showing?” “我使用下面的代码来传递数量和描述”

require DIR . '/../bootstrap.php';
use PayPal\Api\Address;
use PayPal\Api\Amount;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;


$charge = trim($_POST['amount']);
$currency = trim($_POST['currency']);
$desc = trim($_POST['desc']);
$get_url=trim($_SESSION['get_url']);


$payer = new Payer();
$payer->setPayment_method("paypal");

$amount = new Amount();
$amount->setCurrency($currency);
$amount->setTotal($charge);

$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription($desc);





}

"In order summery its showing description but amount is not showing."
Please help me to sort out this problem"
Thank for you help.

Sunil

最佳答案

创建 ItemList 并将其添加到您的交易中,其中至少包含一项。这是一个例子:

$payer = new Payer();                          
$payer->setPaymentMethod("paypal");

$amount = new Amount();
$amount->setCurrency($paymentCurrency);
$amount->setTotal($paymentAmount);

$item = new Item();
$item->setQuantity(1);
$item->setName($paymentDescription);
$item->setPrice($paymentAmount);
$item->setCurrency($paymentCurrency);

$itemList = new ItemList();
$itemList->setItems(array($item));

$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList);

$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($returnUrl);
$redirectUrls->setCancelUrl($cancelUrl);

$payment = new Payment();

$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));

关于php - Paypal REST API 不会在 Paypal 沙盒或实时网站上显示付款金额,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23359832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com