> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alignet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Android initialization

> Invoke Alignet SDK v2.2 with Kotlin and process its callbacks.

## Import classes

```kotlin theme={"system"}
import com.alignet.payme.PaymeClient
import com.alignet.payme.PaymeClientDelegate
import com.alignet.payme.util.PaymeEnvironment
import com.alignet.payme.model.*
```

## Create and invoke the client

```kotlin theme={"system"}
val person = PaymePersonData(
    firstName = "Ana",
    lastName = "Perez",
    email = "ana@example.com",
    addrLine1 = "123 Main Avenue",
    addrLine2 = "",
    city = "Lima",
    countryCode = "PE",
    countryNumber = "604",
    zip = "15000",
    state = "Lima",
    mobilePhone = "51-999999999"
)

val request = PaymeRequest(
    merchant = PaymeMerchantData(
        operation = PaymeOperationData(
            operationNumber = "000001",
            operationDescription = "Purchase",
            amount = "10.55",
            currency = PaymeCurrencyData(code = "604", symbol = "S/")
        ),
        addrMatch = true,
        shipping = person,
        billing = person
    ),
    setting = PaymeSettingData(
        locale = "en_US",
        brands = listOf("VISA", "MSCD", "AMEX", "DINC")
    )
)

val client = PaymeClient(this, "COMMERCE_KEY")
client.setEnvironment(PaymeEnvironment.DEVELOPMENT)
client.authorizeTransaction(activity = this, paymeRequest = request)
```

## Implement the delegate

The `Activity` must implement `PaymeClientDelegate`:

```kotlin theme={"system"}
override fun onNotificate(action: PaymeInternalAction) {
    // Flow telemetry: scoring, 3DS, and authorization.
}

override fun onRespondsPayme(response: PaymeResponse) {
    if (response.success && response.payment?.accepted == true) {
        // Confirm the order using operationNumber.
    } else {
        // Process resultCode, resultMessage, and resultDetail.
    }
}
```

<Warning>
  Do not log real personal data. Switch to `PRODUCTION` only with the production Key and configuration approved for that environment.
</Warning>
