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).
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') );
Most helpful comment
Perfect. I wasnt sure the appropriate way, but in
AppServiceProviderin theregisterfunction I just added :\Stripe\Stripe::setApiKey( \Config::get('services.stripe.secret') );