1
0
mirror of synced 2026-08-04 14:16:55 +00:00

serialize and order the plans

This commit is contained in:
Rimian Perkins
2019-11-01 10:18:57 +11:00
parent 5fe08c110f
commit 3dfa261c19
3 changed files with 23 additions and 4 deletions
+5 -2
View File
@@ -10,8 +10,11 @@ module DiscoursePatrons
begin
plans = ::Stripe::Plan.list(active: true)
# TODO: Serialize. Remove some attributes like meta.group_name
render_json_dump plans.data
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