Class: Saasaparilla::PaymentsController

Inherits:
ApplicationController show all
Includes:
Authentication::InstanceMethods
Defined in:
app/controllers/saasaparilla/payments_controller.rb

Instance Method Summary collapse

Methods included from Authentication::InstanceMethods

included, #require_current_billable

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
# File 'app/controllers/saasaparilla/payments_controller.rb', line 12

def create
  @payment = @subscription.payments.build(params[:payment])
   if @payment.save
     redirect_to edit_subscription_payment_path(@payment)
   else
     render :action => "new"
   end
end

#editObject



21
22
23
# File 'app/controllers/saasaparilla/payments_controller.rb', line 21

def edit
  
end

#newObject



8
9
10
# File 'app/controllers/saasaparilla/payments_controller.rb', line 8

def new
  @payment = @subscription.payments.build
end

#showObject



42
43
44
# File 'app/controllers/saasaparilla/payments_controller.rb', line 42

def show
  @payment = @subscription.payments.find(params[:id])
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/saasaparilla/payments_controller.rb', line 25

def update

  begin
    if @payment.update_attributes(params[:payment])
      flash[:notice] = "Thank you, your payment has been processed."
      redirect_to subscription_payment_path
    else
      flash[:error] = "An error has occured when trying to process your payment."
      render :action => "edit"
    end
  rescue Exception => e
       flash[:error] = e.message
       render :action => "edit"
       flash.discard
  end
end