Paypal项目描述与其余api sdk

tot*_*eat 8 php paypal

我正在使用https://github.com/paypal/rest-api-sdk-php

我想要显示项目描述评论,这里是代码:

  $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);
Run Code Online (Sandbox Code Playgroud)

所有我能看到的是描述,但我想看项目编号和小计,我缺少什么?

更新:所以我读到我需要添加一些东西:所以我做了这样的事情:

 $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));
Run Code Online (Sandbox Code Playgroud)

...

$transaction->setItemList($items);
Run Code Online (Sandbox Code Playgroud)

...

$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);
Run Code Online (Sandbox Code Playgroud)

现在上面的代码给了我400个错误...因为添加了项目的东西,任何线索?

小智 0

添加这个 ...

$transaction->setDescription("Payment description")
Run Code Online (Sandbox Code Playgroud)

...