discourse-subscriptions/app/controllers/choice/choice_controller.rb

28 lines
619 B
Ruby
Raw Normal View History

2017-01-30 21:28:41 -05:00
module Choice
class ChoiceController < Choice::ApplicationController
2017-01-30 22:21:27 -05:00
def create
customer = Stripe::Customer.create(
:email => params[:stripeEmail],
:source => params[:stripeToken]
)
charge = Stripe::Charge.create(
:customer => customer.id,
:amount => params[:amount],
:description => 'Consumer Defender',
:currency => 'aud'
)
2017-02-01 00:16:42 -05:00
BadgeGranter.grant(consumer_defender_badge, current_user)
head :created
end
private
def consumer_defender_badge
2017-02-01 00:16:42 -05:00
Badge.find_by_name('Consumer Defender')
2017-01-30 21:28:41 -05:00
end
end
end