Overview

HOST Pay provides two separate environments for every application to ensure safe development and testing without affecting production data.

Test Mode

Sandbox environment for development and testing

Live Mode

Production environment for real transactions

Key Differences

FeatureTest ModeLive Mode
CredentialsTest API keysLive API keys
DatabaseSeparate test schemaSeparate live schema
StripeStripe Test ModeStripe Live Mode
Mobile MoneyMock Monime ServiceReal Monime API
Real MoneyNo real moneyReal transactions
WebhooksTest webhook URLsProduction webhook URLs

Test Mode

What is Test Mode?

Test Mode is a complete sandbox environment that mirrors Live Mode functionality without processing real money or making real API calls to payment providers.

Features

  • Mock Monime Service: Simulates mobile money without real transactions
  • Stripe Test Mode: Uses Stripe’s test cards and API
  • All payment responses mirror real API structures
  • Completely separate database schema - Test data never mixes with production data - Safe to experiment and delete data
  • All API endpoints available - Same rate limits as Live Mode - Webhook events triggered normally
  • Simulate successful and failed payments
  • Test edge cases and error handling
  • Debug without risk

Using Test Mode

Simply use your Test Mode credentials:
# Test Mode Configuration
test_credentials = {
    "api_key": "test_ak_1234567890abcdef",
    "secret_key": "test_sk_abcdef1234567890"
}

# All requests will use Test Mode
response = requests.post(
    "https://hpay-api.host-sl.com/api/v1/users/create/",
    headers={
        "api-key": test_credentials["api_key"],
        "secret-key": test_credentials["secret_key"]
    },
    json=user_data
)

Test Mode Indicators

Resources created in Test Mode will have "live_mode": false in their response.
{
  "id": "user_test_abc123",
  "name": "Test User",
  "email": "test@example.com",
  "live_mode": false, // ← Indicates Test Mode
  "created_at": "2025-01-16T10:00:00Z"
}

Live Mode

What is Live Mode?

Live Mode is the production environment where real transactions are processed, real money moves, and actual API calls are made to payment providers.
Use Live Mode with caution! All transactions in Live Mode involve real money and cannot be easily reversed.

Features

  • Real Transactions: Actual money transfers
  • Live Payment Providers: Real Stripe and Monime APIs
  • Production Database: Separate live schema
  • Real Webhooks: Events sent to production URLs
  • Compliance: Full regulatory compliance required

Using Live Mode

Use your Live Mode credentials:
# Live Mode Configuration
live_credentials = {
    "api_key": "live_ak_0987654321fedcba",
    "secret_key": "live_sk_fedcba0987654321"
}

# All requests will use Live Mode
response = requests.post(
    "https://hpay-api.host-sl.com/api/v1/users/create/",
    headers={
        "api-key": live_credentials["api_key"],
        "secret-key": live_credentials["secret_key"]
    },
    json=user_data
)

Live Mode Indicators

{
  "id": "user_live_xyz789",
  "name": "Real Customer",
  "email": "customer@example.com",
  "live_mode": true, // ← Indicates Live Mode
  "created_at": "2025-01-16T10:00:00Z"
}

Switching Between Environments

Environment Selection

The environment is automatically determined by which credentials you use:
class HostPayClient:
    def __init__(self, api_key, secret_key):
        self.api_key = api_key
        self.secret_key = secret_key

        # Detect environment from API key
        self.is_live = api_key.startswith("live_")
        self.mode = "LIVE" if self.is_live else "TEST"

        print(f"🔧 Running in {self.mode} mode")

    def get_headers(self):
        return {
            "api-key": self.api_key,
            "secret-key": self.secret_key
        }

# Test Mode
test_client = HostPayClient(
    api_key="test_ak_123",
    secret_key="test_sk_456"
)
# Output: 🔧 Running in TEST mode

# Live Mode
live_client = HostPayClient(
    api_key="live_ak_789",
    secret_key="live_sk_012"
)
# Output: 🔧 Running in LIVE mode

Configuration Management

# .env.development
HOST_PAY_API_KEY=test_ak_1234567890abcdef
HOST_PAY_SECRET_KEY=test_sk_abcdef1234567890
HOST_PAY_ENV=test

# .env.production
HOST_PAY_API_KEY=live_ak_0987654321fedcba
HOST_PAY_SECRET_KEY=live_sk_fedcba0987654321
HOST_PAY_ENV=live

Testing Best Practices

1

Develop in Test Mode

Build and test all features using Test Mode credentials
2

Test Edge Cases

Simulate failures, errors, and unusual scenarios
3

Verify Webhooks

Ensure webhook handlers work correctly in Test Mode
4

Conduct UAT

Perform user acceptance testing in Test Mode
5

Switch to Live

Only move to Live Mode after thorough testing
6

Monitor Carefully

Watch Live Mode closely during initial rollout

Payment Provider Modes

Stripe

Test Cards (always work): - 4242 4242 4242 4242 - Visa (succeeds) - 4000 0000 0000 0002 - Visa (card declined) - 4000 0000 0000 9995 - Visa (insufficient funds) Use any future expiry date and any 3-digit CVC.

Monime (Mobile Money)

MockMonimePaymentService provides:
  • Simulated USSD codes
  • Instant payment confirmation (for testing)
  • No real mobile money transactions
  • Predictable responses
Example response:
{
  "ussdCode": "*715*1234567890#",
  "status": "pending"
}

Common Scenarios

Scenario 1: Initial Development

Use Test Mode for all initial development work.

Scenario 2: Pre-Production Testing

Stay in Test Mode until all tests pass.

Scenario 3: Going Live

Switch to Live Mode only after thorough testing.

Scenario 4: Debugging Production

Use Test Mode to safely reproduce and fix issues.

Checklist: Going Live

Before switching to Live Mode, ensure:

Need Help?

Testing Guide

Learn how to test effectively in Test Mode

Support

Questions about going live? Contact us