cartalyst / stripe-laravel

Cartalyst Stripe package integration for Laravel.
BSD 3-Clause "New" or "Revised" License
336 stars 58 forks source link

Catching exceptions #31

Closed kezern closed 7 years ago

kezern commented 7 years ago

I'm developing an application using laravel and Crudbooster. I want to catch card exceptions. I have this code. try{
$stripe = Stripe::make($key);

            $token = $stripe->tokens()->create([
                'card' => [
                    'number'    => $cobro->tarjeta,
                    'exp_month' => $card_date[0],
                    'cvc'       => $cobro->cvv,
                    'exp_year'  => '20'.$card_date[1],
                ],
            ]);

            //Log::info('token: '.print_r($token, true));

            $charge = $stripe->accountId('acct_XXXXXXXXXX')->charges()->create([
                'currency' => 'EUR',
                'amount'   => $cobro->importe,
                'source' => $token['id'],
                'description' => $cobro->descripcion,
                //'source' => 'tok_es',
                "application_fee" => $application_fee,
            ]);

        }catch(Cartalyst\Stripe\Exception\CardErrorException $e){
            Log::error("Se ha procudido una excepcion ".$e->getMessage());
        }

But exception is not catched and Whoops error of laravel is shown

brunogaspar commented 7 years ago

Duplicate of #17

kezern commented 7 years ago

Thanks! Sorry I didn't find that