大家好,我正在使用laravel的omnipay,我想知道如何更改代码以在paypal收据中显示每个项目的总数及其描述
$response=$gateway->purchase(
array(
'cancelURL' => $keys->getCancelUrl(),
'returnURL' => $keys->getReturnUrl(),
'description' => Cart::content(),
'amount' => '200.00',
'currency' => $keys->getCurrency()
)
)->send();</i>
答案 0 :(得分:2)
我从来没有使用OmniPay,就像我用Google搜索过的那样,在GitHub的eMerchantPay driver for the Omnipay课程中找到了我认为你正在寻找的东西。
$purchase = $gateway->purchase(array(
'currency' => 'GBP',
'transactionReference' => 'referenceID1',
'clientIp' => '95.87.212.88',
'items' => array(
array(
'name' => 10,
'price' => '5.00',
'description' => 'Product 1 Desc',
'quantity' => 2
),
array(
'name' => 12,
'price' => '5.00',
'description' => 'Shipping for Product 1',
'quantity' => 1
),
array(
'name' => 12,
'price' => '0.00',
'description' => 'Promotion',
'quantity' => 1
),
),
'card' => array(
'firstName' => 'Example',
'lastName' => 'User',
'number' => '4111111111111111',
'expiryMonth' => 7,
'expiryYear' => 2013,
'cvv' => 123,
'address1' => '123 Shipping St',
'address2' => 'Shipsville',
'city' => 'Shipstown',
'postcode' => '54321',
'state' => 'NY',
'country' => 'US',
'phone' => '(555) 987-6543',
'email' => 'john@example.com',
)
));
我建议您尝试在脚本中实现该items数组并测试结果。
PS:也许你错过了它,但是有一个实现OmniPay into a laravel Facade的作曲家包;)答案 1 :(得分:2)
谢谢老兄,这很好。 我要分享一些东西,用paypal有一种添加数组的方法就是setItems($ array) 这很酷
foreach (Cart::content() as $content)
{
$items->add(array(
'name' => $content->name,
'quantity' => $content->qty,
'price' => $content->price,
));
}
$items->add(array(
'name' => 'IVA',
'quantity' => '1',
'price' => $iva,
));
$response = $gateway->purchase(
array(
'cancelURL' => $keys->getCancelUrl(),
'returnURL' => $keys->getReturnUrl(),
'description' => 'Venta',
'amount' => $total,
'currency' => $keys->getCurrency()
)
)->setItems($items)->send();
我唯一无法找到的是如何添加税,所以我添加了像项目