【问题标题】:omnipay array of products全支付系列产品
【发布时间】:2014-07-31 20:46:23
【问题描述】:

大家好,我正在 laravel 中使用 omnipay,我想知道如何更改代码以在 paypal 收据中显示每个项目的总数及其描述

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

【问题讨论】:

    标签: php laravel paypal omnipay


    【解决方案1】:

    我从未使用过 OmniPay,顺便说一句,我在 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:也许你错过了,但是有一个 composer 包实现了OmniPay into a laravel Facade ;)

    【讨论】:

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

      我唯一找不到的是如何加税,所以我像一个项目一样添加了它

      【讨论】:

      • $items 的实例是什么?你在哪里实例化那个变量?
      • @MartinBean $item 是 Omnipay\Common\Item 的实例,$items 是 Omnipay\Common\ItemBag 的实例
      • @ddjikic 我猜它应该是 Omnipay\Common\ItemBag 的一个实例,它是一个项目的集合。
      猜你喜欢
      • 2015-08-25
      • 1970-01-01
      • 2015-08-03
      • 2011-06-07
      • 1970-01-01
      • 1970-01-01
      • 2015-03-27
      • 1970-01-01
      • 2013-07-17
      相关资源
      最近更新 更多