#oranges13
1 messages ยท Page 1 of 1 (latest)
๐
Hello ๐
This has been a nightmare
Sorry to hear. I am surprised that this seems to be happening because of expansion. So if you remove the expansion argument your original key gets used?
Unsure. It's extremely inconsistent ๐ฆ
Which also doesn't make sense because code shouldn't have moods
That is my best guess as to why this may be happening.
A better example I just got repeated failures to create an invoice item
Do you have a snippet of code that consistently gets this error?
We were doing InvoiceItem::create($parameter_array, ['idempotency_key' => 'something']); which would repetatedly fail
So if you have code that just sets up stripe and then makes that call, will that fail?
So this in Laravel
we have the api key set up in our App Service Provider which is supposed to be globally available to evrything
so the api key should never be UNSET
in fact I can echo it out immediately before the call, but the call still fails
I even added \Stripe\Stripe::setAPIKey immediately before the call as well
so it must be something to do with us using the legacy format ๐ฆ
Still looking in to what might be happening here. Can you make a standalone snippet of code that gets this error?
Sure. The one that was failing most often just now is
\Stripe\Customer::retrieve(['id' => 'customer_id', 'expand' => ['default_source']]);
repeatedly and consistently
I mean a little more than that. Like a few lines of code with your keys redacted where I can copy-paste in to a file, swap in my keys and get the error
ah. Well like I said, it's Laravel -- so the api key is set in a different file ๐
Also to answer your quick fix question. You can set it as api_key=sk_test_... in an array after the other arguments you pass in https://github.com/stripe/stripe-php#per-request-configuration
But also we were having this problem before and we weren't using an expand array, it shoul have been straight up Invoice::retrieve('in_id') nd that was failing rather frequently too
Does that 3rd array format work with the old style too? I think that's where we might be getting hung up since we can't immediately migrate to the client/service syntax ๐ฆ
I think that may be the root of all this unfortunately
Whoops, I mixed up the old and new syntaxes for a moment. I will look for an equivalent in the older syntax
Thanks I think that will help a ton ๐
Found the older version so it looks like you might just need to pass in that last hash https://github.com/stripe/stripe-php/tree/dccb1358867985440dc8c370dc4ac81daa8a6a21#per-request-configuration
how would we mix that with an expand? Is it the same array or do we do an array for the first parameter too?
I do not know enough PHP syntax to guess and my local project seems to be broken at the moment. From the docs I would guess you should make this separate and put it after the expand arg
If that doesn't work, put it in the same array
๐ it should go in the same array. You can see examples of the legacy vs. the client/service approach here: https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0