使用 Omnipay 和 Laravel 4 通过 Paypal Express 结账列出多个项目

Kie*_*iee 2 php paypal payment-gateway laravel omnipay

是否可以在 PayPal 的网站“购物车”中列出所有产品。我问是因为 PayPal 说的是“描述”而不是描述,这比将总数加上无用的“你的购物篮”描述更好

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

文档含糊不清,或者我可能忽略了这种可能性,但我已经尝试过:

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

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

其中数据遵循上述布局。

Kie*_*iee 5

在 Github 上找到了这篇文章,它解释了这是如何实现的。

setItems 添加了函数,以便可以像这样传递项目数组:

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

注意事项
如果购买金额不等于项目数组的总和,则请求将失败。