Stripe: No such token.. a similar object exists in test mode, but a live mode key was used to make this request

Julien picture Julien · Mar 9, 2015 · Viewed 24.5k times · Source

When using Stripe in live mode I get this PHP error:

No such token tok_fgfhn.. a similar object exists in test mode, but a live mode key was used to make this request

Everything works well in Stripe test mode, and and I've switched to a live API key.

I create a new customer like this:

$token  = $_POST['stripeToken'];
    $email  = $_POST['email'];

$customer = \Stripe\Customer::create(array(
      'email' => $email,
      'card'  => $token
    ));

    //charge for user ads
    $charge = \Stripe\Charge::create(array(
      'customer' => $customer->id,
      'amount'   => $amount,
      'currency' => 'eur'
    ));

I've tested many hours but I still get this error. How can I fix it?

Answer

Jake T. picture Jake T. · Oct 28, 2015

It sounds like you're trying to charge a customer who exists on your test account, not on your live account. Make sure you are making a new customer with your live keys and using their token to create the charge.