Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 364
Julien Avatar asked Mar 09 '15 22:03

Julien


People also ask

How do I change stripe live mode to test mode?

Go to Portal Settings > Payment Settings. Scroll down to Stripe Modes and ensure that the settings are set to test by clicking on the Test Mode button.

How do I turn off live mode on stripe?

When you're done testing, remember to deactivate Test Mode in Stripe before allowing users to submit payments in your form. You can do this by going to WPForms » Settings » Payments, as in the previous step. To enable Live Mode, scroll to the Stripe section and deselect the Test Mode checkbox.


1 Answers

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.

like image 147
Jake T. Avatar answered Sep 20 '22 10:09

Jake T.