Skip to content

Instantly share code, notes, and snippets.

@brandonhilkert
Created May 15, 2015 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonhilkert/330ed9ea6e6ee3416696 to your computer and use it in GitHub Desktop.
Save brandonhilkert/330ed9ea6e6ee3416696 to your computer and use it in GitHub Desktop.
class Subscription
def initialize(stripe_id)
@stripe_id = stripe_id
end
def name
subscription.plan.name
end
def amount
subscription.plan.amount / 100
end
private
attr_reader :stripe_id
def subscription
@subscription ||= customer.subscriptions.data.first
end
def customer
@customer ||= Stripe::Customer.retrieve(stripe_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment