在Laravel中重定向Url for gocardless

时间:2017-10-10 08:46:55

标签: php laravel curl dropbox dropbox-api

我试图在我的laravel项目中实施无卡。

首先,我想通过重定向流创建一个令牌。 但是通过curl调用重定向流时将提供的参数包含success_redirect_url。 但它返回一个错误,如

    Array
  (
[error] => Array
    (
        [message] => Validation failed
        [errors] => Array
            (
                [0] => Array
                    (
                        [field] => success_redirect_url
                        [message] => must be HTTP or HTTPS
                        [request_pointer] => /redirect_flows/success_redirect_url
                    )

            )

        [documentation_url] => https://developer.gocardless.com/api-reference#validation_failed
        [type] => validation_failed
        [request_id] => 8e873944-c3e2-4838-8666-d7683d0db6a6
        [code] => 422
    )

     )

我的ajax控制器是,

      $param_array = array(
                  "redirect_flows" => array(
                   "description" => $compdata[0]['pack'],
                   "session_token" => $session_token,
                   "success_redirect_url" => '/gocardless_calculation/'
                                           )
                          );

我的路线是,

 Route::post('/gocardless_calculation', '\App\Http\Controllers\tunnel\controller@setupgocardless')->name('gocardless_calculation');

如何在laravel中成功重定向网址?

1 个答案:

答案 0 :(得分:0)

您需要返回带有消息的重定向。

return redirect('route.name')->with('success', 'Added Successfully!');

在视图中从Session

获取值
@if (\Session::has('success'))
    <div class="alert alert-success">
        {!! \Session::get('success') !!}
    </div>
@endif