Php 使用Omnipay&;通过Paypal Express结账列出多个项目;拉维尔4号

Php 使用Omnipay&;通过Paypal Express结账列出多个项目;拉维尔4号,php,laravel,paypal,payment-gateway,omnipay,Php,Laravel,Paypal,Payment Gateway,Omnipay,是否可以在PayPal上列出网站“购物车”中的所有产品。我这样问是因为PayPal说的是“描述”而不是“描述”,这比将总数与“你的篮子”的无效描述结合起来要好 文档内容含糊不清,或者我可能忽略了这种可能性,但我尝试过: $request = $gateway->purchase([ 'amount' => array('100','200'), 'currency' => 'GBP',

是否可以在PayPal上列出网站“购物车”中的所有产品。我这样问是因为PayPal说的是“描述”而不是“描述”,这比将总数与“你的篮子”的无效描述结合起来要好

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

 $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()

其中数据遵循上述布局。

我发现了这一点,它解释了这是如何实现的

添加了
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();
需要注意的事项
如果购买金额不等于项目数组的总和,则请求将失败。

可能存在重复项
$gateway = Omnipay\Omnipay::create('PayPal_Express');
$gateway->setUsername('....');
$gateway->setPassword('....');
$gateway->setSignature('.....');
$items = new Omnipay\Common\ItemBag();

$items->add(array(
            'name' => 'prova',
            'quantity' => '1',
            'price' => 40.00,
));
$items->add(array(
            'name' => 'prova 2',
            'quantity' => '1',
            'price' => 10.00,
));
$response = $gateway->purchase(
            array(
                'cancelUrl'=>'http://.../pay/',
                'returnUrl'=>'http://.../pay/return_to_site',
                'amount' =>  50.00,
                'currency' => 'EUR'
            )
)->setItems($items)->send();
$response->redirect();
$gateway = Omnipay\Omnipay::create('PayPal_Express');
$gateway->setUsername('....');
$gateway->setPassword('....');
$gateway->setSignature('.....');
$items = new Omnipay\Common\ItemBag();

$items->add(array(
            'name' => 'prova',
            'quantity' => '1',
            'price' => 40.00,
));
$items->add(array(
            'name' => 'prova 2',
            'quantity' => '1',
            'price' => 10.00,
));
$response = $gateway->purchase(
            array(
                'cancelUrl'=>'http://.../pay/',
                'returnUrl'=>'http://.../pay/return_to_site',
                'amount' =>  50.00,
                'currency' => 'EUR'
            )
)->setItems($items)->send();
$response->redirect();