【问题标题】:paypal order total with laravel使用 laravel 的 paypal 订单总额
【发布时间】:2018-12-06 01:19:02
【问题描述】:

有人在 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); `

提前谢谢你。

【问题讨论】:

    标签: laravel api paypal


    【解决方案1】:

    我找到了解决上述问题的方法。 不知何故 PayPal 不接受 9.99 美元 当我制作一个像 10 美元这样的整数时,它可以工作。

    【讨论】:

      猜你喜欢
      • 2015-12-03
      • 2014-12-29
      • 2021-03-09
      • 2012-11-29
      • 2015-11-17
      • 2021-01-20
      • 2013-01-08
      • 2012-05-21
      相关资源
      最近更新 更多