Skip to main content

Testing your product before releasing to production

After integrating the Freemius SDK into your WordPress product, you should test it to ensure everything works properly before releasing a version to production.

Here is what Freemius recommends for testing the functionality and integration:

  • The opt-in process for the free version. This will be done when seperately installing after the generation of the free version zip file in the Deployment process, as the opt-in screen is only shown to users who have the free version of your product activated.
  • Free to Trial to Paid upgrades.
  • Directly Free to Paid upgrades with the in-dashboard upgrading.

You can test the payments process using:

  • The sandbox mode, which allows you to simulate transactions without processing real payments
  • A generated license key for testing by purchasing one in sandbox mode or by manually creating one in the Freemius Developer Dashboard.

Setting Freemius into Development Mode

During development and testing, add the following constant to your testing environment's wp-config.php file to display the Freemius Debug menu item. This will allow you to view all the Freemius data associated with your local environment.

/* Set Freemius into development mode */
define( 'WP_FS__DEV_MODE', true );
tip

These definitions are added under the WordPress debugging mode section before the WordPress Engine starts, i.e. before /* That is all, stop editing! Happy blogging. */ comment.

When you refresh the WP Admin, you should notice a new top-level menu item. If you click it, you will be able to see all the Freemius data associated with your local environment.

Important Warning

Activating development mode also sets the SDK for debugging, which, among other things, will turn the SDK's logging system on:

  • Logs are stored in the DB, so activating logging on a highly-active production site can quickly fill up the DB storage.
  • Logs are also printed out to the console log, so if a highly-active site utilizes a filesystem caching plugin while running in debug mode, the site’s disk may fill up quickly.

Therefore, do not forget to turn development mode off after completing troubleshooting.

Check out the WordPress Admin Pricing Page with Sandbox Payments

The Freemius WordPress SDK embeds a full checkout system that allows you to monetize your products via the Upgrade or pricing page. This checkout process can be fully tested in a sandbox environment before going live.

To set Freemius Checkout to sandbox payment mode, make sure your wp-config.php file contains the following constant with your secret key:

/* Set Freemius into development mode */
define( 'WP_FS__DEV_MODE', true );

/*
* Set your plugin / theme Freemius secret key for super powers!
* 1. Replace `my-slug` with your product's lowercase slug.
* 2. Replace `sk_mySecretKey` with your product's secret key.
*/
define( 'WP_FS__my-slug_SECRET_KEY', 'sk_mySecretKey' );

With this setup, choose the desired plan from the pricing page. When the Checkout appears, complete the payment using these credit cards and PayPal accounts in sandbox mode.

Generating a License Key for Testing

You can generate a license key for testing by purchasing one in sandbox mode or by manually creating one in the Freemius Developer Dashboard.

Follow these steps to create a license key in the Freemius Developer Dashboard:

  1. Navigate to the Licenses page.
  2. Click the Create License button.
  3. Follow the prompts to complete the process to create the license key.
  4. Use the generated license key to activate the premium features in your product during testing.

Skipping Email Activation

For security and data integrity reasons, if an already opted-in user attempts to opt in to Freemius again, you will first receive an activation email to complete the process. This helps prevent users from hijacking other user accounts.

However, this step might slow down the development and testing process. To skip it, add the following constant to your testing environment's wp-config.php file in addition to the previously added constants:

/* Skip email activation when a user with the same email already opted-in */
define( 'WP_FS__SKIP_EMAIL_ACTIVATION', true );