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