【问题标题】:paypal success url error laravel贝宝成功 url 错误 laravel
【发布时间】:2016-07-17 07:03:47
【问题描述】:

我正在使用 laravel Omni 插件进行交易。付款完成后,我收到成功网址错误。

public function  checkOut(Request $request)
{
    $params = array(
                'cancelUrl'     => 'http://localhost/vis/public/cancel_order',
                'returnUrl'     => 'http://localhost/vis/public/payment_success',
                'name'      => 'Meal',
                'description'   => 'Casper',
                'amount'    => '1.00',
                'currency'  => 'USD'
            );

    Session::put('params', $params);
    Session::save();
    $gateway = Omnipay::create('PayPal_Express');
    $gateway->setUsername('un');
    $gateway->setPassword('pwd');
    $gateway->setSignature('signature');
    $gateway->setTestMode(true);
    $response = $gateway->purchase($params)->send();

    if ($response->isSuccessful()) {
        print_r($params);
        redirect('payment_success/' . $this->orderNo);
        // payment was successful: update database
        print_r($response);
    } elseif ($response->isRedirect()) {

        // redirect to offsite payment gateway
        $response->redirect();
    } else {
        // payment failed: display message to customer
        echo $response->getMessage();
    }
}

public function getSuccessPayment()
{
    $gateway = Omnipay::create('PayPal_Express');
    $gateway->setUsername('un');
    $gateway->setPassword('pwd');
    $gateway->setSignature('signature');
    $gateway->setTestMode(true);

    $params = Session::get('params');
    $response = $gateway->completePurchase($params)->send();
    $paypalResponse = $response->getData(); // this is the raw response object

    if(isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
        // Response
        print_r($params);
 //     print_r($paypalResponse);

    } else {

        //Failed transaction

    }
//  return View('result');
    print_r($params);
    print_r($paypalResponse);
}

我收到以下错误

未找到 HTTP 错误 404。未找到请求的资源。 http://localhost/vis/public/payment_success?token=EC-1R845179Asss493N&PayerID=swdw3BS9REA4AN

【问题讨论】:

    标签: php laravel paypal omnipay


    【解决方案1】:

    您可能忘记在 routes.php 中添加该路由,请确保您在 routes.php 中有类似的内容

    Route::get('/payment_success', 'StoreController@getSuccessPayment');
    

    将 StoreController 更改为此函数所在的控制器的名称。

    【讨论】:

      猜你喜欢
      • 2017-02-26
      • 2018-06-16
      • 2013-12-12
      • 2016-05-27
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2012-06-15
      • 2018-02-02
      相关资源
      最近更新 更多