#willys - stripe-php
1 messages ยท Page 1 of 1 (latest)
Hey there, can you share the contents of your test_api file? (make sure to remove any keys)
Did you install stripe-php using composer?
<?php
use Stripe\Stripe;
\Stripe\Stripe::setApiKey(Config::get('stripe.secret_key'));
\Stripe\PaymentIntent::create([
'amount' => 1000,
'currency' => 'eur',
'payment_method_types' => ['card'],
'receipt_email' => 'jenny.rosen@example.com',
]);
I don't expect that to work, you need to load the library either manually or with composer
see the installation instructions here:
Ok, then you need to add the vendor autoload file:
require_once('vendor/autoload.php');
https://github.com/stripe/stripe-php#composer
You script needs to actually load the library before using it
makes perfect sens, it's my first time using stripe, it's a bit confusing from time to time
no problem, hope that helped!
yep now new error, it makes me happy
Fatal error: Uncaught Error: Class 'Config' not found in /home/tesst/www/test_api.php:6 Stack trace: #0 {main} thrown in /home/test/www/test_api.php on line 6
It sounds like the Config library you're using for manage the secret might not be loaded correctly either
you can try temporarily putting in your test mode secret key to see if the code works otherwise
then figure out your secrets management
do you think trying to update the files could help?
gonna try with the secret key first
with the secret key in place it worked just fine
๐
I remember having an alert saying that the version of stripe I was uploading was a little old when uploading it with composer
might be the reason why it doesn't work properly
?
That is unlikely to matter for the Config error
oh okay, last question if you don't mind, is it fine if I leave my SK in my code?
You need to make sure your secret keys are protected from being revealed publicly. You should use techniques for that suitable for your language/environment etc.
that's well copied, thank you fa lot or your help!
NP! have a good one, and good luck with it ๐
have a good one ๐
<incoming template message ๐ >