discourse-subscriptions/app/controllers/discourse_donations/charges_controller.rb

25 lines
591 B
Ruby
Raw Normal View History

2017-02-21 18:21:42 -05:00
require_dependency 'discourse'
2017-02-23 21:23:11 -05:00
module DiscourseDonations
class ChargesController < ActionController::Base
2017-02-21 18:21:42 -05:00
include CurrentUser
skip_before_filter :verify_authenticity_token, only: [:create]
def create
customer = Stripe::Customer.create(
2017-02-21 18:21:42 -05:00
:email => current_user.email,
:source => params[:stripeToken]
)
charge = Stripe::Charge.create(
:customer => customer.id,
2017-02-21 18:21:42 -05:00
:amount => params[:amount],
:description => 'Consumer Defender',
:currency => 'aud'
)
2017-02-21 19:12:19 -05:00
render :json => charge
end
end
end