Out-of-the-box Railscast

266 Views Asked by At

I'm new to rails and trying to get the Billing w/ Stripe RailsCast up and going (http://railscasts.com/episodes/288-billing-with-stripe) . I am cloned the project and built the project from the saas-after directory (https://github.com/railscasts/288-billing-with-stripe).

I then added my stripe test credentials in config/initalizers/stripe.rb , and added the subscriptions to my stripe account. I also built the rails app:

 bundle
 rake db:setup
 rails s

When I enter a valid Stripe test card i.e. 4242424242424242 I'm still getting validation issues. Error is: "There was a problem with your credit card." Same error I would get if i gave a bad credit card i.e. 123 . What am I missing to get the example up?

1

There are 1 best solutions below

4
On

Look at models/subscription.rb. This is where this validation error is added. Looks like Stripe didn't like the request you sent. Why don't you try to debug it by printing the error?

def save_with_payment
  ...
rescue Stripe::InvalidRequestError => e
  puts e
  logger.error "Stripe error while creating customer: #{e.message}"
  errors.add :base, "There was a problem with your credit card."
  ...

(If you use pry-debugger this would be a good time to put a binding.pry statement in where the puts e is currently ;) ).