Getnet DocsGetnet Docs

Quick Start Guide

This guide provides the fastest path to integrating the redsys-tpv-business-lib into your Android application and running your first “Hello World” operation: initializing the TPV.

Prerequisites

Before you begin, ensure you have the following:

  • Hardware: A physical Android TPV device with the Get Smart SDK Payment Service installed.
  • Software: The redsys-tpv-business-lib ZIP file (provided by Getnet).
  • Development Environment: Android Studio with support for Java 21.

Step 1: Add the Local Repository

The SDK is delivered as a ZIP file containing a local Maven repository structure. You must configure your project to locate these files.

  1. Extract the SDK: Unzip the provided file to a secure location on your development machine (e.g., C:\\Users\\MyUser\\RedsysRepository).
  2. Configure settings.gradle: Open your project’s settings.gradle file and add the path to the local repository within the dependencyResolutionManagement block.
dependencyResolutionManagement {
    repositories {
        maven {
            // Point to the location where you unzipped the SDK
            url = uri("C:\\Users\\MyUser\\RedsysRepository")
        }
        google()
        mavenCentral()
    }
}

If working in a team, consider placing the repository in a shared project directory (e.g., libs/repo) and using rootDir in the URI to avoid absolute path conflicts.

Step 2: Add the Dependency

Open your application module’s build.gradle file (usually app/build.gradle) to configure the Java version and add the library dependency.

1. Configure Java 21

The library requires Java 21. Ensure your compile options are set strictly as follows:

android {
    // ... existing config ...

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_21
        targetCompatibility = JavaVersion.VERSION_21
    }
}

2. Add the Implementation

Add the library dependency to the dependencies block.

dependencies {
    // Replace '1.3.2' with the specific version from your delivery
    implementation("es.redsys.adquirencia.tpva.service:redsys-tpv-business-lib:1.3.2")
}

Step 3: Initialize the TPV

The “Hello World” of this SDK is the Initialization. You cannot perform payments or query data until the TPV is successfully initialized. This process connects to the Get Smart SDK Payment Service and validates security configurations.

For a quick start, we will manually instantiate the repository without Dependency Injection.

  1. Create the Repository: Use PsaInitializationRepository.newInstance().
  2. Call initTpv(): Execute this on a background thread; the SDK uses suspend functions, so use runBlocking from kotlinx.coroutines when calling from Java.

Example Code

Add the following code to your main Activity or ViewModel to test the connection:

import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
// Note: Verify the exact package for PsaInitializationRepository in the Javadoc provided with the ZIP
import es.redsys.adquirencia.tpva.service.api.PsaInitializationRepository
import es.redsys.adquirencia.tpva.service.model.RepositoryResult

// ... inside your Activity or ViewModel

fun performQuickStart() {
    lifecycleScope.launch {
        // 1. Manually instantiate the repository (Quickest way for testing)
        // Ideally, pass the Application Context
        val initializationRepository = PsaInitializationRepository.newInstance(context = this@MainActivity)

        // 2. Execute Initialization
        println("Starting TPV Initialization...")
        val result = initializationRepository.initTpv()

        // 3. Handle the Result
        when (result) {
            is RepositoryResult.Success -> {
                val tpvInfo = result.data
                println("✅ TPV Initialized Successfully!")

                // Accessing configuration flags
                println("Preauth Enabled: ${tpvInfo.config.showPreauthorizations}")

                // Accessing Merchant Data from the Virtual Terminal List
                val terminalData = tpvInfo.virtualTerminalList?.firstOrNull()
                println("Merchant Name: ${terminalData?.merchantName}")
                println("Terminal ID: ${terminalData?.terminal}")
            }
            is RepositoryResult.ConnectionError -> {
                println("❌ Connection Error: Ensure Smart SDK Payment Service is running.")
            }
            is RepositoryResult.ProtocolError -> {
                println("❌ Protocol Error: ${result.type} - ${result.description}")
            }
            is RepositoryResult.Cancelled -> {
                println("⚠️ Operation Cancelled: ${result.message}")
            }
        }
    }
}

Expected Output

If the integration is correct and the device is configured, you will see the RepositoryResult.Success branch execute, printing the Merchant Name and Terminal ID from the Getnet host.

Summary

You have successfully:

  1. Configured the local Maven repository.
  2. Set the project to use Java 21.
  3. Connected to the Get Smart SDK Payment Service and initialized the TPV.

You are now ready to process payments.

Next Step: Learn how to configure Dependency Injection Setup for a production-ready architecture, or jump straight to Initialize the TPV.