Skip to main content

Overview

Novac Android SDKs enable Android developers to extend Novac’s capabilities when building mobile platforms with minimal setup. The Novac Android SDK provides a seamless checkout experience with a customizable UI, native Jetpack Compose and Views support, and robust error handling—all with a simple setup.

Prerequisites

See details

Before you begin, ensure that you’ve completed the following steps:
  • Obtain your API keys: required for making authenticated API calls.
  • Android project with Gradle build system
  • Minimum SDK version compatible with Jetpack Compose or AppCompat

Installation

1

Step 1 - Add the JitPack Repository

In your project-level build.gradle, add the JitPack repository:
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
2

Step 2 - Add the SDK Dependency

In your app-level build.gradle, add the following dependency.
  dependencies {
      implementation 'com.github.novacpayment:novac-payment-android-sdk:v0.2.6'
  }

Initialize the SDK

Initialize the SDK in your Application class or main Activity. You will need your merchantId and apiKey from your Novac dashboard, and you must specify the activities that will handle payment success and failure outcomes.
import com.novacpaymen.paywithnovac_android_skd.NovacCheckout
import com.novacpaymen.paywithnovac_android_skd.CheckoutConfig

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        NovacCheckout.initialize(
            CheckoutConfig(
                merchantId = "your-merchant-id",
                baseUrl = "https://api.novacpayment.com",
                apiKey = "your-api-key",
                enableLogging = false,
                successActivityClass = SuccessActivity::class.java,
                failureActivityClass = FailureActivity::class.java
            )
        )
    }
}

Checkout Config Parameters

ParameterTypeRequiredDescription
merchantIdStringtrueYour merchant ID from Novac
baseUrlStringtrueAPI base URL
apiKeyStringtrueYour API key from Novac
enableLoggingBooleanfalseEnable debug logging
successActivityClassClasstrueActivity to launch on successful payment
failureActivityClassClasstrueActivity to launch on failed payment

Create Result Activities

You need two activities to handle the payment outcomes: one for success and one for failure. The SDK passes transaction details to each via the intent.

SuccessActivity.kt

class SuccessActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_success)

        val transactionReference = intent.getStringExtra("transaction_reference")
        val amount = intent.getDoubleExtra("amount", 0.0)
        val currency = intent.getStringExtra("currency")
        val paymentStatus = intent.getStringExtra("payment_status")

        // Update your UI, confirm the order, etc.
    }
}

FailureActivity.kt

class FailureActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_failure)

        val transactionReference = intent.getStringExtra("transaction_reference")
        val amount = intent.getDoubleExtra("amount", 0.0)
        val currency = intent.getStringExtra("currency")
        val errorMessage = intent.getStringExtra("error_message")
        val errorCode = intent.getStringExtra("error_code")

        // Show error message, offer retry option, etc.
    }
}

Launch the Checkout Flow

Once the SDK is initialized, launching a payment is a single method call:
val sdk = NovacCheckout.getInstance()

sdk.launchCheckoutFlow(
    context = this,
    transactionReference = UUID.randomUUID().toString(),
    amount = 120.0,
    currency = "NGN",
    customerEmail = "customer@example.com",
    customerFirstName = "John",
    customerLastName = "Doe",
    customerPhone = "1234567890"
)

Advanced Usage

Customizing the Checkout UI

You can personalize the checkout modal with your brand logo, a payment description, and a custom title:
val customizationData = CheckoutCustomizationData(
    logoUrl = "https://your-logo-url.com/logo.png",
    paymentDescription = "Payment for Order #123",
    checkoutModalTitle = "Complete Your Payment"
)

sdk.launchCheckoutFlow(
    context = this,
    transactionReference = UUID.randomUUID().toString(),
    amount = 120.0,
    currency = "NGN",
    customerEmail = "customer@example.com",
    customerFirstName = "John",
    customerLastName = "Doe",
    customerPhone = "1234567890",
    customizationData = customizationData
)

Manual Checkout Initiation

For greater control over the checkout flow — for example, to retrieve the payment URL and handle redirection yourself — use initiateCheckout directly within a coroutine:
val sdk = NovacCheckout.getInstance()

val customerData = CheckoutCustomerData(
    email = "customer@example.com",
    firstName = "John",
    lastName = "Doe",
    phoneNumber = "1234567890"
)

val customizationData = CheckoutCustomizationData(
    logoUrl = "https://your-logo-url.com/logo.png",
    paymentDescription = "Payment for Order #123",
    checkoutModalTitle = "Complete Your Payment"
)

coroutineScope.launch {
    when (val result = sdk.initiateCheckout(
        transactionReference = UUID.randomUUID().toString(),
        amount = 120.0,
        currency = "NGN",
        checkoutCustomerData = customerData,
        checkoutCustomizationData = customizationData
    )) {
        is Result.Success -> {
            val paymentUrl = result.value.data?.paymentRedirectUrl
            // Redirect the user to the payment URL
        }
        is Result.Failure -> {
            Log.e("Checkout", "Payment initiation failed", result.exception)
        }
    }
}
Keep the following in mind when testing:
  • Always use a unique reference value for each transaction, duplicate references will be rejected.
  • Start with small test amounts (₦100) to validate your integration before going live.
  • Check your sandbox dashboard to confirm transaction results and inspect any errors.