# -*- encoding : utf-8 -*-

class Public::AbonnementsController < ApplicationController

  before_filter :auth_customer
	layout "public"

	def new
    @abonnement = current_customer.abonnements.new(:price => 300.0, :start_at => Time.now, :end_at => (Time.now+14.months).end_of_day, :slug => "negos-principal")
  end
  
  def create
    @abonnement = current_customer.abonnements.new(:price => 300.0, :start_at => Time.now, :end_at => (Time.now+14.months).end_of_day, :slug => "negos-principal")
    
    if @abonnement.save
      session[:abonnement_id] = @abonnement
      
      @payment = @abonnement.payments.create(:amount => @abonnement.total_price_ttc, :payment_type_id => 1, :customer_id => current_customer.id)
      session[:payment_id] = @payment.id
      redirect_to paid_by_ogone_public_payment_path(@payment)
    else
      redirect_to :action => :new
    end
  
  end
  
end
