Skip to main content

Overview

The PayMaya Android SDK supports two environments: Sandbox for testing and Production for live transactions. Proper environment configuration is essential for secure and reliable payment processing.

Environment Types

The SDK provides two environment options through the PayMayaEnvironment enum:
PayMayaEnvironment.kt
enum class PayMayaEnvironment {
    SANDBOX,
    PRODUCTION
}

Sandbox Environment

Use PayMayaEnvironment.SANDBOX for:
  • Development and testing
  • Integration testing with test credit cards
  • QA and staging environments
  • Demo applications
val payMayaCheckoutClient = PayMayaCheckout.newBuilder()
    .clientPublicKey("pk-test-xxxxxxxxxxxxxxxx")
    .environment(PayMayaEnvironment.SANDBOX)
    .logLevel(LogLevel.DEBUG)
    .build()
Never use sandbox API keys in production builds. Always use environment-specific configuration.

Production Environment

Use PayMayaEnvironment.PRODUCTION for:
  • Live production applications
  • Real customer transactions
  • Processing actual payments
val payMayaCheckoutClient = PayMayaCheckout.newBuilder()
    .clientPublicKey("pk-live-xxxxxxxxxxxxxxxx")
    .environment(PayMayaEnvironment.PRODUCTION)
    .logLevel(LogLevel.ERROR)
    .build()
Always use LogLevel.ERROR or LogLevel.WARN in production to avoid logging sensitive data.

Client Public Keys

Each environment requires its own public API key:
  • Prefix: pk-live-
  • Used for: Live transactions
  • Obtain from: PayMaya Business Account
  • Requires verification and approval

Best Practices for API Keys

Use Build Variants

Store different keys for debug and release builds using BuildConfig or gradle.properties

Secure Storage

Never commit API keys to version control. Use environment variables or secure key storage

Key Rotation

Regularly rotate your production keys and update your applications

Separate Keys

Use different keys for different applications or services

Log Levels

Configure logging verbosity using the LogLevel enum to control SDK output:
LogLevel.kt
enum class LogLevel {
    // Includes Http request and response lines, headers and bodies
    VERBOSE,
    // Includes Http request and response lines and headers
    DEBUG,
    // Includes Http request and response lines
    INFO,
    WARN,
    ERROR,
    ASSERT
}

Log Level Recommendations

EnvironmentRecommended LevelPurpose
DevelopmentDEBUG or VERBOSEFull visibility of HTTP requests and responses
QA/TestingINFO or DEBUGModerate logging for debugging
ProductionERROR or WARNMinimal logging, errors only

Examples by Payment Type

val payMayaCheckoutClient = PayMayaCheckout.newBuilder()
    .clientPublicKey(BuildConfig.PAYMAYA_PUBLIC_KEY)
    .environment(PayMayaEnvironment.SANDBOX)
    .logLevel(LogLevel.DEBUG)
    .build()

Environment-Specific Configuration

Using Gradle Build Types

Recommended approach for managing environment-specific configuration:
build.gradle
android {
    buildTypes {
        debug {
            buildConfigField "String", "PAYMAYA_PUBLIC_KEY", "\"pk-test-xxxxxxxxxxxxxxxx\""
            buildConfigField "String", "PAYMAYA_ENV", "\"SANDBOX\""
        }
        release {
            buildConfigField "String", "PAYMAYA_PUBLIC_KEY", "\"pk-live-xxxxxxxxxxxxxxxx\""
            buildConfigField "String", "PAYMAYA_ENV", "\"PRODUCTION\""
        }
    }
}
Then in your code:
val environment = if (BuildConfig.PAYMAYA_ENV == "PRODUCTION") {
    PayMayaEnvironment.PRODUCTION
} else {
    PayMayaEnvironment.SANDBOX
}

val logLevel = if (BuildConfig.DEBUG) {
    LogLevel.DEBUG
} else {
    LogLevel.ERROR
}

val client = PayMayaCheckout.newBuilder()
    .clientPublicKey(BuildConfig.PAYMAYA_PUBLIC_KEY)
    .environment(environment)
    .logLevel(logLevel)
    .build()

Switching Between Environments

Changing environments requires rebuilding the client instance. Environment cannot be changed at runtime.
// For development/testing
val sandboxClient = PayMayaCheckout.newBuilder()
    .clientPublicKey("pk-test-xxxxxxxxxxxxxxxx")
    .environment(PayMayaEnvironment.SANDBOX)
    .logLevel(LogLevel.DEBUG)
    .build()

// For production
val productionClient = PayMayaCheckout.newBuilder()
    .clientPublicKey("pk-live-xxxxxxxxxxxxxxxx")
    .environment(PayMayaEnvironment.PRODUCTION)
    .logLevel(LogLevel.ERROR)
    .build()

Next Steps

Testing Guide

Learn how to test your integration using sandbox environment

Result Handling

Implement proper handling of payment results

Build docs developers (and LLMs) love