开箱即用的Railscast

时间:2013-08-26 20:57:27

标签: ruby-on-rails stripe-payments railscasts

我是rails的新手,并尝试使用Stripe RailsCast进行结算(http://railscasts.com/episodes/288-billing-with-stripe)。我克隆了项目并从saas-after目录(https://github.com/railscasts/288-billing-with-stripe)构建了项目。

然后我在config / initalizers / stripe.rb中添加了条带测试凭据,并将订阅添加到我的条带帐户。我还构建了rails app:

 bundle
 rake db:setup
 rails s

当我输入有效的Stripe测试卡,即4242424242424242时,我仍然会收到验证问题。错误是:“您的信用卡出现问题。”如果我给了一张坏信用卡,即123,我会得到同样的错误。得到这个例子我错过了什么?

1 个答案:

答案 0 :(得分:0)

看看models/subscription.rb。这是添加此验证错误的位置。看起来Stripe不喜欢你发送的请求。你为什么不尝试通过打印错误来调试它?

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."
  ...

(如果你使用pry-debugger,那么将binding.pry语句放在puts e当前所在的位置是个好时机。)。