omnipay array of products

徘徊边缘 提交于 2019-12-12 20:19:07

问题


Hello guys I'm working with omnipay in laravel and I want to know how can I change the code to show in the paypal receip the total of every item and the description of them

$response=$gateway->purchase(
        array(
            'cancelURL'     =>  $keys->getCancelUrl(),
            'returnURL'     =>  $keys->getReturnUrl(),
            'description'   =>  Cart::content(),
            'amount'        =>  '200.00',
            'currency'      =>  $keys->getCurrency()
            )
    )->send();</i>

回答1:


I never used OmniPay, by the way I've googled around and found what I think you are looking for on a eMerchantPay driver for the Omnipay class on GitHub.

$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',
    )
));

I'd suggest you to try to implement that items array in your script and test the results.

PS: Maybe you missed it, but there's a composer package that implements OmniPay into a laravel Facade ;)




回答2:


Thanks dude that's good. I'm going to share something, with paypal there's a method to add arrays it's setItems($array) and it's very cool

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

the only thing that i can't find was how to add tax so I added that like an item



来源:https://stackoverflow.com/questions/25068618/omnipay-array-of-products

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!