2017-02-21 18:21:42 -05:00
|
|
|
require_dependency 'discourse'
|
|
|
|
|
2017-02-23 21:23:11 -05:00
|
|
|
module DiscourseDonations
|
2017-02-16 00:29:42 -05:00
|
|
|
class ChargesController < ActionController::Base
|
2017-02-21 18:21:42 -05:00
|
|
|
include CurrentUser
|
|
|
|
|
2017-02-16 00:29:42 -05:00
|
|
|
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,
|
2017-02-16 00:29:42 -05:00
|
|
|
:source => params[:stripeToken]
|
|
|
|
)
|
|
|
|
|
|
|
|
charge = Stripe::Charge.create(
|
|
|
|
:customer => customer.id,
|
2017-02-21 18:21:42 -05:00
|
|
|
:amount => params[:amount],
|
2017-02-16 00:29:42 -05:00
|
|
|
:description => 'Consumer Defender',
|
|
|
|
:currency => 'aud'
|
|
|
|
)
|
2017-02-21 19:12:19 -05:00
|
|
|
render :json => charge
|
2017-02-16 00:29:42 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|