【问题标题】:List multiple items through Paypal Express checkout using Omnipay & Laravel 4使用 Omnipay 和 Laravel 4 通过 Paypal Express 结账列出多个项目
【发布时间】:2014-10-11 05:47:57
【问题描述】:

是否可以在 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();

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

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

其中数据遵循上述布局。

【问题讨论】:

标签: php laravel paypal payment-gateway omnipay


【解决方案1】:

我发现了这个post on 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();

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

【讨论】:

    【解决方案2】:
    $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();
    

    【讨论】:

      猜你喜欢
      • 2017-03-25
      • 2017-05-26
      • 2015-02-13
      • 2014-09-28
      • 2014-11-01
      • 2014-11-26
      • 2017-11-10
      • 2017-09-05
      • 2015-01-06
      相关资源
      最近更新 更多