phplaravelpaypalpayment-gatewayomnipay

List multiple items through Paypal Express checkout using Omnipay & Laravel 4


Is it possible to list all products in a sites "cart" on PayPal. I ask because PayPal says "descriptions" instead of description and it would be nicer than having a combined total with a unhelpful description of "your basket"

$request = $gateway->purchase([
            'amount' => '150.00',
            'currency' => 'GBP',
            'description' => 'Your basket',
            'returnUrl' => 'http://localhost:8080/checkout/success',
            'cancelUrl' => 'http://localhost:8080/checkout/cancel'
        ])->send();

The documentation is vague or I may have overlooked the possibility but I've tried:

 $request = $gateway->purchase([
                'amount' => array('100','200'),
                'currency' => 'GBP',
                'description' => array('prod1','prod2'),
                'returnUrl' => 'http://localhost:8080/checkout/success',
                'cancelUrl' => 'http://localhost:8080/checkout/cancel'
            ])->send();

&
$request = $gateway->purchase([data],[data])->send();

where data follows the above layout.


Solution

  • I found this post on Github which explains how this is achievable.

    setItems function was added so that an array of items can be passed like so:

    $request = $gateway->purchase([
                'amount'=>'70.00',
                'returnUrl' => 'http://localhost:8080/checkout/success',
                'cancelUrl' => 'http://localhost:8080/checkout/cancel'
            ])->setItems(array(
                array('name' => 'item1', 'quantity' => 2, 'price' => '10.00'),
                array('name' => 'item2', 'quantity' => 1, 'price' => '50.00')
            ))->send();
    

    Something to note
    The request will fail if the purchase amount does not equal the sum of the array of items.