“ L_LONGMESSAGE0” =>“安全标头无效”

时间:2018-09-24 10:35:04

标签: laravel paypal

我正在尝试将Paypal集成到我的laravel应用程序中。这是我到目前为止所做的

  1. 在Paypal上创建企业帐户
  2. 创建的Rest API
  3. 安装了Laravel 5.6和srmklive/laravel-paypal
  4. 在我的.env文件中,我添加了以下内容

    PAYPAL_SANDBOX_API_USERNAME = mudassar-facilitator_api1.myxyzdomain.com PAYPAL_SANDBOX_API_PASSWORD =我的密码 PAYPAL_SANDBOX_API_SECRET = AzAibTQIex06ji3rlT3Oro9cEqYkAziGSIqm-erXCc4G9PfRPDRmQsDA

    PAYPAL_SANDBOX_API_CERTIFICATE =

    PAYPAL_LIVE_API_USERNAME=mudassar@myxyzdomain.com PAYPAL_LIVE_API_PASSWORD =帐户密码 PAYPAL_LIVE_API_SECRET = EIXF9Ny3w8AipQucQXc7y41lZW3Fsp7fPEiBVpNabopp0kL0b5O6liF8qr-yJ2mY9SvC7M2E98AmQTfG

    PAYPAL_LIVE_API_CERTIFICATE =

在我的config / paypal.php中,

return [
'mode'    => 'live', // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
'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', // Used for testing Adaptive Payments API in sandbox mode
],
'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', // Used for Adaptive Payments API
],

'payment_action' => 'Sale', // Can only be 'Sale', 'Authorization' or 'Order'
'currency'       => 'USD',
'notify_url'     => '', // Change this accordingly for your application.
'locale'         => '', // force gateway language  i.e. it_IT, es_ES, en_US ... (for express checkout only)
'validate_ssl'   => true, // Validate SSL when creating api client.
];

在我的控制器中,我有

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;

    //give a discount of 10% of the order amount
    $data['shipping_discount'] = round((10 / 100) * $total, 2);

    $response = $provider->setExpressCheckout($data);
    dd($response);
     // This will redirect user to PayPal
    return redirect($response['paypal_link']);
}

我正在转储响应以从Paypal中看到Ack 当我使用沙箱时,当我使用实时帐户(实时帐户和实时机密)时,它可以完美地工作,它给我以下错误。

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
]

我在做什么错了?

0 个答案:

没有答案