我是rails的新手,正在尝试使用条带RailsCast进行计费(http://railscasts.com/episodes/288-billing-with-stripe)。我克隆了该项目,并从saas-after目录(https://github.com/railscasts/288-billing-with-stripe)构建了该项目。
然后,我在config/initalizers/stripe.rb中添加了我的条带测试凭据,并将订阅添加到我的条带帐户。我还构建了rails应用程序:
bundle
rake db:setup
rails s当我输入有效的条纹测试卡时,例如4242424242424242,我仍然会遇到验证问题。错误是:“你的信用卡有问题。”如果我给了一张坏的信用卡,我会得到同样的错误,例如123。为了让这个例子上线,我错过了什么?
发布于 2013-08-27 05:06:31
看看models/subscription.rb吧。这就是添加此验证错误的地方。看起来条纹不喜欢你发送的请求。为什么不试着通过打印错误来调试它呢?
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."
...(如果使用撬动调试器,这将是在puts e当前所在的位置放置binding.pry语句的好时机;)。
https://stackoverflow.com/questions/18452893
复制相似问题