Skip to main content

Overview

The Kount Android SDK provides environment constants to configure whether the SDK connects to the test (sandbox) or production environment. These constants are used with the KountSDK.setEnvironment() method.

Constants

ENVIRONMENT_TEST

Configures the SDK to connect to the Kount test environment (sandbox).
KountSDK.ENVIRONMENT_TEST: Int
Use this environment during development, testing, and QA phases. The test environment allows you to:
  • Test your integration without affecting production data
  • Validate your implementation before going live
  • Perform end-to-end testing in a safe environment
  • Debug issues without risk to real transactions
Example:
KountSDK.setEnvironment(KountSDK.ENVIRONMENT_TEST)
KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);

ENVIRONMENT_PRODUCTION

Configures the SDK to connect to the Kount production environment.
KountSDK.ENVIRONMENT_PRODUCTION: Int
Use this environment only when your application is deployed to production and processing real transactions. The production environment:
  • Processes live device data for fraud evaluation
  • Connects to production Kount servers
  • Affects your merchant account metrics and billing
  • Should only be used after thorough testing
Example:
KountSDK.setEnvironment(KountSDK.ENVIRONMENT_PRODUCTION)
KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_PRODUCTION);
Never use ENVIRONMENT_PRODUCTION during development or testing. Always start with ENVIRONMENT_TEST and only switch to production when deploying your app.

Usage

Configuration

Set the environment early in your application lifecycle, typically in your Application class or before calling collectForSession():
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        KountSDK.setMerchantId("999999")
        KountSDK.setEnvironment(KountSDK.ENVIRONMENT_TEST)
        KountSDK.setCollectAnalytics(true)
    }
}
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        KountSDK.INSTANCE.setMerchantId("999999");
        KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);
        KountSDK.INSTANCE.setCollectAnalytics(true);
    }
}

Build-Specific Configuration

Use build variants or flavors to automatically select the appropriate environment: Kotlin Example:
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        
        val environment = if (BuildConfig.DEBUG) {
            KountSDK.ENVIRONMENT_TEST
        } else {
            KountSDK.ENVIRONMENT_PRODUCTION
        }
        
        KountSDK.setMerchantId(BuildConfig.KOUNT_MERCHANT_ID)
        KountSDK.setEnvironment(environment)
    }
}
Java Example:
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        
        int environment = BuildConfig.DEBUG 
            ? KountSDK.ENVIRONMENT_TEST 
            : KountSDK.ENVIRONMENT_PRODUCTION;
        
        KountSDK.INSTANCE.setMerchantId(BuildConfig.KOUNT_MERCHANT_ID);
        KountSDK.INSTANCE.setEnvironment(environment);
    }
}

Gradle Configuration

Store environment-specific configuration in your build.gradle file:
android {
    buildTypes {
        debug {
            buildConfigField "String", "KOUNT_MERCHANT_ID", '"999999"'
            buildConfigField "int", "KOUNT_ENVIRONMENT", "${KountSDK.ENVIRONMENT_TEST}"
        }
        release {
            buildConfigField "String", "KOUNT_MERCHANT_ID", '"YOUR_PROD_MERCHANT_ID"'
            buildConfigField "int", "KOUNT_ENVIRONMENT", "${KountSDK.ENVIRONMENT_PRODUCTION}"
        }
    }
}
Then use it in your code:
KountSDK.setMerchantId(BuildConfig.KOUNT_MERCHANT_ID)
KountSDK.setEnvironment(BuildConfig.KOUNT_ENVIRONMENT)

Environment Comparison

Test Environment

Use for:
  • Development
  • Testing
  • QA validation
  • Integration verification
Characteristics:
  • Safe sandbox environment
  • No impact on production
  • Test merchant accounts
  • Debug-friendly

Production Environment

Use for:
  • Live applications
  • Real transactions
  • Production deployments
  • Post-release monitoring
Characteristics:
  • Live fraud detection
  • Real merchant accounts
  • Affects billing
  • Production SLAs

Best Practices

Begin development using ENVIRONMENT_TEST. This ensures you don’t accidentally send test data to production or incur unexpected costs.
// Start here during development
KountSDK.setEnvironment(KountSDK.ENVIRONMENT_TEST)
Automate environment selection based on build type to prevent manual errors.
val environment = when (BuildConfig.BUILD_TYPE) {
    "debug" -> KountSDK.ENVIRONMENT_TEST
    "release" -> KountSDK.ENVIRONMENT_PRODUCTION
    else -> KountSDK.ENVIRONMENT_TEST
}
KountSDK.setEnvironment(environment)
Double-check that your production builds use ENVIRONMENT_PRODUCTION and your test builds use ENVIRONMENT_TEST.
// Log environment for verification
val envName = if (BuildConfig.KOUNT_ENVIRONMENT == KountSDK.ENVIRONMENT_TEST) {
    "TEST"
} else {
    "PRODUCTION"
}
Log.i("Kount", "Using environment: $envName")
Use different merchant IDs for test and production environments.
// build.gradle
buildTypes {
    debug {
        buildConfigField "String", "MERCHANT_ID", '"999999"' // Test ID
    }
    release {
        buildConfigField "String", "MERCHANT_ID", '"123456"' // Production ID
    }
}
Clearly document which environment your team should use for different scenarios.
/**
 * Kount SDK Configuration
 * 
 * Environments:
 * - Local development: ENVIRONMENT_TEST
 * - Staging: ENVIRONMENT_TEST
 * - Production: ENVIRONMENT_PRODUCTION
 */
object KountConfig {
    fun initialize(context: Application) {
        KountSDK.setMerchantId(getMerchantId())
        KountSDK.setEnvironment(getEnvironment())
    }
}

Complete Example

class MyApplication : Application() {
    
    companion object {
        private const val TEST_MERCHANT_ID = "999999"
        private const val PROD_MERCHANT_ID = "123456"
    }
    
    override fun onCreate() {
        super.onCreate()
        initializeKount()
    }
    
    private fun initializeKount() {
        val isProduction = !BuildConfig.DEBUG
        
        val merchantId = if (isProduction) PROD_MERCHANT_ID else TEST_MERCHANT_ID
        val environment = if (isProduction) {
            KountSDK.ENVIRONMENT_PRODUCTION
        } else {
            KountSDK.ENVIRONMENT_TEST
        }
        
        KountSDK.setMerchantId(merchantId)
        KountSDK.setEnvironment(environment)
        KountSDK.setCollectAnalytics(true)
        
        // Log for verification (remove in production)
        if (BuildConfig.DEBUG) {
            Log.i("Kount", "Initialized with merchant: $merchantId, environment: TEST")
        }
    }
}
public class MyApplication extends Application {
    
    private static final String TEST_MERCHANT_ID = "999999";
    private static final String PROD_MERCHANT_ID = "123456";
    
    @Override
    public void onCreate() {
        super.onCreate();
        initializeKount();
    }
    
    private void initializeKount() {
        boolean isProduction = !BuildConfig.DEBUG;
        
        String merchantId = isProduction ? PROD_MERCHANT_ID : TEST_MERCHANT_ID;
        int environment = isProduction 
            ? KountSDK.ENVIRONMENT_PRODUCTION 
            : KountSDK.ENVIRONMENT_TEST;
        
        KountSDK.INSTANCE.setMerchantId(merchantId);
        KountSDK.INSTANCE.setEnvironment(environment);
        KountSDK.INSTANCE.setCollectAnalytics(true);
        
        // Log for verification (remove in production)
        if (BuildConfig.DEBUG) {
            Log.i("Kount", "Initialized with merchant: " + merchantId + ", environment: TEST");
        }
    }
}
  • KountSDK - Main SDK class with setEnvironment() method
  • Quick Start - Getting started guide with initial configuration

Build docs developers (and LLMs) love