Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Stripe "You did not provide an API key" on donate form payment #1050

Closed
BenSturmfels opened this issue Mar 16, 2022 · 11 comments · Fixed by #1065
Closed

[BUG] Stripe "You did not provide an API key" on donate form payment #1050

BenSturmfels opened this issue Mar 16, 2022 · 11 comments · Fixed by #1065
Labels
bug Something isn't working

Comments

@BenSturmfels
Copy link
Contributor

After configuring my local development environment with STRIPE_API_KEY and STRIPE_API_PUBLIC and adding some puts into gems/bess/lib/houdini/engine.rb to verify tha the environment variables are being being read in, I'm seeing the a "You did not provide an API key" error on the donate form (screenshot below).

2022-03-17_10-01

From what I can see in the browser console, the Authorization: Bearer header is missing the the API key on the end, e.g. Authorization: Bearer XXX.

This is running against master in development mode, Ruby 2.7.4 and allowing assets to be built in-process (not a separate webpack process).

@BenSturmfels BenSturmfels added the bug Something isn't working label Mar 16, 2022
@BenSturmfels
Copy link
Contributor Author

(The Internal Server Error in my console are unrelated errors loading images caused by missing libvips.so.42)

@BenSturmfels
Copy link
Contributor Author

BenSturmfels commented Mar 23, 2022

If I modify bess like this:

diff --git a/gems/bess/lib/houdini/engine.rb b/gems/bess/lib/houdini/engine.rb
index ddb499f4..fc6ef5b0 100644
--- a/gems/bess/lib/houdini/engine.rb
+++ b/gems/bess/lib/houdini/engine.rb
@@ -34,6 +34,8 @@ module Houdini
     config.houdini.payment_providers.stripe = ActiveSupport::OrderedOptions.new
     config.houdini.payment_providers.stripe.public_key = ENV['STRIPE_API_PUBLIC']
     config.houdini.payment_providers.stripe.private_key = ENV['STRIPE_API_KEY']
+    puts config.houdini.payment_providers.stripe.private_key
+    puts config.houdini.payment_providers.stripe.public_key
     config.houdini.payment_providers.stripe.connect = false
     config.houdini.payment_providers.stripe.proprietary_v2_js = false

and start bin/rails server, I see my Stripe keys printed to the console.

Then if I modify _javascripts.html.erb like this:

diff --git a/app/views/layouts/_javascripts.html.erb b/app/views/layouts/_javascripts.html.erb
index 5c724dc5..4c8ba88d 100644
--- a/app/views/layouts/_javascripts.html.erb
+++ b/app/views/layouts/_javascripts.html.erb
@@ -8,6 +8,9 @@
   <%= javascript_pack_tag "page__stripe_wrapper" %>
 <% end %>
 
+<pre>Debug 1: <%= Houdini.payment_providers.stripe %></pre>
+<pre>Debug 2: <%= Houdini.payment_providers.stripe.public_key %></pre>
+
 <script>
 Stripe.setPublishableKey("<%= Houdini.payment_providers.stripe.public_key %>");
 window._csrf = "<%= form_authenticity_token %>";

and view the dashboard page, I see:

<pre>Debug 1: #&lt;Houdini::PaymentProvider::StripeProvider:0x00007f2d596e1b48&gt;</pre>
<pre>Debug 2: </pre>

That's unexpected, because I know that the public_key is in the system, but it's clearly not ending up where it's meant to.

@BenSturmfels
Copy link
Contributor Author

BenSturmfels commented Mar 23, 2022

If I forge ahead by temporarily hard-coding my Stripe public key directly into the template and submit the credit card form, the authorization header is all good and the POST to api.stripe.com succeeds, but I then get a 404 on http://localhost:5000/cards and Uncaught TypeError: resp is undefined. See screenshot:

2022-03-23_17-09

@BenSturmfels
Copy link
Contributor Author

If I do the same as above (temporarily hard-code public key) while logged into the dashboard, I get at error from the Stripe API:

Received unknown parameter: card[profile_id]"

@wwahammy
Copy link
Member

I think these are two separate issues. Would you be able to separate them?

@wwahammy
Copy link
Member

wwahammy commented Mar 25, 2022

@BenSturmfels This may relate to your second bug or it may not. #1066

@BenSturmfels
Copy link
Contributor Author

Sure, it may well be three separate issues, so I'll break them out. Just didn't want to create too much noise.

@BenSturmfels
Copy link
Contributor Author

Confirming that the "You did not provide an API key" issue is fixed by PR #1066. No change for the other two, but they're now in separate issues.

@wwahammy
Copy link
Member

@BenSturmfels: am I correct that we can close this issue?

@BenSturmfels
Copy link
Contributor Author

@BenSturmfels: am I correct that we can close this issue?

Yes can close. Up to you about the order of things, but I'd tend to wait until the PR is merged before closing the issue to avoid confusion.

@wwahammy
Copy link
Member

Ah, fair point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants