Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tealiedie's avatar

Stripe. No API key provided

Hello. i'm using Laravel 5.1.45 and i tested stripe billing perfectly on my local. it is working until i deployed it on my staging server. it says

No API key provided. (HINT: set your API key using "Stripe::setApiKey(<API-KEY>)". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email [email protected] if you have any questions.

i also tried to adding Stripe::setApiKey to AppServiceProvider but no luck

i'm only using test key

0 likes
7 replies
tealiedie's avatar

@bugsysha yes. i added keys to my .env file also i manually set the keys to config.services.stripe

bugsysha's avatar
bugsysha
Best Answer
Level 61

Paste code where you create requests from backend.

Have you tried?

php artisan config:cache
4 likes
tealiedie's avatar

this is my clientside script

var start = function() {
      Stripe.card.createToken({
        number: $form.find('[name="cc_number"]').val(),
        cvc: $form.find('[name="cc_cid"]').val(),
        exp_month: $form.find('[name="cc_exp"]').val().split('/')[0],
        exp_year: $form.find('[name="cc_exp"]').val().split('/')[1]
      }, stripeResponseHandler);
    },
    stripeResponseHandler = function(status, response) {
      console.log(response);
      if (response.error) {
        $('.alert-container').append('<div class="alert alert-danger" role="alert">'+
          '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
          '<strong>'+response.error.code+'</strong>'+
          '<span class="message">'+response.error.message+'</span>'+
        '</div>');
      }
      else {
        $form.find('[name=stripe_token]').val(response.id);
        $form.submit();
      }
    };

and this is my server side code

$subscription = 'monthly_payment'
$premium->subscription($subscription)->create($token, [
      'email' => $email,
    ]);
tealiedie's avatar

yes iv'e tried cache:clear also route:clear

bugsysha's avatar

Glad it works. Please select it as a correct answer so others can see that and try when they have the same problem.

Please or to participate in this conversation.