Skip to main content

Test Mode

Test your integration safely with test API keys without processing real payments or affecting production data.

Overviewโ€‹

Omise provides separate test and live environments. Use test mode during development to verify your integration without real money or customer data.

Test Mode Features:

  • ๐Ÿ” Separate API keys - Test keys start with pkey_test_ and skey_test_
  • ๐Ÿ’ณ Test cards - Special card numbers for testing scenarios
  • ๐Ÿ’ฐ No real money - All transactions are simulated
  • ๐Ÿ”„ Full API access - Test all features and payment methods
  • ๐Ÿ“Š Test dashboard - View test transactions separately

API Keysโ€‹

Test Keys vs Live Keysโ€‹

Key TypePrefixEnvironmentReal Transactions
Test Public Keypkey_test_TestโŒ No
Test Secret Keyskey_test_TestโŒ No
Live Public Keypkey_live_Productionโœ… Yes
Live Secret Keyskey_live_Productionโœ… Yes

Getting Test Keysโ€‹

  1. Log into Omise Dashboard
  2. Navigate to Settings โ†’ API Keys
  3. Copy your test keys (they start with pkey_test_ and skey_test_)
// Test mode configuration
const omise = require('omise')({
publicKey: 'pkey_test_5xb...', // Test public key
secretKey: 'skey_test_5xb...' // Test secret key
});
Never Commit Keys

Never commit API keys to version control. Use environment variables:

OMISE_PUBLIC_KEY=pkey_test_...
OMISE_SECRET_KEY=skey_test_...

Test Cardsโ€‹

Success Scenariosโ€‹

Card NumberBrandResult
4242424242424242VisaSuccess (no 3DS)
5555555555554444MastercardSuccess (no 3DS)
3566111111111113JCBSuccess (no 3DS)

Expiry: Any future date (e.g., 12/25) CVV: Any 3 digits (e.g., 123)

3D Secure Test Cardsโ€‹

Card NumberBrand3DS Behavior
4000000000003220Visa3DS required, authentication succeeds
4000000000009235Visa3DS required, authentication fails
5200000000001096Mastercard3DS required, succeeds

Decline Scenariosโ€‹

Card NumberError Type
4000000000000002Card declined
4000000000009995Insufficient funds
4000000000000069Expired card
4000000000000127Incorrect CVC
4000000000000119Processing error

Specific Amount Testingโ€‹

Use these amounts with any test card to simulate scenarios:

AmountResult
100.00Success
100.02Card declined
100.05Insufficient funds
100.41Processing error

Testing Payment Methodsโ€‹

Digital Wallets (Test Mode)โ€‹

// Create test wallet payment
const source = await omise.sources.create({
type: 'truemoney',
amount: 50000,
currency: 'THB'
});

// In test mode, you can simulate success/failure
const charge = await omise.charges.create({
amount: 50000,
currency: 'THB',
source: source.id
});

// Test charge completes immediately in test mode

Bank Transfers (Test Mode)โ€‹

// Mobile banking test
const source = await omise.sources.create({
type: 'mobile_banking_scb',
amount: 100000,
currency: 'THB'
});

// Test mode simulates bank approval
const charge = await omise.charges.create({
amount: 100000,
currency: 'THB',
source: source.id,
return_uri: 'https://yourdomain.com/callback'
});

// In test, redirect shows test page with success/fail buttons

QR Payments (Test Mode)โ€‹

// PromptPay test
const source = await omise.sources.create({
type: 'promptpay',
amount: 100000,
currency: 'THB'
});

// QR code generated in test mode
const qrCode = source.scannable_code.image.download_uri;

// Charge status can be updated manually in test dashboard

Test Dashboardโ€‹

Access test data at: https://dashboard.omise.co/test/

Test Dashboard Features:

  • View all test transactions
  • Filter by payment method
  • Test webhook delivery
  • Update charge status manually
  • Generate test reports

Manual Charge Updatesโ€‹

In test mode, you can manually update charge status:

  1. Go to test dashboard
  2. Find the test charge
  3. Click "Change Status"
  4. Select: Success, Failed, or Expired

Testing Webhooksโ€‹

Webhook Test Eventsโ€‹

// Test webhook locally with ngrok
// 1. Start ngrok: ngrok http 3000
// 2. Add webhook URL in dashboard: https://xxx.ngrok.io/webhooks

app.post('/webhooks/omise', (req, res) => {
const event = req.body;

console.log('Test webhook received:', event.key);
console.log('Charge status:', event.data.status);

res.sendStatus(200);
});

Trigger Test Webhooksโ€‹

From test dashboard:

  1. Select a test charge
  2. Click "Send Webhook"
  3. Choose event type
  4. Webhook fires to your endpoint

Environment Variablesโ€‹

# .env file
NODE_ENV=development

# Test keys for development
OMISE_PUBLIC_KEY=pkey_test_5xb...
OMISE_SECRET_KEY=skey_test_5xb...

# Live keys for production (different file)
# OMISE_PUBLIC_KEY=pkey_live_5xb...
# OMISE_SECRET_KEY=skey_live_5xb...
// Load based on environment
const omise = require('omise')({
publicKey: process.env.OMISE_PUBLIC_KEY,
secretKey: process.env.OMISE_SECRET_KEY
});

// Check which mode you're in
const isTestMode = process.env.OMISE_SECRET_KEY.startsWith('skey_test_');
console.log('Running in:', isTestMode ? 'TEST' : 'LIVE');

Testing Checklistโ€‹

Before Going Liveโ€‹

  • All payment flows tested with test cards
  • 3D Secure flow tested and working
  • Webhook handling tested and verified
  • Error scenarios handled properly
  • Refund process tested
  • Mobile responsive design tested
  • All payment methods tested on actual devices
  • Security review completed
  • Test keys replaced with live keys
  • Production environment configured

Common Test Scenariosโ€‹

1. Successful Paymentโ€‹

// Use success test card
const token = await createToken('4242424242424242', '12/25', '123');

const charge = await omise.charges.create({
amount: 10000,
currency: 'THB',
card: token
});

assert(charge.status === 'successful');

2. Declined Cardโ€‹

// Use decline test card
const token = await createToken('4000000000000002', '12/25', '123');

try {
const charge = await omise.charges.create({
amount: 10000,
currency: 'THB',
card: token
});
} catch (error) {
assert(error.message.includes('declined'));
}

3. 3D Secure Flowโ€‹

// Use 3DS test card
const token = await createToken('4000000000003220', '12/25', '123');

const charge = await omise.charges.create({
amount: 10000,
currency: 'THB',
card: token,
return_uri: 'https://yourdomain.com/callback'
});

// Should have authorize_uri for 3DS
assert(charge.authorize_uri !== null);

// Test 3DS page allows success/fail selection

Best Practicesโ€‹

1. Use Test Mode for All Developmentโ€‹

if (process.env.NODE_ENV === 'production' && process.env.OMISE_SECRET_KEY.startsWith('skey_test_')) {
throw new Error('DANGER: Using test keys in production!');
}

2. Test Error Handlingโ€‹

// Test various failure scenarios
const testCases = [
{ card: '4000000000000002', expected: 'card_declined' },
{ card: '4000000000009995', expected: 'insufficient_funds' },
{ card: '4000000000000069', expected: 'expired_card' }
];

for (const test of testCases) {
const token = await createToken(test.card);
// Verify error handling
}

3. Separate Test and Live Dataโ€‹

// Different databases for test and live
const dbName = process.env.NODE_ENV === 'production'
? 'myapp_production'
: 'myapp_test';

const db = mongoose.connect(`mongodb://localhost/${dbName}`);

4. Clear Test Data Regularlyโ€‹

Test data doesn't affect billing, but keep it tidy:

  • Archive old test transactions
  • Clear test customer data
  • Reset test webhooks

FAQโ€‹

Do test transactions cost money?

No. Test mode is completely free. No charges apply to test transactions.

Can I use real cards in test mode?

No. Only use test card numbers in test mode. Real card numbers will be rejected.

How do I switch from test to live mode?

Replace test API keys with live API keys. That's it! Your code stays the same.

// Change from:
OMISE_SECRET_KEY=skey_test_...
// To:
OMISE_SECRET_KEY=skey_live_...
Can I test webhooks without deploying?

Yes, use ngrok or similar tools to expose localhost:

ngrok http 3000
# Use ngrok URL in webhook settings
What happens to test data?

Test data is kept separate from production data. It won't affect reports, billing, or settlements. You can delete test data anytime.

Next Stepsโ€‹

  1. Get your test API keys
  2. Implement payment flow
  3. Test with test cards
  4. Test all payment methods
  5. Test webhooks
  6. Review going live checklist
  7. Switch to live keys
  8. Go live!