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 Swift SDK

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

Pré-requisitos

Instalação

dependencies: [
    .package(url: "https://github.com/AbacatePay/abacatepay-swift-sdk", from: "1.0.0")
]

Configuração

Armazene sua chave de API em variáveis de configuração ou no Keychain e nunca no código:
import AbacatePay

let abacatePay = AbacatePay(apiKey: ProcessInfo.processInfo.environment["ABACATEPAY_API_KEY"]!)

Primeira cobrança

let billingData = CreateBillingData(
    frequency:    .oneTime,
    methods:      [.pix],
    returnUrl:    "https://meusite.com/app",
    completionUrl: "https://meusite.com/pagamento/sucesso",
    products: [
        .init(externalId: "PRO-PLAN", name: "Pro plan", quantity: 1, price: 1000)
    ]
)

do {
    let billing = try await abacatePay.billing.create(data: billingData)
    print(billing.url) // URL de pagamento para o cliente
} catch {
    print("Erro:", error)
}
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.