1
0
mirror of synced 2026-09-12 00:49:38 +00:00
Files
discourse-subscriptions/app/controllers/plans_controller.rb
T
2019-11-01 10:18:57 +11:00

25 lines
564 B
Ruby

# frozen_string_literal: true
module DiscoursePatrons
class PlansController < ::ApplicationController
include DiscoursePatrons::Stripe
before_action :set_api_key
def index
begin
plans = ::Stripe::Plan.list(active: true)
serialized = plans[:data].map do |plan|
plan.to_h.slice(:id, :amount, :currency, :interval)
end.sort_by { |plan| plan[:amount] }
render_json_dump serialized
rescue ::Stripe::InvalidRequestError => e
return render_json_error e.message
end
end
end
end