【发布时间】: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); `
提前谢谢你。
【问题讨论】: