Eliya Cohen
Eliya Cohen

Reputation: 11508

Paypal Checkout Express doesn't show the order details

I'm using the lib PayPal-PHP-SDK on Laravel 4

and I have a problem with showing the order details. I followed the steps from Paypal Web Checkout and it doesn't showing me the order details.

it says "You'll be able to see your order details before you pay." Image Link - Image Link

This is the method when I get the link to the payment:

public function checkout()
{
    $apiContext = new ApiContext($this->cred, 'Request' . time());
    $apiContext->setConfig($this->sdkConfig);

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

    $amount = new Amount();
    $amount->setCurrency("EUR");
    $amount->setTotal("10");

    $transaction = new Transaction();
    $transaction->setDescription("Example");
    $transaction->setCustom('abv');
    $transaction->setAmount($amount);

    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl(URL::to('/') . '/payment/success/');
    $redirectUrls->setCancelUrl(URL::to('/') . '/payment/cancel/');


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

    $payment->create($apiContext);

    print $payment->getApprovalLink();

}

Paypal Transaction

Upvotes: 0

Views: 1240

Answers (2)

Jay Patel - PayPal
Jay Patel - PayPal

Reputation: 1489

As Andrew mentioned, you are missing itemized details in your request. This is how you could do it. http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html

As you can see the create payment has an array of transactions that has an item_list attribute, that needs to be set. You can see how to do so, using our SDK in above link.

We attach a lot of samples in our SDK now, that could be ran in your local machine with just one command. Please follow the instructions here

The command you need to run is:

php -f <paypal SDK Directory>/paypal/rest-api-sdk-php/sample/index.php

This will host a local server at localhost:5000, that would allow you to run the samples located in samples directory.

PayPal-PHP-SDK is getting developed strongly, and we are adding more and more features to it. Please visit our SDK page to view all the supporting documentations, API specs, Samples, etc.

Upvotes: 1

Drew Angell
Drew Angell

Reputation: 26056

I don't see any itemized details in your request. It would help to see a sample of the raw request getting sent to PayPal, but from what I can see those parameters are simply not getting included.

On a side note, you may be interested in checking out my PHP class library for PayPal. It's available on GitHub and Packagist and works with Composer, so it works very nicely with Laravel, and it's a lot easier to use than PayPal's SDK. It sets up all the parameters you might want to use, including itemized details, so all you have to do is fill in the parameters and you're done.

Upvotes: 3

Related Questions