Class: StripeWrapper::ChargesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/stripe_wrapper/charges_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#main_app_current_user

Methods included from StripeWrapperHelper

#stripe_get_amount, #stripe_pay, #stripe_set_amount, #stripe_wrapper_path

Instance Method Details

#indexObject



20
21
22
# File 'app/controllers/stripe_wrapper/charges_controller.rb', line 20

def index
  @charges = Charge.all.order("ID DESC")
end

#process_paymentObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/stripe_wrapper/charges_controller.rb', line 6

def process_payment
  @user = main_app_current_user
  token = params[:stripe_token]
  @amount = stripe_get_amount
  redirect_url = params[:redirect_path]

  @customer = Customer.find_or_create_customer(token,@user)
  @charge = @customer.process_new_charge(@amount)

  # abort

  return redirect_to redirect_url+"?charge_id=#{@charge.id}"
end