[英]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.