我试图把PayPal集成到我的LaaFLE应用程序中。这就是我到目前为止所做的
-
贝宝创建业务帐户
-
已创建REST API
-
安装了Laravel 5.6和
srmklive/laravel-paypal
-
在我的.env文件中,我添加了以下内容
paypal_sandbox_api_username=mudassar-facilitator_api1.myxyzdomain.com
paypal_sandbox_api_password=我的密码
paypal_sandbox_api_secret=azaibtqiex06ji3rlt3or9ceqykazigsiqm-erxcc4g9pfrpdrmqsda
PayPal_Sandbox_API_证书=
paypal_live_api_用户名=mudassar@myxyzdomain.com
paypal_live_api_password=帐户密码
paypal_live_api_secret=eixf9ny3w8aipqucqxc7y41lzw3fsp7fpeibvpnabopp0kl0b5o6lif8qr-yj2my9svc7m2e98amqtfg
PayPal_Live_API_证书=
在我的config/paypal.php中,我有
return [
'mode' => 'live',
'sandbox' => [
'username' => env('PAYPAL_SANDBOX_API_USERNAME', ''),
'password' => env('PAYPAL_SANDBOX_API_PASSWORD', ''),
'secret' => env('PAYPAL_SANDBOX_API_SECRET', ''),
'certificate' => env('PAYPAL_SANDBOX_API_CERTIFICATE', ''),
'app_id' => 'APP-80W284485P519543T',
],
'live' => [
'username' => env('PAYPAL_LIVE_API_USERNAME', ''),
'password' => env('PAYPAL_LIVE_API_PASSWORD', ''),
'secret' => env('PAYPAL_LIVE_API_SECRET', ''),
'certificate' => env('PAYPAL_LIVE_API_CERTIFICATE', ''),
'app_id' => 'APP-80W284485P519543T',
],
'payment_action' => 'Sale',
'currency' => 'USD',
'notify_url' => '',
'locale' => '',
'validate_ssl' => true,
];
在我的控制器里
public function create()
{
$provider = new ExpressCheckout;
$data = [];
$data['items'] = [
[
'name' => 'Product 1',
'price' => 9.99,
'qty' => 1
],
[
'name' => 'Product 2',
'price' => 4.99,
'qty' => 2
]
];
$data['invoice_id'] = 1;
$data['invoice_description'] = "Order #{$data['invoice_id']} 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;
$data['shipping_discount'] = round((10 / 100) * $total, 2);
$response = $provider->setExpressCheckout($data);
dd($response);
return redirect($response['paypal_link']);
}
我倾倒的反应看从Paypal的ACK
当我使用沙盒时,当我使用Live(Live帐户和Live Secret)时,它会完美地工作,它会给我以下错误。
array:10 [â¼
"TIMESTAMP" => "2018-09-24T10:20:55Z"
"CORRELATIONID" => "e16239423f52"
"ACK" => "Failure"
"VERSION" => "123"
"BUILD" => "49303320"
"L_ERRORCODE0" => "10002"
"L_SHORTMESSAGE0" => "Security error"
"L_LONGMESSAGE0" => "Security header is not valid"
"L_SEVERITYCODE0" => "Error"
"paypal_link" => null
]
我做错什么了?