Cashier-stripe: No API Provided when using Stripe calls

Created on 13 Jun 2017  路  2Comments  路  Source: laravel/cashier-stripe

If I am doing a regular Stripe call (say for plans) like so in my controller:

public function enrollmentOptions(){

      $subscriptions  = Auth::user()->subscriptions;
      $plans          = \Stripe\Plan::all(array("limit" => 3));

      return view('user.enrollment-edit', [
        'user' => Auth::user(),
        'plans'=> $plans,
        'subscriptions' => $subscriptions
      ]);

    }

I get this error:
No API key provided. (HINT: set your API key using "Stripe::setApiKey(<API-KEY>)".

Is the env credentials I used not exposed to the stripe API when I use a default Stripe call? All the Cashier functions work fine (like Auth::user()->subscriptions).

Most helpful comment

Perfect. I wasnt sure the appropriate way, but in AppServiceProvider in the register function I just added :

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

All 2 comments

Set the apikey globally in a service provider :)

Perfect. I wasnt sure the appropriate way, but in AppServiceProvider in the register function I just added :

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jessehorne picture jessehorne  路  3Comments

pricop picture pricop  路  5Comments

Mr-Anonymous picture Mr-Anonymous  路  5Comments

adrianoGaspar picture adrianoGaspar  路  5Comments

4UForever picture 4UForever  路  3Comments