34 lines
680 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module DiscoursePatrons
class PlansController < ::Admin::AdminController
2019-09-24 20:44:51 +10:00
include DiscoursePatrons::Stripe
before_action :set_api_key
2019-09-25 11:18:11 +10:00
def index
plans = ::Stripe::Plan.list
render json: plans.data
end
2019-09-24 20:44:51 +10:00
def create
plan = ::Stripe::Plan.create(
amount: params[:amount],
interval: params[:interval],
product: {
name: 'Gold special',
},
2019-09-24 20:57:42 +10:00
currency: SiteSetting.discourse_patrons_currency,
2019-09-24 20:44:51 +10:00
id: 'gold-special',
)
2019-09-25 11:18:11 +10:00
render json: plan
end
2019-09-25 13:20:28 +10:00
def destroy
plan = ::Stripe::Plan.delete(params[:id])
render json: plan
end
end
end