# Get Smart SDK Overview

This page provides a high-level overview of the `redsys-tpv-business-lib` library, explaining its purpose, architectural design, and the technical shift from legacy systems to a modern, Kotlin-first approach.

The `redsys-tpv-business-lib` is an Android SDK designed to act as a secure abstraction layer between your application and the Get Smart SDK Payment Service. It allows you to integrate payment functionalities rapidly and securely without managing the complex underlying business logic or communication protocols.

This library replaces the legacy `redsysTpvAndroidLib` (`paysyslib.jar`). It provides access to all core Getnet functionalities, including:

* **Payment Processing**: Management of standard payments.  
* **Preauthorizations**: Handling creation, confirmation, and cancellation of pre-auths.  
* **Operations Management**: Access to transaction history, session management, and totals.  
* **Returns**: Processing refunds.  
* **Configuration**: Management of settings and keys.

## Architecture

The solution architecture consists of four primary actors that interact to process payments and manage the TPV:

1. **App**: Your Android application developed by the integrator.  
2. **redsys-tpv-business-lib**: The SDK provided by Getnet. It connects securely with the Get Smart SDK Payment Service installed on the device.  
3. **Get Smart SDK Payment Service**: A background Android service running on the device. It implements the business logic, manages communication protocols with the host, and handles the low-level operations.  
4. **Host**: The Getnet cloud back-office that processes payments, configurations, logs, and other TPV logic.

[//]: # (image)

### Data Flow

The architecture ensures a clear separation of concerns. Your app interacts with the SDK, which in turn communicates with the local Payment Service. The Payment Service handles the actual execution and communication with the remote Host.

## Design Philosophy

The `redsys-tpv-business-lib` adopts modern Android development standards to facilitate integration into current application architectures (such as MVVM or Clean Architecture).

### Kotlin-First and Coroutines

The library is developed 100% in Kotlin. It leverages **Kotlin Coroutines** to handle asynchronous tasks efficiently.

* **Suspend Functions**: All library interface functions are defined as `suspend`. This ensures that operations, which involve network communication with the host, do not block the main thread.  
* **Context Management**: All executions automatically switch to `Dispatchers.IO` to ensure the appropriate thread context for network and disk operations.

### Repository Pattern and Clean Architecture

The library follows the **Repository Pattern** and **SOLID principles**, organizing functionality into distinct interfaces (Repositories) based on their specific domain (e.g., `PaymentRepository`, `InitializationRepository`).

This design offers several key benefits:

* **Decoupling**: It abstracts your application from the data layer and specific implementation details.  
* **Dependency Injection**: The library is designed to work seamlessly with dependency injection frameworks like **Dagger Hilt**. You can configure repositories as singletons.  
* **Testability**: The interface-based design allows you to substitute real implementations with "dummy" or mock repositories during testing. This enables you to test your application logic independently of the Getnet hardware or service.

### Comparison with Legacy Library

Unlike the legacy `paysyslib.jar`, which required more manual management of logic and callbacks, the new library provides a structured, type-safe, and reactive approach to integration.

| Feature | Legacy (paysyslib.jar) | New (redsys-tpv-business-lib) |
| :---- | :---- | :---- |
| **Language** | Java | Kotlin |
| **Concurrency** | Callbacks/Threads | Coroutines (`suspend` functions) |
| **Architecture** | Monolithic | Repository Pattern / Clean Architecture |
| **Integration** | Manual instantiation | Ready for Dependency Injection (Hilt) |