1

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

sk4yb3n
  • 244
  • 1
  • 4
  • 9

3 Answers3

0

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.

sk4yb3n
  • 244
  • 1
  • 4
  • 9
  • Isn't it required to be put in config? – Volatil3 Sep 10 '15 at 18:41
  • @Volatil3 Like i said, If you follow the default instructions you won't succeed. Yes it says you need to put in config file, but other solution is this... – sk4yb3n Sep 13 '15 at 22:23
  • `5.1.10` does seem to resolve the issue. However, I can't catch Stripe error. – Volatil3 Sep 14 '15 at 02:02
  • @sk4yb3n I have set in register function of AppServiceProvider like `Stripe::setApiKey('pk_test_mytesting_key');` but it isn't working either – Awais Qarni Jan 08 '16 at 13:25
0

Set the Stripe API key from stripe.php like

public static $apiKey='sk_test_your api_key';
louisfischer
  • 1,968
  • 2
  • 20
  • 38
0

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

OlaJ
  • 608
  • 7
  • 15