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 Rust SDK Repositório oficial — issues, changelog e contribuições.
Pré-requisitos
Instalação
cargo add abacatepay-rust-sdk
cargo add tokio --features full
Ou adicione ao Cargo.toml:
[ dependencies ]
abacatepay-rust-sdk = "0.1.0"
tokio = { version = "1" , features = [ "full" ] }
Configuração
Armazene sua chave de API em uma variável de ambiente e nunca no código:
use abacatepay_rust_sdk :: AbacatePay ;
let api_key = std :: env :: var ( "ABACATEPAY_API_KEY" ) . expect ( "ABACATEPAY_API_KEY not set" );
let client = AbacatePay :: new ( api_key );
Primeira cobrança
use abacatepay_rust_sdk :: {
AbacatePay , BillingKind , BillingMethods , CreateBillingData , CreateBillingProduct ,
};
#[tokio :: main]
async fn main () -> Result <(), Box < dyn std :: error :: Error >> {
let client = AbacatePay :: new ( std :: env :: var ( "ABACATEPAY_API_KEY" ) ? );
let billing = client . create_billing ( CreateBillingData {
frequency : BillingKind :: OneTime ,
methods : vec! [ BillingMethods :: Pix ],
return_url : "https://meusite.com/app" . to_string (),
completion_url : "https://meusite.com/pagamento/sucesso" . to_string (),
products : vec! [ CreateBillingProduct {
external_id : "PRO-PLAN" . to_string (),
name : "Pro plan" . to_string (),
quantity : 1 ,
price : 1000.0 , // em centavos
description : None ,
}],
customer_id : None ,
}) . await ? ;
println! ( "{}" , billing . url); // URL de pagamento para o cliente
Ok (())
}
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.