【问题标题】:Stripe - No API key provided (Laravel 5.1)Stripe - 未提供 API 密钥(Laravel 5.1)
【发布时间】:2015-11-23 15:23:54
【问题描述】:

我在提供 Stripe API 密钥时遇到问题。一切都包括在内,包,所有依赖项......

我收到的错误消息:未提供 API 密钥。 (提示:使用“Stripe::setApiKey()”设置您的 API 密钥。您可以从 Stripe 网络界面生成 API 密钥。有关详细信息,请参阅https://stripe.com/api,或发送电子邮件至 support@stripe.com,如果您有任何问题。

控制器:

    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');
        }

}

错误 SS:http://pokit.org/get/img/5f7886d0d9a50ecf349312225c8c47ea.jpg

【问题讨论】:

    标签: php laravel laravel-5 stripe-payments


    【解决方案1】:

    解决了

    Stripe 集成似乎在 Laravel 5.1 版本上不能正常工作,如果你遵循默认文档,你可能不会成功。

    在这种情况下,解决方案是将条带 api 键放入 AppServiceProvider 中,放入 register() 类中。

    【讨论】:

    • 不是必须放到config里吗?
    • @Volatil3 就像我说的,如果你按照默认的指令,你不会成功。是的,它说您需要放入配置文件,但其他解决方案是这样...
    • 5.1.10 似乎确实解决了这个问题。但是,我无法捕捉到 Stripe 错误。
    • @sk4yb3n 我已经在 AppServiceProvider 的注册函数中设置了 Stripe::setApiKey('pk_test_mytesting_key'); 但它也不起作用
    【解决方案2】:

    在我的 .env 文件中设置条带 API 密钥(对我有用,Laravel 5.8):

    STRIPE_KEY=your pk key here

    STRIPE_SECRET=your sk key here

    【讨论】:

      【解决方案3】:

      stripe.php 中设置 Stripe API 密钥

      public static $apiKey='sk_test_your api_key';
      

      【讨论】:

        猜你喜欢
        • 2021-05-25
        • 1970-01-01
        • 2015-11-16
        • 2017-01-18
        • 2014-06-23
        • 2020-04-24
        • 2015-12-09
        • 2017-05-31
        • 2017-10-25
        相关资源
        最近更新 更多