I am redirecting away from Laravel 7 controller and it shows the redirection url just before it redirects to the url. I am using the following code:
private function createPayment($session_token)
{
    ...
    try {
        $response = Http::timeout(30)->withHeaders($headers)->post($url, $body)->json();
        if ($response['statusCode'] != '0000') {
            $this->redirectError($response['statusCode'], $session_token);
        }
        $url= $response['bkashURL'];
        redirect()->away($url)->send();
    } catch (\Throwable $th) {
        $this->redirectError($response['statusCode'], $session_token);
    }
}
// redirect error method:
private function redirectError($code, $session_token = null)
{
    if ($session_token != null) {
        session()->forget($session_token);
    }
    $message = $this->error($code);
    $url = config('global.api_url_bkash') . 'error/' . $message;
    redirect()->away($url)->send();
}
// error method:
private function error($code)
{
    switch ($code) {
        case '2001':
            return 'Invalid App Key';
            break;
        case '2002':
            return 'Invalid Payment ID';
            break;
            
    .....
}
I getting this :
how can I prevent the page not to show the url.
via Chebli Mohamed

 
Aucun commentaire:
Enregistrer un commentaire