Skip to main content

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.

AbacatePay Kotlin SDK

Repositório oficial — issues, changelog e contribuições.

Pré-requisitos

  • Kotlin 2+ e Java 11+
  • Android 5+ (se for app Android)
  • Uma chave de API (criar no dashboard)

Instalação

Adicione ao build.gradle.kts:
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:
import com.abacatepay.AbacatePayClient

val client = AbacatePayClient(apiKey = BuildConfig.ABACATEPAY_API_KEY)

Primeira cobrança

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:
{
  "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

Configurar webhooks

Receba notificações em tempo real sobre pagamentos confirmados.

Checkout Transparente

Aceite PIX e cartão diretamente na sua interface.

Criar clientes

Gerencie clientes vinculados às cobranças.

Referência completa

Todos os endpoints, status codes e formato de resposta.