I am using https://github.com/paypal/rest-api-sdk-php
And I want to view an overview of the item description, here is the code:
$amountDetails = new Details(); $amountDetails->setSubtotal('7.41'); $amountDetails->setTax('0.03'); $amountDetails->setShipping('0.03'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('7.47'); $amount->setDetails($amountDetails); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment transaction description.'); $RedirectUrls = new RedirectUrls(); $RedirectUrls ->setReturnUrl('http://localhost/mrSurvey/public/#/pricing'); $RedirectUrls ->setCancelUrl('http://localhost/mrSurvey/public/#/pricing'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); $payment->setRedirectUrls($RedirectUrls);
All I see is a description, but I want to see the item number and subtotal, what am I missing?
Update: So I read that I need to add a few things: so I did something like this:
$item = new Item(); $item->setQuantity('1'); $item->setName('benny'); $item->setPrice('7.41'); $item->setCurrency('USD'); $item->setSku('blah'); $items = new ItemList(); $items->addItem(array($item));
...
$transaction->setItemList($items);
...
$payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); $payment->setRedirectUrls($RedirectUrls); $response = $payment->create($apiContext)->toarray(); return Response::json($response);
Now the code above gives me 400 errors ... due to the added material of the element, any hints?
php paypal
totothegreat
source share