Stripe - No API key provided (Laravel 5.1)

我怕爱的太早我们不能终老 提交于 2019-12-24 11:26:17

问题


I have problem with providing the Stripe API key. Everything is included, packages, all dependencies...

The error message I get: No API key provided. (HINT: set your API key using "Stripe::setApiKey()". 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.

Controller:

    public function upgradeBronze() {

        $bid = Session::get('builderId');

        Stripe::setApiKey(env('KEY_SECRET'));
        $token = $_POST['stripeToken'];

        // Create the charge on Stripe's servers - this will charge the user's card

        try {

            $user = \App\User::find($bid);
            $user->subscription('monthly')->create($token);
            return Redirect::route('builders-packages');

        } catch(\Stripe\Error\Card $e) {
            return Redirect::route('builders-packages');
        }

}

Error SS: http://pokit.org/get/img/5f7886d0d9a50ecf349312225c8c47ea.jpg


回答1:


SOLVED

It seems that Stripe integration doesn't work fine on Laravel 5.1 version, if you follow the default documentation you probably won't succeed.

In this case the solution was to put the stripe api key into AppServiceProvider, into register() class.




回答2:


set the stripe api key from stripe.php Like public static $apiKey='sk_test_your api_key';




回答3:


Setting stripe API keys in my .env file (worked for me, Laravel 5.8):

STRIPE_KEY=your pk key here

STRIPE_SECRET=your sk key here



来源:https://stackoverflow.com/questions/32279966/stripe-no-api-key-provided-laravel-5-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!