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

# Kotlin

> Integre a AbacatePay em aplicações Android e Kotlin em minutos.

<Card title="AbacatePay Kotlin SDK" icon="github" href="https://github.com/AbacatePay/abacatepay-kotlin-sdk">
  Repositório oficial — issues, changelog e contribuições.
</Card>

## Pré-requisitos

* Kotlin 2+ e Java 11+
* Android 5+ (se for app Android)
* Uma chave de API ([criar no dashboard](https://app.abacatepay.com))

## Instalação

Adicione ao `build.gradle.kts`:

```kotlin theme={null}
repositories {
    mavenCentral()
    maven { url = uri("https://jitpack.io") }
}

dependencies {
    implementation("com.github.abacatepay:abacatepay-kotlin-sdk:0.0.5")
}
```

## Configuração

Armazene sua chave de API em uma variável de ambiente ou arquivo seguro e nunca no código:

```kotlin theme={null}
import com.abacatepay.AbacatePayClient

val client = AbacatePayClient(apiKey = BuildConfig.ABACATEPAY_API_KEY)
```

## Primeira cobrança

```kotlin theme={null}
import kotlinx.coroutines.runBlocking
import com.abacatepay.models.*

runBlocking {
    val billing = client.createBilling(
        frequency     = BillingFrequency.ONE_TIME,
        methods       = listOf(BillingMethod.PIX),
        returnUrl     = "https://meusite.com/app",
        completionUrl = "https://meusite.com/pagamento/sucesso",
        products = listOf(
            BillingProduct(
                externalId = "PRO-PLAN",
                name       = "Pro plan",
                quantity   = 1,
                price      = 1000, // em centavos
            )
        ),
    )

    println(billing.url) // URL de pagamento para o cliente
}
```

**Resposta:**

```json theme={null}
{
  "success": true,
  "error": null,
  "data": {
    "id": "bill_12345667",
    "url": "https://app.abacatepay.com/pay/bill_12345667",
    "amount": 1000,
    "status": "PENDING",
    "devMode": true,
    "createdAt": "2024-11-04T18:38:28.573Z"
  }
}
```

## Próximos passos

<CardGroup cols={2}>
  <Card title="Configurar webhooks" icon="bell" href="/pages/webhooks">
    Receba notificações em tempo real sobre pagamentos confirmados.
  </Card>

  <Card title="Checkout Transparente" icon="credit-card" href="/pages/transparents/create">
    Aceite PIX e cartão diretamente na sua interface.
  </Card>

  <Card title="Criar clientes" icon="users" href="/pages/client/create">
    Gerencie clientes vinculados às cobranças.
  </Card>

  <Card title="Referência completa" icon="book-open" href="/pages/reference/introduction">
    Todos os endpoints, status codes e formato de resposta.
  </Card>
</CardGroup>
