我試圖從條紋網站使條紋校驗樣品工作有效發佈的按鍵,但沒有得到有效發佈的按鍵設置
https://stripe.com/docs/checkout/rails
,但是當我試圖付錢,我收到此錯誤信息。
您沒有設置有效的可發佈密鑰。用您的可發佈鍵調用 Stripe.setPublishableKey()。欲瞭解更多信息, 看到https://stripe.com/docs/stripe.js
在我的JavaScript控制檯錯誤信息是
https://checkout.stripe.com/api/bootstrap?key=&locale=en-US未能 加載資源:服務器迴應400(錯誤請求)的狀態
在我的控制檯錯誤信息是
入門使用「/」爲10.240.1.15在2016年10月19日17點29分24秒+0000不能 從10.240.1.15渲染控制檯!允許的網絡:127.0.0.1 :: 1, 127.0.0.0/127.255.255.255由ChargesController處理#new as HTML在佈局/應用程序中渲染費用/new.html.erb(0.5ms) 在53ms內完成200 OK :52.6ms | ActiveRecord:0.0ms)
當我檢查我的html源代碼stripe-key元標記沒有任何內容?
條紋樣本使用他們自己的祕密和可發佈的鍵,但我使用我的。
請,如果需要更多的信息,問,所以我可以發佈。
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Workspace</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'https://js.stripe.com/v2/' %>
<%= csrf_meta_tags %>
<%= tag :meta, :name=> 'stripe-key', :content => ENV["STRIPE_PUBLIC_KEY"] %>
</head>
<body>
<%= yield %>
</body>
</html>
charges.html.erb
<head>
</head>
<body>
<%= yield %>
</body>
</html>
stripe.js
$(document).ready(function() {
Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'));
});
stripe.rb
Rails.configuration.stripe = {
:publishable_key => ENV['PUBLISHABLE_KEY'],
:secret_key => ENV['SECRET_KEY']
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
你託管Stripe.js? – korben
@Korben我顯示我的stripe.js內容。我不知道更多 –
在stripe.rb中,您將可發佈鍵設置爲'ENV ['PUBLISHABLE_KEY']',但在您的元標記中它是'ENV [「STRIPE_PUBLIC_KEY」]' - 如果您使用'<%= tag:meta,:name =>'stripe-key',:content => ENV [「PUBLISHABLE_KEY」]%>'? –