#willys - stripe-php

1 messages ยท Page 1 of 1 (latest)

tribal hollow
#

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?

vale nacelle
#

yeah

#

a sec ๐Ÿ™‚

vale nacelle
#

<?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',
]);

tribal hollow
#

I don't expect that to work, you need to load the library either manually or with composer

#

see the installation instructions here:

vale nacelle
#

I did install it with composer

#

that's what makes me perplex ahah

tribal hollow
#

You script needs to actually load the library before using it

vale nacelle
#

makes perfect sens, it's my first time using stripe, it's a bit confusing from time to time

tribal hollow
#

no problem, hope that helped!

vale nacelle
#

yep now new error, it makes me happy

vale nacelle
#

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

tribal hollow
#

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

vale nacelle
#

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

tribal hollow
#

๐ŸŽ‰

vale nacelle
#

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

#

?

tribal hollow
#

That is unlikely to matter for the Config error

vale nacelle
#

oh okay, last question if you don't mind, is it fine if I leave my SK in my code?

tribal hollow
#

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.

vale nacelle
#

that's well copied, thank you fa lot or your help!

tribal hollow
#

NP! have a good one, and good luck with it ๐Ÿ™‚

vale nacelle
#

have a good one ๐Ÿ™‚

tribal hollow
#

<incoming template message ๐Ÿ˜„ >