Rails和Heroku和Stripe

时间:2019-06-03 14:53:37

标签: ruby-on-rails stripe-payments

在localhost上一切正常,但是在heroku上我遇到了一些错误。

在Heroku上:

enter image description here

缺少卡片输入:

enter image description here

在localhost上

enter image description here

我相信是带有Api密钥的东西,但我不明白自己做错了什么:

config/initializers/stripe.rb :


Stripe.api_key = Rails.application.secrets.stripe_private_key
StripeEvent.signing_secret = Rails.application.secrets.stripe_webhook_secret

StripeEvent.configure do |config|
  config.subscribe "charge." do |event|
    Webhooks::Charge.new(event).call
  end
end

secrets.yml:

development:
stripe_private_key: 'sk_test_*********'
stripe_public_key: 'pk_test_**********'
stripe_webhook_secret: 'whsec_**********'

在生产环境中,我使用了相同的测试键,因为我没有设置实时键

production:
stripe_private_key: 'sk_test_********'
stripe_public_key: 'pk_test_*********'
stripe_webhook_secret: 'whsec_*********'

如果我在heroku上按下“提交”按钮: enter image description here

谢谢您的时间。

更新:

enter image description here

我有很多,因为我尝试了很多事情。

1 个答案:

答案 0 :(得分:0)

您的secrets.yml文件在生产服务器上可能不存在。当然,它应该在您的.gitignore中,但是您需要确保这些秘密也可以在Heroku上找到。

有关如何执行此操作的一些想法,请参见this answer