laravel的贝宝订单总额

时间:2018-06-27 08:13:15

标签: laravel api paypal

有人在laravel项目中使用srmklive的PayPal API吗?

https://github.com/srmklive/laravel-paypal

已经安装了它,并且可以正常使用,直到出现以下错误。 我已经搜索了几个小时,但是找不到解决方案。

这是什么问题? 它一直在说以下内容;订单总数无效。

Array ( [TIMESTAMP] => 2018-06-27T08:06:32Z [CORRELATIONID] => c8e16efc9b6e4 [ACK] => Failure [VERSION] => 123 [BUILD] => 47483429 [L_ERRORCODE0] => 10401 [L_ERRORCODE1] => 10426 [L_ERRORCODE2] => 10431 [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details. [L_SHORTMESSAGE1] => Transaction refused because of an invalid argument. See additional error messages for details. [L_SHORTMESSAGE2] => Transaction refused because of an invalid argument. See additional error messages for details. [L_LONGMESSAGE0] => Order total is invalid. [L_LONGMESSAGE1] => Item total is invalid. [L_LONGMESSAGE2] => Item amount is invalid. [L_SEVERITYCODE0] => Error [L_SEVERITYCODE1] => Error [L_SEVERITYCODE2] => Error [paypal_link] => )

我在文档中没有看到有关订单总额的信息? 还是我错过了什么?

我现在正在使用的代码;

`$provider = new ExpressCheckout;

        $data = [];
        $order_id = 1;

        $data['items'] = [
            [
                'name'  => 'Product 1',
                'price' => 9.99,
                'qty'   => 1,
            ],
        ];
        $data['return_url'] = url('/paypal/ec-checkout-success');

        $data['invoice_id'] = config('paypal.invoice_prefix').'_'.$order_id;
        $data['invoice_description'] = "Order #$order_id Invoice";
        $data['cancel_url'] = url('/');
        $total = 0;

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

        $data['total'] = $total;

        //return print_r($data);

        $response = $provider->setExpressCheckout($data);

        //return dd($respons);

        // This will redirect user to PayPal
        return print_r($response); `

谢谢。

1 个答案:

答案 0 :(得分:0)

我找到了解决上述问题的方法。 PayPal不知为何不接受9.99美元 当我用10美元作一个整数时,它就起作用了。