Bonaventure OgetoBy Bonaventure Ogeto|

Paystack Live Keys Rejected After Business Activation

If your live keys are rejected after business activation, the cause is one of these: you are still loading test keys from your environment variables instead of live keys, your activation is not fully complete (check for pending steps in the dashboard), you need to regenerate your live keys (activation sometimes requires a key refresh), your deployment platform is serving cached/stale environment variables, or you have the keys from a different Paystack account. Check the key prefix in your server logs, verify activation status in the dashboard, try regenerating the live key, and redeploy your server.

What Happens When Live Keys Are Rejected

You got the activation email. Your Paystack dashboard shows your business is active. You copy the live secret key, paste it into your environment variables, and make an API call. Paystack responds:

{
  "status": false,
  "message": "Invalid key"
}

Or in some cases, the API returns 401 Unauthorized without a JSON body. Either way, your live integration is dead on arrival.

This is confusing because the key is right there in the dashboard. You just copied it. But several things can go wrong between the dashboard and your server. Let's walk through each one.

Cause 1: Wrong Environment Variable (Most Common)

This is the cause in about 60% of cases. Your server is loading a different key than the one you think it is loading. There are several ways this happens:

You updated the local .env file but not the production environment. Your code reads process.env.PAYSTACK_SECRET_KEY, which works locally. But your production server on Vercel, Railway, or Render has the old test key in its environment variable settings.

You updated the wrong environment. Platforms like Vercel have separate environment variables for production, preview, and development. If you updated the "preview" environment but deployed to "production", the production server still has the old key.

Your variable name has a typo. You set PAYSTACK_SECRET_KEY in the platform but your code reads PAYSTACK_KEY or PAYSTACK_SECRET. The variable is undefined, and the API call sends an empty or malformed Authorization header.

The fix: Add a startup check that logs the key prefix.

// Add this to your server startup (index.js, server.js, etc.)
function checkPaystackKey() {
  const key = process.env.PAYSTACK_SECRET_KEY;

  if (!key) {
    console.error('PAYSTACK_SECRET_KEY is not set. Check your environment variables.');
    process.exit(1);
  }

  const trimmed = key.trim();
  const prefix = trimmed.substring(0, 8);
  const suffix = trimmed.slice(-4);

  console.log(`Paystack key: ${prefix}...${suffix} (length: ${trimmed.length})`);

  if (prefix === 'sk_test_') {
    console.warn('WARNING: Using TEST key. Switch to sk_live_ for live payments.');
  } else if (prefix === 'sk_live_') {
    console.log('Using LIVE Paystack key.');
  } else if (prefix.startsWith('pk_')) {
    console.error('ERROR: Using PUBLIC key as secret key. Use sk_live_ instead.');
    process.exit(1);
  } else {
    console.error(`ERROR: Unrecognized key prefix: ${prefix}`);
    process.exit(1);
  }

  if (trimmed.length !== key.length) {
    console.warn('WARNING: Key has trailing whitespace. Trimming.');
  }
}

checkPaystackKey();

This function runs once at startup. If the key is wrong, you see the problem immediately in your server logs instead of discovering it when a customer tries to pay.

Cause 2: Activation Is Not Fully Complete

Paystack activation has multiple stages. Your dashboard may show your business name and appear "active" to you, but there might be pending verification steps that block live payments.

Check for these signs of incomplete activation:

  • A yellow or orange banner at the top of the dashboard asking you to complete a step
  • The "Go Live" or "Activate" button is still visible somewhere in the dashboard
  • Under Settings > Business Settings, one or more fields show as "pending" or "unverified"
  • Your identity (BVN) verification is still processing
  • Your settlement bank account has not been verified

The fix:

  1. Log into the Paystack dashboard
  2. Go to Settings > Business Settings
  3. Check every section: Business Information, Owner Information, Bank Account, Documents
  4. Complete any section that shows as incomplete or pending
  5. If everything looks complete but live keys still fail, contact Paystack support at support@paystack.com and ask them to verify your activation status

Sometimes the dashboard shows everything as complete, but an internal verification step is still pending on Paystack's side. Support can confirm whether your account is fully active for live transactions.

Cause 3: Live Key Needs Regeneration

In some cases, the live keys generated before activation become stale. This can happen when:

  • The activation process triggers a key rotation internally
  • You copied the live key before activation was complete, and the key was regenerated during the activation process
  • Someone on your team regenerated the key and did not update the environment variables

The fix:

  1. Go to your Paystack dashboard
  2. Navigate to Settings > API Keys & Webhooks
  3. Click "Regenerate" next to the live secret key
  4. Copy the new key
  5. Update the key in all your environment variables (production, staging, CI/CD)
  6. Redeploy all services that use the key
# After regenerating, update everywhere:

# 1. Production environment (example with Vercel)
vercel env rm PAYSTACK_SECRET_KEY production
vercel env add PAYSTACK_SECRET_KEY production
# Paste: sk_live_new_key_here

# 2. Redeploy
vercel --prod

# 3. Verify the new key works
curl -H "Authorization: Bearer sk_live_new_key_here"   https://api.paystack.co/transaction?perPage=1
# Should return { "status": true, ... }

Remember: when you regenerate a key, the old key stops working immediately. Update all services as quickly as possible to minimize downtime.

Cause 4: Deployment Platform Caching Old Keys

You updated the environment variable on your deployment platform, but the running server is still using the old value. This happens because most platforms do not hot-reload environment variables. The server process reads environment variables at startup and keeps them in memory.

Platforms that require a redeploy after changing env vars:

  • Vercel: Environment variable changes require a new deployment. Changing a var does not automatically redeploy.
  • Railway: Changes trigger an automatic redeploy (you should still verify).
  • Render: Changes trigger an automatic redeploy.
  • Heroku: Changing a config var automatically restarts the dyno.
  • Docker: You must rebuild and restart the container.
  • PM2: You must restart the process: pm2 restart your-app

The fix: After updating the environment variable, force a redeploy. Then check your server logs to confirm the new key loaded.

// Your startup check (from Cause 1) will show you the key
// If the suffix doesn't match the new key, the old key is still cached

// Server startup output should show:
// "Paystack key: sk_live_...x9y2 (length: 40)"
// Compare the last 4 chars with the key in your dashboard

If you use Docker, make sure the new key is passed to the container:

# Docker: pass the key at runtime, not build time
docker run -e PAYSTACK_SECRET_KEY=sk_live_new_key_here your-app

# Do NOT bake the key into the Docker image with ENV in Dockerfile

Cause 5: Key from a Different Paystack Account

If you manage multiple Paystack accounts (personal, client, staging), you might have copied the live key from the wrong account. Account A's live key will return "Invalid key" when used with Account B's integration.

The fix:

  1. Open the Paystack dashboard for the correct business account
  2. Go to Settings > API Keys & Webhooks
  3. Compare the last 6 characters of the live secret key with the last 6 characters of the key your server is using
  4. If they do not match, you have the wrong key
// Quick check: compare the key suffix
const key = process.env.PAYSTACK_SECRET_KEY?.trim();
console.log('Key suffix:', key?.slice(-6));
// Go to the Paystack dashboard and compare this with the last 6 chars shown there

To prevent this in the future, label your environment variables with the account or project name:

# .env.production
# Account: YourCompany (business@yourcompany.com)
PAYSTACK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxx

# NOT just "PAYSTACK_SECRET_KEY" with no context about which account

Quick Diagnostic Script

Run this script on your production server to diagnose the exact problem. It checks every common cause in order.

// diagnose-paystack.js
// Run: node diagnose-paystack.js

async function diagnose() {
  console.log('--- Paystack Live Key Diagnostic ---\n');

  // Check 1: Key exists
  const key = process.env.PAYSTACK_SECRET_KEY;
  if (!key) {
    console.error('FAIL: PAYSTACK_SECRET_KEY is not set');
    console.error('Fix: Add the key to your environment variables');
    return;
  }
  console.log('PASS: Key exists');

  // Check 2: Whitespace
  const trimmed = key.trim();
  if (trimmed.length !== key.length) {
    console.warn('WARN: Key has whitespace (' + (key.length - trimmed.length) + ' extra chars)');
    console.warn('Fix: Trim the key or remove whitespace from your env var');
  } else {
    console.log('PASS: No whitespace');
  }

  // Check 3: Key type
  const prefix = trimmed.substring(0, 8);
  if (prefix === 'sk_live_') {
    console.log('PASS: Using live secret key');
  } else if (prefix === 'sk_test_') {
    console.error('FAIL: Using TEST key, not LIVE key');
    console.error('Fix: Replace sk_test_ key with sk_live_ key from dashboard');
    return;
  } else if (prefix.startsWith('pk_')) {
    console.error('FAIL: Using PUBLIC key, not SECRET key');
    console.error('Fix: Use sk_live_ key, not pk_live_ key');
    return;
  } else {
    console.error('FAIL: Unrecognized key format');
    console.error('Current prefix:', prefix);
    return;
  }

  // Check 4: API call
  console.log('\nTesting API call...');
  try {
    const res = await fetch('https://api.paystack.co/transaction?perPage=1', {
      headers: { Authorization: `Bearer ${trimmed}` },
    });

    const data = await res.json();

    if (res.status === 200 && data.status) {
      console.log('PASS: API call succeeded');
      console.log('Account is active and key is valid');
    } else if (res.status === 401) {
      console.error('FAIL: API returned 401 - ' + data.message);
      console.error('The key is not recognized by Paystack.');
      console.error('Possible causes:');
      console.error('  - Key was regenerated (copy new key from dashboard)');
      console.error('  - Key belongs to a different account');
      console.error('  - Account activation is not complete');
    } else {
      console.error('FAIL: Unexpected response:', res.status, data.message);
    }
  } catch (err) {
    console.error('FAIL: Network error:', err.message);
  }

  console.log('\nKey suffix:', trimmed.slice(-4));
  console.log('Compare this with the key in your Paystack dashboard');
}

diagnose();

Run this on your production server, not your local machine. The output tells you exactly what is wrong and what to do about it.

Verification: Confirm Live Keys Work

After fixing the issue, verify live keys work with a real API call:

Step 1: Test from the command line.

# Replace sk_live_YOUR_KEY with your actual live key
curl -s https://api.paystack.co/transaction?perPage=1   -H "Authorization: Bearer sk_live_YOUR_KEY" | head -c 200

# Success: {"status":true,"message":"Transactions retrieved","data":[],...}
# Failure: {"status":false,"message":"Invalid key"}

Step 2: Verify from your server.

Check your server logs after startup. Your key check function (from the diagnostic section) should show "Using LIVE Paystack key" with no warnings.

Step 3: Initialize a test transaction.

// From your server, initialize a small transaction
const res = await fetch('https://api.paystack.co/transaction/initialize', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    email: 'test@yourcompany.com',
    amount: 10000,  // 100 NGN
    callback_url: 'https://yoursite.com/payment/verify',
  }),
});

const data = await res.json();
console.log('Authorization URL:', data.data?.authorization_url);
// If you get an authorization_url, your live key is working

Step 4: Complete a real payment.

Open the authorization URL and pay with a real card. Confirm the payment succeeds, the webhook fires, and the transaction appears in your Paystack dashboard under live transactions.

Key Takeaways

  • The most common cause is loading the wrong key from environment variables. You updated your .env file but did not update the production environment, or the variable name is different in production.
  • Paystack activation has multiple steps. If any step is incomplete, your dashboard may show "activated" but live keys will not work. Check Settings > Business Settings for any remaining requirements.
  • After activation, you may need to regenerate your live keys. Some accounts require a key refresh when moving from pending to active status. Regenerate in Settings > API Keys & Webhooks.
  • Deployment platforms cache environment variables. Changing an env var on Vercel, Railway, or Render does not take effect until you redeploy the service.
  • Always log the key prefix (first 8 characters) at server startup. This tells you immediately whether you are loading the right key without exposing the full secret.
  • If you manage multiple Paystack accounts, verify the key belongs to the activated account. A live key from Account A will not work for Account B.

Frequently Asked Questions

I just activated my Paystack account. Do I need new live keys?
Not always. In most cases, the live keys generated before activation become active automatically. But if your live keys return "Invalid key" after activation, try regenerating them in the dashboard under Settings > API Keys & Webhooks. This forces a fresh key pair that is definitely linked to your active account.
How do I know if my Paystack account is fully activated?
Log into the Paystack dashboard and check for any activation banners or incomplete steps. Go to Settings > Business Settings and verify every section is complete. If you are unsure, email support@paystack.com with your business name and ask them to confirm your activation status.
Can I use both test and live keys at the same time?
Yes, but not in the same request. Test keys only work for test transactions and live keys only work for live transactions. You can run a test environment and a live environment simultaneously, each using the appropriate key. Just make sure your production server never loads test keys.
My live key worked yesterday but stopped working today. What happened?
Someone may have regenerated the key in the Paystack dashboard. When a key is regenerated, the old key stops working immediately. Check with your team, then go to the dashboard and compare the current key with the one your server is using. If they differ, update your environment variables with the new key and redeploy.
Is there a way to test live keys without charging a real card?
No. Live keys process real transactions. The best approach is to initialize a small transaction (like 100 NGN), pay with a real card, verify the transaction works, and then refund it from the Paystack dashboard. This confirms your entire live flow works without losing money.

Ready to build real-world apps?

Join the McTaba Labs full-stack marathon (4 months full-time · 6 months part-time). Learn M-Pesa, USSD, and WhatsApp engineering while shipping 8 production apps.

Apply to the McTaba Marathon