Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Live payment keys on staging taking real money: how to fix it

OPS-210High impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A staging site is a private copy of your website used to try changes before they go live. When you clone a live site, the copy often brings along its settings, including the live API keys for Stripe, PayPal, Square or another gateway. A live key tells the gateway to move real money. A test key (also called sandbox) only simulates it.

Why it costs you leads or sales

Real charges on a site that is not your shop create refunds, chargebacks and angry customers. Staging orders also rarely reach your fulfilment flow, so a person pays and gets nothing. Gateways can treat a spike of refunds or disputes as a risk signal, which can lead to holds or reviews on your account.

How a staging test becomes a real charge
  1. Clone live to stagingSettings and keys are copied too
  2. Tester places orderUses a real card or a customer finds the URL
  3. Gateway uses live keyReal money is taken
  4. Refunds and disputesNo product shipped, reports polluted

The break happens at the copy step, before anyone tests anything.

How to check if your site has it

Check the keys, not the checkout. Placing a test order to find out is exactly how the problem happens. Live keys start with pk_live_ and sk_live_ on Stripe. Test keys start with pk_test_ and sk_test_.

Quick checks
  • Open the payment plugin or app settings on staging and look for a test mode or sandbox switch
  • Look at the publishable key in the page source of the staging checkout: search for pk_live_ or pk_test_
  • In your gateway dashboard, open Payments and filter by the last days: look for charges with unfamiliar amounts or your staging domain in metadata
  • Check webhook endpoints in the gateway: is a staging URL registered against live mode?
  • Ask your team whether anyone has tested a checkout on staging recently
  • Check that staging is hidden from search engines and public visitors
Search a staging codebase for live Stripe keysbash
grep -rIn --exclude-dir=node_modules --exclude-dir=.git -E "(pk|sk|rk)_live_" .

How to fix it

Fix it in order
  1. Stop the damage

    Put staging behind a password or take it offline until the keys are changed.

  2. Refund real charges

    In the gateway dashboard, find charges made from staging and refund them.

  3. Swap in test keys

    Replace live keys on staging with test or sandbox keys from the gateway's developer section.

  4. Rotate keys if they leaked

    If staging was public or the keys were shared widely, roll the live secret key in the gateway dashboard and update your live site.

  5. Fix webhooks

    Make sure staging uses a test-mode webhook endpoint and the live endpoint points only at the live site.

  6. Block the staging URL from the public

    Add password protection or an IP allowlist so real customers cannot reach it.

Where to change the keys
  1. WooCommerce Stripe

    Go to WooCommerce > Settings > Payments > Stripe, turn on Test mode and enter the test keys.

  2. PayPal

    In WooCommerce > Settings > Payments > PayPal, enable sandbox and use sandbox credentials.

  3. Lock the keys in code

    Where your plugin supports it, define keys in wp-config.php on staging only so a database copy cannot overwrite them.

Staging payment setup

Before

  • Live keys copied from production
  • Live webhook can be hit from staging
  • Staging URL open to anyone
  • Test orders charge real cards

After

  • Test keys only on staging
  • Separate test-mode webhook
  • Staging behind a password
  • Test orders use gateway test cards

How to confirm it's fixed

Confirm with a test card
  1. Check the key prefix

    View the staging checkout source and confirm the publishable key starts with pk_test_.

  2. Place a test order

    Use the gateway's documented test card number, for example Stripe's 4242 4242 4242 4242.

  3. Check the right dashboard

    The payment should appear in the gateway's Test data view, not in live Payments.

  4. Check the side effects

    Confirm no real email, CRM record or ad conversion was created from the order.

How to prevent it happening again

Prevention checklist
  • Store keys in environment variables or a secrets manager, one set per environment
  • After every clone from live to staging, run a post-clone script that swaps in test keys
  • Password protect staging and set it to noindex
  • Register separate webhook endpoints for staging and live
  • Add a secrets scanner to your repository so live keys cannot be committed
  • Show a visible STAGING banner on the staging site
  • Review who has access to the live gateway dashboard

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard runs your real customer journeys on your live site on a schedule and checks steps, tracking and lead delivery. It does not inspect the configuration of a private staging copy or read your payment keys.

The kind of tool that fits is a secrets and configuration scanner (for example one that scans your repository and environment for live keys), together with the alerts and review features in your payment gateway dashboard, such as notifications for unexpected live charges. FunnelGuard is useful alongside them to keep watching your live checkout journey, and it stops before payment unless a store's test mode is set up.

Questions people ask

Why is my staging site charging real credit cards?

Your staging site is almost certainly using live payment keys copied from the production site. Any order placed with a real card then goes through the live gateway. Switch staging to test or sandbox keys and refund the real charges.

How do I know if my site is using live or test Stripe keys?

Check the key prefix. Live keys start with pk_live_ and sk_live_, and test keys start with pk_test_ and sk_test_. You can see the publishable key in the checkout page source, and both in the Stripe dashboard under Developers.

How do I stop staging from using live payment keys after I clone my site?

Keep keys in environment variables or a config file that is not copied with the database, and use a post-clone step that sets test keys. Hosts and plugins that offer a staging mode often have a setting to disable live payments on the copy.

Can I refund payments made by mistake on a staging site?

Yes. If the charge went through a live key, it appears in your gateway's live payments list, and you can refund it from there. Contact the customer to explain, since they may have already seen the charge.

Should I rotate my API keys if staging used live keys?

Rotate them if staging was public, shared with outsiders, or the keys were stored in a repository or chat. Roll the secret key in the gateway dashboard and update the live site with the new value.

Is it safe to test checkout on my live store with a real card?

It is better to avoid it. Use test mode and the gateway's test cards, or a development store. If you must run a real transaction, use a small amount and refund it straight away.

Does FunnelGuard detect live keys on staging?

No. This issue needs a different kind of tool, such as a secrets scanner or your payment gateway's alerts. FunnelGuard monitors live customer journeys, tracking and lead delivery.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.