#deputycheese_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
âąď¸ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1212675624783839232
đ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question. Thank you for your patience!
API key is used for server. Only one should be needed when making the request.
\Stripe\StripeClient('{api_key}')will initialise an stripe instance which can be further used in the subsequent API requestStripe::setApiKey('myapikey')is to set global API key
So StripeClient is used for checkout etc and setApiKey for the API to receive transactions etc?
No, you should use only one of them
Can you share how you use setApiKey in your API? There should be equivalent integration in StripeClient
I used this one for the CLI command too (works in checkout on the website): \Stripe\StripeClient('{api_key}')
Then I'm getting a "No API key provided." message
When I add Stripe::setApiKey('myapikey') it works via CLI too
The apikey is there and it is correct
Both above approaches are in PHP and it should be in the code of your server side. How do you use it in CLI command? Can you share an example code of what you're trying to do with both approaches?
Yes, they are
I am using it via CLI to retrieve balance transactions
BalanceTransaction::all
Authentication only works if I use Stripe::setApiKey here somehow
First authentication method I use for frontend/checkout stuff like paymentIntents->create
Can you share your full code of balance transaction retrieval?
$this->client->auth();
$arguments = [
'created' => [
'gt' => $startDate->format('U'),
'lt' => $endDate->format('U'),
],
'limit' => 100,
];
$transactionHistory = BalanceTransaction::all($arguments);
auth() looks like this:
$this->client = new \Stripe\StripeClient([
'api_key' => $this->stripeSecretKey,
'stripe_version' => '2020-08-27',
]);
Stripe::setApiKey($this->stripeSecretKey);
The last line (Stripe::setApiKey($this->stripeSecretKey);) I added to make it work via CLI too
Somehow api_key is ignored there, idk why
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
I don't understand what you mean by "CLI" here. What Stripe CLI has to do with PHP code? It's a standalone executable that has it's own way of setting API keys.
Yes of course
I am using different modes here (Symfony)
Calling it directly via symfony cli vs calling it via frontend php
It shouldnt really make a difference though
I don't know how your application is set up, so I can't judge here. But I know for sure, and what my colleague suggested, that you only need to set the API keys in one place. Is it's not the case, you app structure might not be organized correctly.