Skip to content

Instantly share code, notes, and snippets.

@mikesabat
Created December 15, 2013 18:13
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 mikesabat/7976187 to your computer and use it in GitHub Desktop.
Save mikesabat/7976187 to your computer and use it in GitHub Desktop.
Subscribing a User (with Devise) to a Stripe plan
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :pins
validates :name, presence: true
after_create :create_a_customer
def create_a_customer
token = self.stripe_card_token
customer = Stripe::Customer.create(
:card => token,
:plan => 120,
:email => self.email
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment