Q:

Show openpay errors in laravel

I am using OpenPay and Laravel, if an error occurs when I try to do the carge to the bank account, it shows in the Laravel error page (The one that is red). How can I show that errors in a view?

A:

I used a try catch structure, as an extra I had to put an **** before every exception to avoid the default Laravel exception errors.
try{
some code...
}catch(\OpenpayApiTransactionError $e) {
                flash('Error ' . $e->getMessage())->error();
                $error = $e->getMessage();
                return redirect()->back()->with('error', $error)->with('valor', 'si');
                //return redirect('/codigos');
            } catch (\OpenpayApiRequestError $e) {
                flash('Error ' . $e->getMessage())->error();
                $error = $e->getMessage();
                return redirect()->back()->with('error', $error)->with('valor', 'si');
                //return redirect('/codigos');
            } catch (\OpenpayApiConnectionError $e) {
                flash('Error ' . $e->getMessage())->error();
                $error = $e->getMessage();
                return redirect()->back()->with('error', $error)->with('valor', 'si');
                //return redirect('/codigos');
            } catch (\OpenpayApiAuthError $e) {
                flash('Error ' . $e->getMessage())->error();
                $error = $e->getMessage();
                return redirect()->back()->with('error', $error)->with('valor', 'si');
                //return redirect('/codigos');
            } catch (\OpenpayApiError $e) {
                flash('Error ' . $e->getMessage())->error();
                $error = $e->getMessage();
                return redirect()->back()->with('error', $error)->with('valor', 'si');
                //return redirect('/codigos');
            } catch (\Exception $e) {
                flash('Error ' . $e->getMessage())->error();
                $error = $e->getMessage();
                return redirect()->back()->with('error', $error)->with('valor', 'si');
                //return redirect('/codigos');
            }

I hope that somebody else finds this usefull.

