discourse-subscriptions/app/controllers/discourse_subscriptions/customers_controller.rb

24 lines
493 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2019-12-03 19:23:45 -05:00
module DiscourseSubscriptions
class CustomersController < ::ApplicationController
2019-12-03 19:23:45 -05:00
include DiscourseSubscriptions::Stripe
before_action :set_api_key
def create
2019-10-25 20:31:19 -04:00
begin
customer = ::Stripe::Customer.create(
email: current_user.email,
source: params[:source]
)
2019-10-25 20:31:19 -04:00
render_json_dump customer
rescue ::Stripe::InvalidRequestError => e
2019-12-11 17:59:38 -05:00
render_json_error e.message
2019-10-25 20:31:19 -04:00
end
end
end
end