I am struggling with this error. An API key is not provided. Set the API key using "Stripe.api_key =". You can create API keys from the Stripe web interface in the Rails application after the following steps: Stripe guide .
From what I see, everything looks good, but he continues to return this notification. Any tips?
Payment controller:
class ChargesController < ApplicationController def new end def create # Amount in cents @amount = 500 customer = Stripe::Customer.create( :email => ' example@stripe.com ', :card => params[:stripeToken] ) charge = Stripe::Charge.create( :customer => customer.id, :amount => @amount, :description => 'Rails Stripe customer', :currency => 'usd' ) rescue Stripe::CardError => e flash[:error] = e.message redirect_to charges_path end end
configurations / Initializers / stripe.rb
Rails.configuration.stripe = { :publishable_key => ENV['pk_test_KEY'], :secret_key => ENV['sk_test_KEY'] } Stripe.api_key = Rails.configuration.stripe[:secret_key]
Terminal route Started POST "/ charges" for 127.0.0.1 at 2014-12-12 22:15:08 +0100
Processing by ChargesController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXX", "stripeToken"=>"tok_1590kf2NNSl5uX0kXE9XXX", "stripeTokenType"=>"card", "stripeEmail"=>" USER@gmail.com "} Completed 500 Internal Server Error in 2ms Stripe::AuthenticationError - No API key provided. Set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https:
Tested, including keys in secrets.yml, as @sealocal suggests in the comments, but still the same problem:
development: secret_key_base: key publishable_key: anotherkey secret_key: anotherkey test: secret_key_base:key production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> publishable_key: <%= ENV["publishable_key"] %> secret_key: <%= ENV["secret_key"] %>
ruby-on-rails stripe-payments
malditojavi
source share