Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thisismyaim's avatar

Laravel + Stripe

I am looking at Stripe payment tutorial and follow as in video but got error :

No API key provided. (HINT: set your API key using "Stripe::setApiKey(<API-KEY>)". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.

with Laravel 5.1

If i use this code in charge function :

Stripe::setApiKey($this->app['config']['services.stripe']['key']);

also tried this :

Stripe::setApiKey(\Config::get('stripe.secret_key'));

Working fine but when use in __construct()

Got error above - can anyone tell me why ? also using namespace for Stripe\Stripe

0 likes
5 replies
MikeHopley's avatar

Weird.

I think you need to debug this a bit more yourself. Have you tried checking the value of the API key? For example:

public function __construct()
{
    $key = \Config::get('stripe.secret_key');
    dd($key);

    Stripe::setApiKey($key);
}
thisismyaim's avatar

still same error ;

is it effect if i am using static function ?

public static function charge(array $data)
thisismyaim's avatar

Actually i saw i am using static function but what if i want to use that ? otherwise i have to use this code :

$stripe = new StripeBilling();
    return $stripe->charge([
        'email' => 'thisismyaim@gmail.com',
        'token' => Input::get('stripeToken')
    ]);

and i want it simple like this :

return StripeBilling::charge([
        'email' => 'thisismyaim@gmail.com',
        'token' => Input::get('stripeToken')
    ]);

Thanks

Please or to participate in this conversation.