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
Nil api key causing exception with Stripe 1.20.4 #209
Comments
same problem |
Having the same problem. |
I think I have a somewhat similar problem. In various methods in my code I use things like: customer.subscriptions.retrieve({SUB_ID}) I am using this gem to test the methods that then make these API calls to Stripe. The ones for create customer/subscription/plan are working fine without the api_key, but all of the calls to the retrieve methods (listed above) are failing with the following error and I don't want to have to add the api_key since this is only a problem for my tests: TypeError: api_key must be a string. |
+1 same problem |
Anyone found solution to that? I have the same problem as described above with retrieving from Stripe. |
I still haven't figured out a solution to that issue. |
+1 |
1 similar comment
+1 |
👍 @jasonrhalpern There's an alternative solution in the original post, if you need it quickly. |
Similar to what @crberube mentioned, you can (for now) make your call with the api_key stripe_customer.sources.retrieve(stripe_card_id, {api_key: Stripe.api_key}) |
you can use branch https://github.com/rebelidealist/stripe-ruby-mock/tree/stripe-1.21.0 |
Thanks for the help on this guys, I'll probably use the older branch for the time being. I don't really want to have to modify the stripe code that I am testing by adding the api_key since doing so would only be necessary for the tests to pass and not for the actual implementation. |
@alexmamonchik Is this fix in the roadmap? I can go change all my tests to use the syntax suggested by @crberube , but that doesn't seem to be a long term solution. |
@moneytree-doug |
+1 Same problem here with let(:stripe_helper) { StripeMock.create_test_helper }
before do
Stripe.api_key = 'blablabla'
StripeMock.start
end
after { StripeMock.stop } |
+1 |
I was having the same issue but with the So in my specs, I wrote the following:
And used it like so:
Hope this helps. |
@HunterMeyer try to get code from repo instead of rubygems |
Wanted to point out this issue that I noticed even though stripe-ruby-mock is only supporting stripe 1.20.1 as of now.
As of the following PR stripe/stripe-ruby#221 stripe raises a TypeError when it receives an api_key in the options that is not a string. In the mock_request method of StripeMock::Instance, api_key is a required parameter that is nil by default, thus raising an exception unless an api key is explicitly passed.
As an example, the following code raises a TypeError:
while this code works as expected:
The text was updated successfully, but these errors were encountered: