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

bigblueboss's avatar

Cashier and Stripe: No such token Error constantly!

I've gone down to my last bit of code. But something gets stuck here:

Route::post('charge', function(){
    $creditCardToken = Input::get('stripeToken');
    Auth::user()->newSubscription('pro', 'pro')->create($creditCardToken);
});

Instead of making the new subscription, I get this: No such token: tok_blablabla; a similar object exists in test mode, but a live mode key was used to make this request.

If i try to change the api key to the live secret key instead, then I get a very similar response, only this time it says that a similar object exist in the LIVE mode, but a test mode key was used to make this request.

Does anyone know what might be the issue here?

0 likes
9 replies
bigblueboss's avatar

@jekinney I thought you might be able to drop some knowldge in this situation. As well, it seems like google can't help me out much so far. T_T

ericlbarnes's avatar

When setting the LIVE or TEST mode you have to use both keys the public and secret. It sounds like you are mixing them up using one live and one test.

bigblueboss's avatar

@ericlbarnes you mean that you, you have to use either both publishable and secret LIVE or both publishable and secret TEST right?

I just tried again using TEST publishable and TESt secret keys and this is the error that i get.

No such customer: cus_7crThN4CGK3iSL; a similar object exists in live mode, but a test mode key was used to make this request.
bigblueboss's avatar

I'm definitely getting a token back from Stripe. I checked for that. But if I got the token from them, how could that token not work? I imagine this should always be working (it's like getting a key from someone, yet the key doesn't work for their home door)

1 like
ericlbarnes's avatar

That last error you got means you are using the correct keys now, but that the customer you are trying to charge was created in live mode. So if you clear their id in your db and go through the process again it should work by creating the customer in the proper mode and then charging.

1 like
0Sourabh's avatar

i am having a similar issue.. my laravel website is working fine now since i am integrating it, i am testing it on local server and testing stripe on test mode... on changing the test public and secret keys, when i do payment with test card details i get following error

No such token: tok_(genrated token); a similar object exists in live mode, but a test mode key was used to make this request.

i checked my logs on stripe api i get this:

Parsed Request POST Body:

source: "tok_********"(genrated token)
email: "h.men94@gmail.com"

Response body

error:
    type: "invalid_request_error"
    message: "No such token: tok_(genrated token); a similar object exists in live mode, but a test mode key was used to make this request."
    param: "source"
guycas's avatar

How did you manage to resolve this? I just spent 2 hours on chat with Stripe support and they couldn't figure out what's causing it. They said they'll pass it on to a specialist that will get back to me via email at some point(!?). Meanwhile I can process payments in test mode but going live (with the live keys) returns this error. They suggested it might be because I used the same plan names on both environments. They asked me to delete all the plans I created on both environments, create new ones with different names, I then updated the code, but no joy... Really not a great start with Stripe.

1 like
orrd's avatar

I ran into this issue also, and as Eric said, it has to mean that one of your keys is set to the wrong thing. There's a mismatch between your STRIPE_KEY and STRIPE_SECRET values. Make sure both of those are set to the right thing. For example, if one is set to your test environment and one is from your live environment, you'll get that "No such token" error.

Another way those can have the wrong value is if you're using something like Stripe.js, make sure that your Javascript is passing the right key to the Stripe() Javascript object.

Please or to participate in this conversation.