I'm trying to store my API keys for Stripe Elements..You can see my previous post here: Using javascript for Stripe Elements
As you can see, the Stripe Elements isn't showing up with the JS from Stripe or my stripejs.js file.
I am assuming its the https://js.stripe.com/v3/ that's not showing up somehow due to my API keys not storing correctly. I currently have my API keys stored in my .env file managed by the dotenv gem
I'm trying to store my API keys with credentials.yml.enc but not sure if I am doing it correctly.
What I do:
Call "EDITOR=atom rails credentials:edit" in CMD. Atom pops up. I store API keys the following way: PUBLISHABLE_KEY = pk_test_1111111111111111111 SECRET_KEY = sk_test_11111111111111111111
Save the file. Exit.
Although, it won't work. Am i not storing it correctly? Doing something wrong?
In my stripe.rb file under initializers is:
Rails.configuration.stripe = {
:publishable_key => ENV['PUBLISHABLE_KEY'],
:secret_key => ENV['SECRET_KEY']
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
Edit:
I have my stripe.rb file structured like this:
Rails.configuration.stripe = {
:publishable_key => Rails.application.credentials.stripe[:publishable_key],
:secret_key => Rails.application.credentials.stripe[:secret_key]
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
and then saved my credentials files like this:
stripe:
publishable_key: 123456789
secret_key: 123456789
I then receive the error when starting my servier:
undefined method \credentials' for Rails:Module (NoMethodError)`
Is there something wrong I'm doing?
Attempt: 2:
I tried doing in the stripe.rb file...
Rails.configuration.stripe = {
Rails.application.credentials.stripe[:publishable_key],
Rails.application.credentials.stripe[:secret_key]
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
with and withou tthe last time... I get the error: "syntax error, unexpected '}', expecting end-of-input"
UPDATE:
in case anyone comes across this with a similar issue...
For me, it was bootstrap causing the problems. All you need to do is use class="form-control" within the Stripe Elements form for it to display correctly - if you're using Bootstrap.