问题
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