RailsApps / rails-stripe-membership-saas

An example Rails 4.2 app with Stripe and the Payola gem for a membership or subscription site.
http://railsapps.github.io/rails-stripe-membership-saas
1.14k stars 232 forks source link

Stripe token not present #91

Closed viveksp closed 10 years ago

viveksp commented 10 years ago

Hi,

Few disclaimers - I have gone through all the issues discussed for "Stripe token not present". None of them were helpful in my case I am newbie in rails.

I followed the step by step instructions for setup.

  1. Ran rails new rails-stripe-membership-saas -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T and setup the app for stripe.
  2. Configured email, password, stripe api and public keys in application.yml
  3. setup the seed file.
  4. Setup the stipe account for the 3 plans mentioned.

When I run this app in local host and try to add an new user, I get "stripe token not present" error. When i looked at the logs, the variable is null.

This is for any other email except example.com. If i use somename@example.com, It works fine(it wont hit stipe. Just create a user in database)

I have used tools to check on the client side and ensure that registrations.js is loading. I dont see that js.stripe.com is being called from logs.

Please note. I have not made any changes to the code anywhere. I have just followed the instructions.

What am i missing here.

Please help

DanielKehoe commented 10 years ago

What happens if you clone the project directly from the GitHub repo? We know the version in the repo works if you set it up with valid Stripe keys.

viveksp commented 10 years ago

That works perfectly well. Thanks a bunch. But I would be interested to know why the generate failed.

DanielKehoe commented 10 years ago

Use a file compare tool to look for differences between your version and the "known good" version from the repo.

riley128 commented 10 years ago

I'm having the same issue, did you find out what was causing the error?

rceee commented 10 years ago

Same issue here. I notice in registrations.js, that it is linking to https://js.stripe.com/v1/; while Stripe's documentation says to use /v2; has anything changed on their end? I cloned the repo and set things up from there; had a successful db:create, migrate, and seed. Application.yml variables are set right with the keys. But my error message shows a blank value for the "stripe_token"=>"" when signing up a non-example user (with Stripe in test mode, trying to test subscriptions)

I also did a comprehensive comparison of the cloned repo vs the generated one (from command line, the rails new rails-stripe-membership-saas -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T choosing sass/stripe site), and there were very few differences, mainly a couple of extra files for Teaspoon testing… So It's a bit confusing as to why the token isn't loading when it seems to be right there. Also, all rspec tests passed, fwiw

Upon closer inspection, in new.html.erb there is the following code block (in both cloned and generated):

<% content_for :head do %> <%= tag :meta, :name => "stripe-key", :content => STRIPE_PUBLIC_KEY %> <% end %>

However, when viewing the page source, the meta tag is not generated in the final html. Wondering if this is a recent Rails version issue, but looking further. Definitely seems to be part of the problem, as I can pull the STRIPE_PUBLIC_KEY as present in the console/debugger.

Javascript error confirms this:

Error: You did not set a valid publishable key. Call Stripe.setPublishableKey() with your publishable key. For more info, see…

---- EDIT

Adding the following line under the existing META tag(s) in application.html.erb header made the key available in meta tag, and thus passed on to registration.js's code; and fixed the issue:

<%= yield :head %>