如何在Laravel Paypal包装中设定税费和运费

时间:2018-01-08 02:44:47

标签: php paypal laravel-5.5

最近我正在开发一个laravel项目,我选择使用srmklive/laravel-paypal作为我的paypal支付网关插件,但我发现我无法添加税费和运费,我已多次阅读readme.doc并检查paypal文档,但我仍然对如何添加税费和运费感到困惑。

有没有人知道如何在setExpresssCheckout中添加这些数据?

这是我的代码:

$provider = new ExpressCheckout;
            $provider = PayPal::setProvider('express_checkout');

            $itemsArr = $data = [];

// add items
            foreach ($order->orderProduct as $order_product) {
              array_push($itemsArr, [
                  'name' => $order_product->product->name,
                  'price' => $order_product->price,
                  'qty' => $order_product->quantity
              ]);
            }

            // add shipping fees
            array_push($itemsArr, [
              'name' => "Shipping Method : ".$order->shipping_method,
              'price' => $order->shipping_fees,
              'qty' => 1
            ]);
            $data["items"] = $itemsArr;

            $data['invoice_id'] = 1;
            $data['invoice_description'] = "Order #1 Invoice";
            $data['return_url'] = url('/payment/success');
            $data['cancel_url'] = url('/cart');

            $total = 0;
            foreach($data['items'] as $item) {
                $total += $item['price']*$item['qty'];
            }

            $data['total'] = $total;

            $options = [
              'BRANDNAME' => 'Ulife',
              'LOGOIMG' => asset("images\ulifelanding.png"),
              'CHANNELTYPE' => 'Merchant'
            ];

            $response = $provider->setCurrency('MYR')->addOptions($options)->setExpressCheckout($data);

Ps:我也在github问过,但仍感到困惑。

0 个答案:

没有答案