public function add($invoice)
 {
     $validator = Validator::make(Input::all(), InvoiceComment::$rulesAdd);
     if (!$validator->fails()) {
         $i = new InvoiceComment();
         $i->invoice_id = Input::get('invoice_id');
         $i->user_id = Input::get('user_id');
         $i->content = Input::get('content');
         if ($i->save()) {
             return Redirect::route('invoice_modify', $invoice)->with('mSuccess', 'Le commentaire a bien été ajouté');
         }
     }
     return Redirect::route('invoice_modify', $invoice)->with('mError', 'Impossible d\'ajouter ce commentaire');
 }
 public function stripe($id)
 {
     $invoice = $this->dataExist($id, 'invoice_list');
     // Set your secret key: remember to change this to your live secret key in production
     // See your keys here https://dashboard.stripe.com/account/apikeys
     \Stripe\Stripe::setApiKey($_ENV['stripe_sk']);
     // Get the credit card details submitted by the form
     $stripeToken = Request::input('stripeToken');
     // Create the charge on Stripe's servers - this will charge the user's card
     try {
         $amount = Invoice::TotalInvoiceWithTaxes($invoice->items) * 100;
         if ($amount) {
             $charge = \Stripe\Charge::create(array("amount" => $amount, "currency" => "eur", "source" => $stripeToken, "description" => "Facture " . $invoice->ident));
         }
         $invoice->date_payment = date('Y-m-d');
         $invoice->save();
         $invoice_comment = new InvoiceComment();
         $invoice_comment->invoice_id = $invoice->id;
         $invoice_comment->user_id = Auth::user()->id;
         $invoice_comment->content = 'Payé par CB avec Stripe';
         $invoice_comment->save();
         return Redirect::route('invoice_list')->with('mSuccess', sprintf('La facture %s a été payée', $invoice->ident));
     } catch (\Stripe\Error\Card $e) {
         // The card has been declined
     }
 }