是的,我知道,那里有一个完全相同的问题,但“解决方案”没有得到批准,也没有按应有的规定指定。
所以:
1)我通过 php composer.phar 安装了 strip 库 v.3.0 需要 strip /等
并且安装正常,(否则我实际上不会收到该错误)
2)我在头部部分的 Blade 表单中有公共(public)测试 key
3)然后在 Controller 中,我在从表单接收数据的公共(public)函数中包含以下内容:(没问题,不是我真正的 key )
$token = Input::get('stripeToken');
Stripe::setApiKey("sk_test_1VJeJsdfsdgdgVbJODDDD");
3)我也把它放在 .env 文件中
STRIPE_API_SECRET='sk_test_1VJeJsvj7l2ft2eXXsevDD'
并从 config/services.php 调用
'stripe' => [
'model' => App\User::class,
'key' => '',
'secret' => env('STRIPE_API_SECRET'),
],
但我不断收到该错误。
SO的另一个相同问题说它已经通过以下方式“解决”了它:
the solution was to put the stripe api key into AppServiceProvider, into register() class.
那是完全模糊的,不准确的,不知道他在说什么。
有谁知道?非常感谢你
最佳答案
如果您查看 Billable
代码:
/**
* Get the Stripe API key.
*
* @return string
*/
public static function getStripeKey()
{
return static::$stripeKey ?: getenv('STRIPE_SECRET');
}
/**
* Set the Stripe API key.
*
* @param string $key
* @return void
*/
public static function setStripeKey($key)
{
static::$stripeKey = $key;
}
它需要静态变量或
STRIPE_SECRET
要定义的环境变量。other answer有点模糊,但提供了一个解决方案。在您的
AppServiceProvider
:public function register()
{
\App\Models\User::setStripeKey(\Config::get('services.stripe.secret'));
}
关于laravel-5 - Laravel:Stripe 未提供 API key 。 (提示:使用 Stripe::setApiKey() 设置您的 API key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32552620/