【发布时间】:2014-08-02 18:38:10
【问题描述】:
我试图通过Paypal API 销售多种产品,但我收到了错误的请求错误。
我有一个数组中的项目,如
$products = array(
array('name' => 'Product 1', 'price' => $200) ,
array('name' => 'Product 2', 'price' => $240)
);
$transactions = [];
$total = 0;
foreach($products as $product) {
$transaction = new Transaction();
$transaction->setAmount(array('currency' => 'USD', 'amount' => $product['price']));
$transaction->setDescription($product['name']);
$transactions[] = $transaction;
$total += $product['price'];
}
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($returnUrl);
$redirectUrls->setCancelUrl($cancelUrl);
$amount = new Amount();
$amount->setCurrency($currency);
$amount->setTotal($total);
$payment = new Payment();
$payment->setRedirectUrls($redirectUrls);
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions($transactions);
我怎样才能使上面的代码工作?非常感谢您的意见。
更多详情:
我的方法基于以下example和Paypal Rest API。
【问题讨论】:
标签: php rest paypal paypal-sandbox payment-processing