andrewculver/koudoku — pull request #42 by DaKaZ (2014-01-29 15:01:54+00:00)
Title: Freemium Enhancements

In order to use Koudoku with a freemium model (a free account or upgraded pay accounts) we must change Koudoku to support adding a customer without taking a credit card (most customers dont want to provide a CC for a free account). In order for this to work, you need to have a "Free" plan in your Stripe.com account. For our model, we overrode the default Devise confirmations_controller.rb and extended the do_confirm! method to create the free subscription (and create the customer object) at stripe.

def do_confirm
@confirmable.confirm!
if @confirmable.subscription.nil?
subscription = Subscription.new
subscription.user = @confirmable
subscription.plan = Plan.find_by_name('Free')
subscription.save
end
set_flash_message :notice, :confirmed
sign_in_and_redirect(resource_name, @confirmable)
end

We had to significantly update the views for our application but thanks to rails engine magic those are easy to override (thanks for rake task to set those up as well!)