Laravel:Stripe没有提供API密钥. (提示:使用Stripe :: setApiKey()设置您的API密钥 [英] Laravel: Stripe No API key provided. (HINT: set your API key using Stripe::setApiKey()

查看:417
本文介绍了Laravel:Stripe没有提供API密钥. (提示:使用Stripe :: setApiKey()设置您的API密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道,那里有一个完全相同的问题,但是解决方案"未得到批准或指定.

Yes, I know, there is an exact same question there but the "solution" is not approved nor specified as it should.

所以: 1)我通过php composer安装了Stripe库v.3.0.pharrequire stripe/etc

So: 1) I installed the stripe library v.3.0 by php composer.phar require stripe/etc

并且安装成功,(否则我实际上不会收到该错误)

and it installed ok, (otherwise I wouldn't have actually received that error)

2)我在头部"部分的刀片表格中有公共测试密钥

2) I have the public test key in the blade Form in the Head section alright

3)然后,在控制器处,我包括了从窗体接收数据的公共函数内:(没问题,不是我的真实密钥)

3) Then at the controller I included inside the public function that receives the data from the Form the following: (no problem not my real secret key)

$token = Input::get('stripeToken');
Stripe::setApiKey("sk_test_1VJeJsdfsdgdgVbJODDDD");

3)我也将它放在.env文件中,作为

3) I also put it in the .env file as

STRIPE_API_SECRET='sk_test_1VJeJsvj7l2ft2eXXsevDD'

并以config/services.php的身份拨打电话

and made a call from the config/services.php as

'stripe' => [
        'model'  => App\User::class,
        'key'    => '',
        'secret' => env('STRIPE_API_SECRET'),
    ],

但我不断收到该错误.

SO的另一个相同问题是它已通过以下方式解决"了它:

The other same question at SO says that it has "solved" it by:

the solution was to put the stripe api key into AppServiceProvider, into register() class.

那完全是模糊的,不准确的,也不知道他在说什么.

That is completely vague, inaccurate and don't know what he is talking about.

有人知道吗?非常感谢你

Anyone knows? thank you very much

推荐答案

如果您查看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环境变量.

It wants either the static variable or the STRIPE_SECRET environment variable to be defined.

其他答案有点含糊,但提供了解决方案.在您的AppServiceProvider:

The other answer is a bit vague, but offers a solution. In your AppServiceProvider:

public function register()
{
    \App\Models\User::setStripeKey(\Config::get('services.stripe.secret'));
}

这篇关于Laravel:Stripe没有提供API密钥. (提示:使用Stripe :: setApiKey()设置您的API密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆