samedi 30 avril 2016

Display Omnipay Error Message in Laravel

I have a simple payment form in my Laravel 5.2 webapp. Everything works as expected except when the payment has an issue and fails. I am trying to pass the error message on a redirect back and display this message on the top of the page.

My Controller:

// Payment failed
$payment_failed_array = $response->getMessage();
//dd($payment_failed_array); // I do get the error here.
return redirect()->back()
->with('payment_failed_array', $payment_failed_array)
->withInput();

My view:

@if ( ! empty(Session::get('payment_failed_array')))
@foreach (Session::get('payment_failed_array') as $error)
<div class="col-md-9">
    <div class="tab-pane fade in active" id="alert-1">
        <div class="alert alert-danger fade in">
            <strong>Oh snap!</strong> 
        </div>
    </div>
</div>
@endforeach
@endif

I definitely thank anyone who can help me in figuring this issue out.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1O4wMGZ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire