【问题标题】:Paypal PHP REST API - No Payment Value Shown At CheckoutPaypal PHP REST API - 结帐时不显示付款值
【发布时间】:2016-09-17 01:54:28
【问题描述】:

我对 PayPal API 和 REST 请求/响应非常陌生。因此,我一直在尝试关注如何使用 PayPal 的 REST Api 处理付款的在线示例(主要来自 GitHub)。

但是,我遇到了一个问题。当我点击生成的链接时,我被成功重定向到 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;
?>

【问题讨论】:

  • 有同样的问题。金额正在从买家即时转移到商家帐户,但交易/活动也没有显示在买家仪表板上

标签: php rest paypal


【解决方案1】:

您必须在付款中添加一个项目列表:
http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/OrderCreateUsingPayPal.html

您还可以通过将&amp;useraction=commit 附加到批准网址来更改操作:
Does PayPal Rest API have the classic useraction equivalent

【讨论】:

  • 不适合我。金额会立即从买家转移到商家账户,但交易/活动也没有显示在买家的商家仪表板上。
【解决方案2】:

希望这会有所帮助

$item = new Item();
$item->setSku('Product Id');
$item->setName('Product Name');
$item->setPrice('5.55');
$item->setCurrency('USD');
$item->setQuantity(1);

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

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

【讨论】:

    猜你喜欢
    • 2017-10-16
    • 2014-01-05
    • 2016-12-17
    • 1970-01-01
    • 2013-08-25
    • 2017-07-13
    • 2013-03-30
    • 2013-08-29
    • 2013-05-02
    相关资源
    最近更新 更多