【问题标题】:Rails & Heroku & StripeRails & Heroku & Stripe
【发布时间】:2019-06-03 14:53:37
【问题描述】:

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

在 Heroku 上:

卡输入丢失:

在本地主机上:

我认为是 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 上按下提交按钮:

感谢您的宝贵时间。

更新:

我有多个,因为我尝试了很多东西。

【问题讨论】:

    标签: ruby-on-rails stripe-payments


    【解决方案1】:

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

    请参阅 this answer 了解有关如何执行此操作的一些想法。

    【讨论】:

    • 我更新了我的问题。我相信我有 heroku 的钥匙。
    猜你喜欢
    • 2015-11-16
    • 2013-11-04
    • 2013-09-13
    • 2013-08-13
    • 2012-04-28
    • 2017-06-16
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多