Why Did Staging Charge Real WooCommerce Renewals?
Why This Happens
Cloning a WordPress site for staging typically copies the entire database, including live payment gateway API keys, stored customer payment tokens, and every pending Action Scheduler entry for subscription renewals. Nothing about a database clone inherently marks it as "not the real site" — if WP-Cron or a server cron job is active on that staging copy and a renewal happens to be due, it fires exactly as it would in production, using the real gateway credentials it inherited.
This has caught out experienced WooCommerce developers, not just beginners — it's a structural risk in how staging environments are typically created, not a sign of doing something obviously wrong.
Common Causes
- A full database clone without disabling cron on the staging copy before or immediately after the clone completes.
- Staging hosting plans that enable WP-Cron by default with no obvious warning that live payment credentials came along with the database.
- Payment gateway plugins storing live API keys in the database rather than in an environment-specific config file that wouldn't transfer with a simple clone.
- A staging site left running long-term rather than torn down promptly, increasing the window in which a scheduled renewal could fall due.
How to Prevent It
- Disable WP-Cron immediately after cloning to staging, before doing anything else — add
define('DISABLE_WP_CRON', true);to the staging site'swp-config.phpas the very first step. - Switch payment gateways to test/sandbox mode on the staging copy, using sandbox API keys rather than the live account's credentials, so even an accidental charge attempt can't touch real money.
- Use a staging tool that automatically handles this — many managed WordPress hosts' staging features switch gateways to test mode or disable cron by default specifically because of this risk; confirm your host's actually does before relying on it.
- If a staging site already ran with cron active, check WooCommerce → Status → Scheduled Actions on it immediately and check the live site's actual order/subscription records for any charges that shouldn't exist.
- If a real customer was charged from a staging environment, that needs an immediate refund and, if there's a pattern of the same failure recurring, a proper audit of how staging environments get created going forward.
If this has already happened and needs auditing or a hardened staging workflow going forward, see WooCommerce fixes.