“No such token” error message

Problem statement

When a customer tries to make a payment on a one-time payment form or on a subscription form, an error message similar to this one is displayed:

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

The solution

Either of the following scenarios can cause the error:

  1. Several Stripe plugins are activated, and one of them is in live API mode, and the other one is in test API mode (or vice versa).
  2. The payment page is cached, and it’s storing the live publishable key while the plugin is in test mode (or vice versa)

The solution is easy in both cases:

1) Several Stripe plugins are activated
Make sure that all Stripe plugins are in the same API mode.

Ideally, WP Full Stripe should be active, and you should deactive all other Stripe plugins.

2) The payment page is cached, the wrong publishable key is stored
When you change API mode, always purge the cache.

Ideally, you should add a rule to the cache to not cache the payment page at all.

in Troubleshooting