pixcli
API Reference

pix-efi

Efí (Gerencianet) API client with mTLS authentication

The pix-efi crate provides a complete client for the Efí (formerly Gerencianet) Pix API. It handles OAuth2 authentication, mTLS certificate management, and all Pix operations.

[dependencies]
pix-efi = "0.1"

EfiClient

Creating a Client

use pix_efi::{EfiClient, EfiConfig};

let config = EfiConfig {
    client_id: "your_client_id".to_string(),
    client_secret: "your_client_secret".to_string(),
    certificate_path: "/path/to/cert.p12".to_string(),
    certificate_password: "".to_string(),
    sandbox: true,
};

let client = EfiClient::new(config)?;

Authentication

The client handles OAuth2 token management automatically. Tokens are cached and refreshed when expired.

// Authentication happens automatically on first API call
let balance = client.get_balance().await?;

Charge Operations

Create a Charge

use pix_provider::{ChargeRequest, Debtor};

let request = ChargeRequest {
    amount: "25.00".to_string(),
    pix_key: "+5511999999999".to_string(),
    description: Some("Order #123".to_string()),
    expiration: Some(3600),
    debtor: Some(Debtor {
        name: "João Silva".to_string(),
        document: "12345678901".to_string(),
    }),
    txid: None,
};

let charge = client.create_charge(request).await?;
println!("TxID: {}", charge.txid);
println!("Status: {}", charge.status);
println!("BR Code: {}", charge.brcode.unwrap_or_default());

Get a Charge

let charge = client.get_charge("abc123def456").await?;
println!("Status: {}", charge.status);

List Charges

use pix_provider::TransactionFilter;
use chrono::{Utc, Duration};

let filter = TransactionFilter {
    start: Some(Utc::now() - Duration::days(7)),
    end: Some(Utc::now()),
    page: None,
    per_page: None,
};

let charges = client.list_charges(filter).await?;
for charge in charges {
    println!("{}: R${} ({})", charge.txid, charge.amount, charge.status);
}

Pix Transaction Operations

List Received Transactions

let filter = TransactionFilter {
    start: Some(Utc::now() - Duration::days(7)),
    end: Some(Utc::now()),
    page: None,
    per_page: None,
};

let transactions = client.list_pix(filter).await?;
for tx in transactions {
    println!("{}: R${}", tx.e2eid, tx.amount);
}

Get a Transaction

let tx = client.get_pix("E12345678901234567890123456").await?;
println!("Amount: R${}", tx.amount);
println!("Payer: {}", tx.payer_name.unwrap_or_default());

Balance

let balance = client.get_balance().await?;
println!("Available: R${}", balance.available);

Webhook Management

// Register
client.register_webhook("+5511999999999", "https://example.com/webhook").await?;

// Get
let webhook = client.get_webhook("+5511999999999").await?;
println!("URL: {}", webhook.url);

// Remove
client.remove_webhook("+5511999999999").await?;

Error Handling

use pix_efi::EfiError;

match client.get_balance().await {
    Ok(balance) => println!("Balance: R${}", balance.available),
    Err(EfiError::Auth(msg)) => eprintln!("Authentication failed: {}", msg),
    Err(EfiError::Api { status, message }) => {
        eprintln!("API error ({}): {}", status, message);
    }
    Err(EfiError::Certificate(msg)) => eprintln!("Certificate error: {}", msg),
    Err(e) => eprintln!("Unexpected error: {}", e),
}

Full API Documentation

For the complete auto-generated API reference, see docs.rs/pix-efi.

On this page