# Set up

Before processing payments or performing any other operations with the **ePOS Unified SDK**, you must first initialize the SDK.

Follow the steps below to properly initialize and prepare the SDK for use in your Android project:

## 1. Create the `AllInOneSDK` Instance

To set up the **All-in-One SDK** in your Android project, create an instance of `AllInOneSDK` by calling `TeyaAllInOneSDK` function.  
You'll need to provide a `MissedResponseListener`, which is explained in detail in the [Missed Responses section](./missed-responses.md).

```tabs
    tab:
      title: Kotlin
      content:
        ```kotlin
        val teyaAllInOneSDK = TeyaAllInOneSDK(
            onMissedResponseListener = object : MissedResponseListener {
              // ..
            },
            logger = LoggerImpl(),
            eposInstanceId = null // Optional: identifier for your ePOS app instance
        )
        ```
    tab:
      title: Java
      content:
        ```java
        AllInOneSDK teyaAllInOneSDK = TeyaAllInOneSDK.init(
                new MissedResponseListener() {
                  // ..
                },
                new LoggerImpl(),
                null // eposInstanceId: Optional identifier for your ePOS app instance
        );
        ```
```

## 2. Add Custom Logging
To enable logging, you can pass a custom logger by implementing the Logger interface.

```tabs
    tab:
      title: Kotlin
      content:
        ```kotlin
        class LoggerImpl : Logger {
            override fun d(message: String) {
                Log.d("SDK", message)
            }
        
            override fun i(message: String) {
                Log.i("SDK", message)
            }
        
            override fun w(message: String) {
                Log.w("SDK", message)
            }
        
            override fun e(message: String) {
                Log.e("SDK", message)
            }
        }
        ```
    tab:
      title: Java
      content:
        ```java
        class LoggerImpl implements Logger {
            @Override
            public void d(@NonNull String message) {
                Log.d("SDK", message);
            }
        
            @Override
            public void i(@NonNull String message) {
                Log.i("SDK", message);
            }
        
            @Override
            public void w(@NonNull String message) {
                Log.w("SDK", message);
            }
        
            @Override
            public void e(@NonNull String message) {
                Log.e("SDK", message);
            }
        }
        ```
```

| Symbol | Level   | Description                                                                         |
|--------|---------|-------------------------------------------------------------------------------------|
| `d`    | Debug   | Detailed information used for diagnosing issues. Typically disabled in production. |
| `i`    | Info    | General operational messages that highlight system progress.                        |
| `w`    | Warning | An indication that something unexpected happened, but the app can continue running. |
| `e`    | Error   | A serious issue that has caused part of the application to fail.                    |

These log levels help you filter and understand the behavior of the SDK or your application.

## 3. Initialize the Transactions API

Use `setupTransactionsApi` to initialize the SDK. You must retain the `TeyaCommonTransactionsApi` instance for all future SDK operations.

```tabs
    tab:
      title: Kotlin
      content:
        ```kotlin
        val teyaIntegration = teyaAllInOneSDK.setupTransactionsApi(
            skipApprovedScreen = false, // Optional: Show the approved screen after successful payment
            allowPaymentAppTips = true, // Optional: Enable tipping on the payment app
            showReceiptOptionsOnPaymentApp = false // Optional: Do not show receipt options on the payment app
        )
        ```
    tab:
      title: Java
      content:
        ```java
        TeyaCommonTransactionsApi teyaIntegration = teyaAllInOneSDK.setupTransactionsApi(
                false, // skipApprovedScreen: Show the approved screen after successful payment
                true, // allowPaymentAppTips: Enable tipping on the payment app
                false // showReceiptOptionsOnPaymentApp: Do not show receipt options on the payment app
        );
        ```
```
