here is what I did.
in app\Exceptions\Handler.php this is what I have and it works.
<?php namespace cablework\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Stripe\Error as Stripe;
class Handler extends ExceptionHandler {
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof Stripe\Card)
{
session()->flash('error_msg',$e->getMessage() . ' <a class="alert-link" href="'.route('settings.company.creditcard').'">Click here</a> to manage your card.');
return redirect()->back();
}
if ($e instanceof Stripe\RateLimit)
{
session()->flash('error_msg','It looks like our payment processor was busy. Please try again in a few minutes.');
return redirect()->back();
}
if ($e instanceof Stripe\Api ||
$e instanceof Stripe\ApiConnection ||
$e instanceof Stripe\Authentication ||
$e instanceof Stripe\InvalidRequest ||
$e instanceof Stripe\Base)
{
session()->flash('error_msg',$e->getMessage());
return redirect()->back();
}
return parent::render($request, $e);
}
}