Cannot redeclare class Stripe\Stripe

When installing WP Full Stripe results in a fatal error this article can help you resolve the issue.

What happened?

You are installing WP Full Stripe, and Wordpress displays one of the following fatal errors:

“Fatal error: Cannot redeclare class Stripe\Stripe in /wp-content/plugins//classes/stripe/lib/Stripe.php on line 6”

“Fatal error: Another plugin has loaded an incompatible Stripe API client. Deactivate all other Stripe plugins, and try to activate Full Stripe again.”

Why is it happening?

WP Full Stripe loads its own copy of the Stripe PHP client library, and another plugin tries to do the same, and PHP throws an error.

The error is the result of a fundamental flaw in WordPress’ design: there is no central management for PHP libraries used by several plugins.

What is the solution?

There are cases when this issue can be resolved, in other cases there is no solution. It depends on the Stripe PHP client library versions required by the conflicting plugins, and on the loading order of the plugins.

You can resolve the issue (if possible) by taking the following steps:

  1. Find out the PHP client library required by WP Full Stripe
  2. Find out the PHP client library required by the other plugin
  3. Determine the loading order of the conflicting plugins

1. Find out the PHP client library required by WP Full Stripe

WP Full Stripe defines the version number in the wp-full-stripe.php file in the root of the plugin directory, you just have to find the WP_FULL_STRIPE_API_VERSION constant in the file (see last line of the code snippet):

2. Find out the PHP client library required by the other plugin

For the other plugins, the safest bet is to find the VERSION file in the Stripe PHP library directory.

3. Determine the loading order of the conflicting plugins

The loading order is determined by the alphabetical order of the plugin slugs.

Decision matrix based on your findings

Armed with the version numbers and loading order, consider the following cases:

  1. The other plugin is loaded first, and it requires an older Stripe version than WP Full Stripe
    In this case there is no solution. The oher plugin has to load the Stripe library, but it will be too old for WP Full Stripe.

  2. The other plugin is loaded first, and it requires a newer Stripe version than WP Full Stripe
    This might work, you have to comment out loading the Stripe library in the /wp-full-stripe.php file in the root folder of WP Full Stripe (see next section).

  3. WP Full Stripe is loaded first, and it requires an older Stripe version than the other plugin
    In this case there is no solution. WP Full Stripe has to load the Stripe library, but it will be too old for the other plugin.

  4. WP Full Stripe is loaded first, and it requires a newer Stripe version than the other plugin
    This might work, you have to comment out loading the Stripe library in the other plugin.

How not to load the Stripe PHP client library of WP Full Stripe

You have to comment out the code which verifies the version number of the Stripe PHP library if it’s already loaded.

It’s in the wp-full-stripe.php file:

Comment out the statements in the “else” block:

IMPORTANT: WP Full Stripe installations using a Stripe PHP library versions other than the exact version required by the plugin are not supported by Mammothology.

Still not finding the solution?

Our support team is happy to help you.

Contact support

Feature requests are always welcome!
We consider each feature request carefully, and examine how it fits the roadmap for the plugin.