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. Can't create account. #88

Closed seei2i closed 10 years ago

seei2i commented 10 years ago

I know this issue seems to be closed but I can not find any information on the tutorial that seems to help solve the problem I am having with the rails-stripe-membership-saas application. I have one striped down version that does work and one that I have a number of models on the gives the error in development. These are the last lines I get in the command line when it rolls back.
Role Exists (0.1ms) SELECT 1 AS one FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" IS NULL AND "roles"."id" = 3 LIMIT 1 (0.1ms) SELECT "roles".id FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" IS NULL Role Load (0.1ms) SELECT "roles".* FROM "roles" WHERE "roles"."id" = ? LIMIT 1 ["id", 3] begin transaction User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'person@gmail.com' LIMIT 1 (0.1ms) rollback transaction Completed 500 Internal Server Error in 102ms

Any help work be Greatly appreciated. Or to be pointed in the right direction for information that might help. Thanks

seei2i commented 10 years ago

Thanks for the Cucumber test recommendation. I did run it on the app. Great testing sequence many test were successful but those related to the Stripe issue had problems, results below: (all are related to the Stripe_ token not present) Failing Scenarios: cucumber features/users/sign_up_with_stripe.feature:11 # Scenario: With valid card data cucumber features/users/sign_up_with_stripe.feature:26 # Scenario: With invalid card number cucumber features/users/sign_up_with_stripe.feature:41 # Scenario: With invalid card security code cucumber features/users/sign_up_with_stripe.feature:56 # Scenario: With declined card cucumber features/users/user_delete.feature:13 # Scenario: I create a new subscription and delete my account

DanielKehoe commented 10 years ago

We can assure you that the problem is not present in the reference implementation (the example app), as many people are using it without problem. That means it is a local configuration issue. You'll need to examine the HTTP request and response. You can use an HTTP sniffer/debugger like http://tuffcode.com/ (Mac) or http://fiddler2.com/ or http://www.wireshark.org/.

billvieux commented 10 years ago

The first thing is to look at your logs just above what you pasted into this issue above. You should see the standard Rails logging. It will be something like this if you are trying to create a new user/subscription.

Started POST "/users" for 127.0.0.1 at 2013-10-09 22:32:52 -0700
Processing by RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"84vWz0q/Twp/LqsAj8S3KMQr8c4Rc3SUwtiULUxd3i4=", "plan"=>"silver", "user"=>{"name"=>"user", "email"=>"user@example.org", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "coupon"=>"", "stripe_token"=>"tok_123456789"}, "commit"=>"Sign up"}

If the stripe_token does not have a value, then you are not getting the token inserted properly into the form for submission. If you haven't changed the new.html.erb or registration.js files, then you are probably having an issue getting/running the Javascript from Stripe.

For me, the most common reason is lack of network connectivity. If you don't have a network connection, the page won't be able to download the required Javascript from Stripe. It is easy to check this using something like the Developer Tools Console in Chrome. Without the Javascript, registration.js cannot create a token or insert it into the right form element for submission to the server.

Another, less likely, possible reason is that there is an SSL error connecting to Stripe. If you use Fiddler2 with the option to decrypt HTTPS traffic, but don't have the Fiddler root certificate trusted, the browser won't be able to download the Javascript from Stripe.

seei2i commented 10 years ago

Thanks for the information. The problem was related to the registration.js not getting to load because of an error on a script that loads before it. The section in the tutorial on testing the JQuery loading was very helpful in solving the problem. The JQuery depreciation of .live() to .on() on the other script kept the stripe script from loading. It was in a different part of the app I am developing. When the other script triggered the error, the registration.js never loaded. After I updated this section of code, it all worked. Thanks for the help.

DanielKehoe commented 10 years ago

Glad you were able to resolve the issue. Thanks for pointing out an issue other users may encounter.