代码之家  ›  专栏  ›  技术社区  ›  Mudassar Khani

“l_longmessage0”=>“安全头无效”

  •  0
  • Mudassar Khani  · 技术社区  · 6 年前

    我试图把PayPal集成到我的LaaFLE应用程序中。这就是我到目前为止所做的

    1. 贝宝创建业务帐户
    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=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', // 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 当我使用沙盒时,当我使用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
    ]
    

    我做错什么了?

    0 回复  |  直到 6 年前