[英]List multiple items through Paypal Express checkout using Omnipay & Laravel 4
是否可以在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();
数据遵循上述布局。
添加了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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.