2017-01-30 21:28:41 -05:00
|
|
|
module Choice
|
|
|
|
class ChoiceController < Choice::ApplicationController
|
2017-01-30 22:21:27 -05:00
|
|
|
def create
|
2017-01-31 21:35:18 -05:00
|
|
|
@badge = consumer_defender_badge
|
|
|
|
@user = @discourse_api.client.user
|
|
|
|
|
|
|
|
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'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
head :created
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def consumer_defender_badge
|
|
|
|
Discourse.badges['badges'].select { |b| b['name'] == 'Consumer Defender' }.first
|
2017-01-30 21:28:41 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|