RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.

Home Page:http://railsapps.github.io/rails-stripe-membership-saas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems on Windows with "Stripe token not present"

Austio opened this issue · comments

Before creating a new issue I have looked at issues 10 and 22 and searched on a few google groups

When I run db:seed i get the "stripe token not present. Can't create account" and the error is coming in on line 36 of the user model.

The admin user is created but the regular users fail.

I commented out the lines in the user.update_stripe method to allow for non-example.com in development

commented out so that I could put gmail and others into the User Database

#return if email.include?('@example.com') and not Rails.env.production?

For the stripe setup in the application.yml
STRIPE_API_KEY: sk_test_********************
STRIPE_PUBLIC_KEY: pk_test_********************

If this is not a big deal I can just manually create them, just wanted to make sure that I haven't broken anything.

Thanks!

Just an update, when i look at my parameters the request is this
{"utf8"=>"✓", "authenticity_token"=>"mfti9nt9r2eBkIJSB2uA3A3XqAEa0IRFCwG7E4lNRGg=", "plan"=>"silver", "user"=>{"name"=>"Austin", "email"=>"l@gmail.com", "password"=>"l", "password_confirmation"=>"l", "stripe_token"=>""}, "commit"=>"Sign up", "action"=>"create", "controller"=>"registrations"}

So, stripe_token does not have a value

The stripe token will be nil because you are not using Stripe.js to sign up new users. That is the reason for the return if email.include?('@example.com') and not Rails.env.production?. That stops it from hitting the Stripe service when creating new users from the seed file. Without that line, it will try to hit Stripe and will throw an error because it hasn't received a stripe_token back from the stripe.js file.

If you are going to initialize the database from the db/seeds.rb file you should use example.com email addresses for the "fake" users. And leave the return if email.include?('@example.com') statement in place in the User model update_stripe method.

You could use gmail.com email addresses in your db/seeds.rb file and change the '@example.com' to '@gmail.com' in the User model update_stripe method but I advise not to because it will break tests (unless you change the tests) and prevent you from using the application in development to add gmail.com users.

Maybe you could explain your use case why you want to add gmail.com addresses in the db/seeds.rb file. It's best to use the application, not the db/seeds.rb file, to add new users.

You are right Danial, i have no business case to change this in development so i cloned a new one.

I am still getting errors. All of my rspec is passing but my cucumber is not. I suspect it is due to me being on a windows box.

btw, i have a few steps that windows developers will need to add that I have documented if you would like those to add to the tutorial (assuming that those steps are not the cause of this error...which there is a good chance they are if i am the only one getting this)

Windows Extra Steps

  1. Binding of callers Error
    Download DevKit. https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
    Put it somewhere and then go to the directory and run
    ruby dk.rb init
    ruby dk.rb install
  2. libv8 error
    gem install libv8 -- --with-system-v8
    gem install libv8 -- --with-system-v8
  3. Javascript error -
    remove the //= require_tree . in assets/javascripts/application.js

After this it runs but gives an error due to not getting a stripe token. I suspect it is due to step 3 to run in windows (maybe this is conflicting somehow with the stripe.js)

Remove the binding_of_caller gem or use this in your Gemfile:

gem "binding_of_caller", ">= 0.7.1", :group => :development, :platforms => [:mri_19, :rbx]

Yes, you need a JavaScript runtime. See the article:
http://railsapps.github.com/installing-rails.html

As you know, you can develop with Rails on Windows but be aware that most developers use Mac OS X or Ubuntu to develop Rails applications. Some gems requiring native extensions may be difficult to install on Windows. An option on Windows is to install Ruby under Cygwin. This gives you a Linux environment on Windows.

You are getting the "Stripe token not present" error (and the Cucumber tests are failing) because you have removed the //= require_tree . in assets/javascripts/application.js. You need that for the JavaScript files to be included. AFAIK (I don't develop on Windows) you should be able to leave //= require_tree . in place once you add a JavaScript runtime.

Thanks a million Daniel, i'm learning (through pain) that this windows is not optimal for this. I wish I had this guide when I first started so wanted to include it here for anyone else installing this on windows.

http://installfest.railsbridge.org/installfest/windows