the subscribe product page

This commit is contained in:
Rimian Perkins
2019-11-04 16:37:21 +11:00
parent 2b3c52bdd4
commit e14b4dcd96
21 changed files with 201 additions and 128 deletions
+7 -18
View File
@@ -8,14 +8,14 @@ module DiscoursePatrons
def index
begin
customers = ::Stripe::Customer.list(
email: current_user.email,
expand: ['data.subscriptions']
)
products = ::Stripe::Product.list(active: true)
subscriptions = customers[:data].map do |customer|
customer[:subscriptions][:data]
end.flatten(1)
subscriptions = products[:data].map do |p|
{
id: p[:id],
description: p.dig(:metadata, :description)
}
end
render_json_dump subscriptions
@@ -50,17 +50,6 @@ module DiscoursePatrons
end
end
def destroy
begin
subscription = ::Stripe::Subscription.delete(params[:id])
render_json_dump subscription
rescue ::Stripe::InvalidRequestError => e
return render_json_error e.message
end
end
private
def plan_group(plan)