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

masonfox's avatar

Spark Stripe Not Working

With modifying and adding my test credentials to my local .env file, I get this error anytime I try and do anything billable:

Uncaught Error: You are using a secret key with Stripe.js, instead of the publishable one. For more info, see https://stripe.com/docs/stripe.js

I followed the docs and tried to add my key, but it still didn't work. Any help?

0 likes
6 replies
ahuggins's avatar

It looks like you are publishing your secret key instead of the publishable key. What does the code look like for how you are preparing and sending the code to Stripe?

Maybe you have the keys reversed in the env file?

christian_H's avatar

@masonfox It looks like you're using the same key with both, but the STRIPE_KEY and STRIPE_SECRET should be two different values. If you go to your Account Settings in Stripe and go to the "API Keys" tab, then it should have yours listed. The "Secret Key" should be assigned to the STRIPE_SECRET variable and the "Publishable Key" goes with the STRIPE_KEY. You'll actually have two pairs of keys, one for test and one for production, so make sure you use the right pair for your needs.

ahuggins's avatar
ahuggins
Best Answer
Level 51

All the stripe tokens start with either two strings:

sk_test_

or

pk_test_

The sk_test is the one that needs to be in your STRIPE_SECRET field and the pk_test one is the STRIPE_KEY. And yes you need to be using the Test api keys if your Stripe account is in test mode and the Live ones if it is in live mode.

I think that error is suggesting that you have the sk_test key in your STRIPE_KEY value.

ahuggins's avatar

Yeah, it would be nice if Stripe had their keys like secret_test_dkfjbnvsdkjfbnsdkfgjbn and public_test_dkfvjnsdkfjbnfgdk would be a lot more clear as to which one is secret/public.

Please or to participate in this conversation.