Skip to main content
This guide will walk you through processing your first payment transaction using the Akatus .NET SDK. You’ll learn how to create a shopping cart, add customer information, add products, and process a payment.

Prerequisites

Before you begin, make sure you have:
  • Installed the Akatus .NET SDK (Installation Guide)
  • Configured your API credentials in Web.Config
  • Set AkatusAmbiente to testes for testing

Processing a Transaction

1

Create a new shopping cart

Initialize a new Carrinho instance to hold your transaction data:
using Akatus;
using Akatus.Carrinho;
using Akatus.Enums;

Carrinho carrinho = new Carrinho();
2

Add customer information

Set the customer’s name and email address:
// Customer name and email
carrinho.Pagador.Nome = "NOME CLIENTE";
carrinho.Pagador.Email = "[email protected]";
3

Add customer address

Add the customer’s delivery or billing address:
// Add customer address
PagadorEndereco endereco = new PagadorEndereco();
endereco.Tipo = TipoEndereco.entrega;
endereco.Logradouro = "Rua Teste da Silva";
endereco.Numero = 0;
endereco.Bairro = "CENTRO";
endereco.Cidade = "Salvador";
endereco.Estado = "BA";
endereco.Pais = "BRA";
endereco.CEP = "40000000";
carrinho.Pagador.Enderecos.Add(endereco);
Tipo can be TipoEndereco.entrega (delivery) or TipoEndereco.comercial (commercial).
4

Add customer phone number

Add the customer’s contact phone number:
// Add customer phone
PagadorTelefone telefone = new PagadorTelefone();
telefone.Tipo = TipoTelefone.celular;
telefone.Numero = "7199990000";
carrinho.Pagador.Telefones.Add(telefone);
Phone type options: TipoTelefone.celular (mobile), TipoTelefone.residencial (home), or TipoTelefone.comercial (business).
5

Add product to cart

Add one or more products to the shopping cart:
// Add product
Produto produto = new Produto();
produto.Codigo = "ABC1234567";
produto.Descricao = "Caixa de bombons sortidos";
produto.Quantidade = 1;
produto.Preco = 32.25m;
produto.Frete = 0;
produto.Peso = 0;
produto.Desconto = 0;
carrinho.Produtos.Add(produto);
6

Configure payment method

Choose your payment method. You can use either credit card or boleto (bank slip).
// Credit card payment
carrinho.Transacao.MeioDePagamento = MeioDePagamento.cartao_master;
carrinho.Transacao.Referencia = "OFP12345";

// Card details
carrinho.Transacao.Cartao.Numero = "5453010000066167";
carrinho.Transacao.Cartao.NumeroParcelas = 2;
carrinho.Transacao.Cartao.CodigoSeguranca = "123";
carrinho.Transacao.Cartao.Expiracao = "05/2018";

// Cardholder information
carrinho.Transacao.Cartao.Portador.Nome = "AUTORIZAR";
carrinho.Transacao.Cartao.Portador.CPF = "721.726.663-78";
carrinho.Transacao.Cartao.Portador.Telefone = "7199990000";

// Transaction details
carrinho.Transacao.Desconto = 0;
carrinho.Transacao.Peso = 0;
carrinho.Transacao.Frete = 0;
carrinho.Transacao.Moeda = "BRL";
Available payment methods: boleto, cartao_visa, cartao_master, cartao_amex, cartao_elo, cartao_diners, tef_itau, tef_bradesco.
7

Process the transaction

Send the cart to Akatus for processing:
// Process transaction
Retorno retorno = carrinho.processaTransacao();

// Check the result
if (retorno != null)
{
    // Transaction was sent successfully
    // Use retorno object to get transaction details
}

Complete Example

Here’s a complete working example that processes a credit card transaction:
Complete Transaction Example
using Akatus;
using Akatus.Carrinho;
using Akatus.Enums;

try
{
    // Create shopping cart
    Carrinho carrinho = new Carrinho();
    
    // Customer information
    carrinho.Pagador.Nome = "NOME CLIENTE";
    carrinho.Pagador.Email = "[email protected]";
    
    // Customer address
    PagadorEndereco endereco = new PagadorEndereco();
    endereco.Tipo = TipoEndereco.entrega;
    endereco.Logradouro = "Rua Teste da Silva";
    endereco.Numero = 0;
    endereco.Bairro = "CENTRO";
    endereco.Cidade = "Salvador";
    endereco.Estado = "BA";
    endereco.Pais = "BRA";
    endereco.CEP = "40000000";
    carrinho.Pagador.Enderecos.Add(endereco);
    
    // Customer phone
    PagadorTelefone telefone = new PagadorTelefone();
    telefone.Tipo = TipoTelefone.celular;
    telefone.Numero = "7199990000";
    carrinho.Pagador.Telefones.Add(telefone);
    
    // Add product
    Produto produto = new Produto();
    produto.Codigo = "ABC1234567";
    produto.Descricao = "Caixa de bombons sortidos";
    produto.Quantidade = 1;
    produto.Preco = 32.25m;
    produto.Frete = 0;
    produto.Peso = 0;
    produto.Desconto = 0;
    carrinho.Produtos.Add(produto);
    
    // Credit card payment
    carrinho.Transacao.MeioDePagamento = MeioDePagamento.cartao_master;
    carrinho.Transacao.Referencia = "OFP12345";
    carrinho.Transacao.Cartao.Numero = "5453010000066167";
    carrinho.Transacao.Cartao.NumeroParcelas = 2;
    carrinho.Transacao.Cartao.CodigoSeguranca = "123";
    carrinho.Transacao.Cartao.Expiracao = "05/2018";
    carrinho.Transacao.Cartao.Portador.Nome = "AUTORIZAR";
    carrinho.Transacao.Cartao.Portador.CPF = "721.726.663-78";
    carrinho.Transacao.Cartao.Portador.Telefone = "7199990000";
    
    carrinho.Transacao.Desconto = 0;
    carrinho.Transacao.Peso = 0;
    carrinho.Transacao.Frete = 0;
    carrinho.Transacao.Moeda = "BRL";
    
    // Process transaction
    Retorno retorno = carrinho.processaTransacao();
    
    // Handle successful response
    Response.Write("Transaction processed successfully!");
}
catch (Akatus.RestExcepction ex)
{
    // Handle API errors
    Response.Write("HTTP Status: " + ex.StatusCode);
    Response.Write("Description: " + ex.StatusDesciption);
    
    // Show error messages
    foreach (string error in ex.ErrorMessages)
    {
        Response.Write("Error: " + error);
    }
}
catch (Exception ex)
{
    // Handle general exceptions
    Response.Write("Exception: " + ex.Message);
}

Error Handling

Always wrap your Akatus API calls in try-catch blocks to handle errors gracefully:
Error Handling
try
{
    // Your Akatus code here
    Retorno retorno = carrinho.processaTransacao();
}
catch (Akatus.RestExcepction ex)
{
    // Handle Akatus-specific errors
    Console.WriteLine("HTTP Status: " + ex.StatusCode);
    Console.WriteLine("Description: " + ex.StatusDesciption);
    
    // Display all error messages
    foreach (string error in ex.ErrorMessages)
    {
        Console.WriteLine("Error: " + error);
    }
}
catch (Exception ex)
{
    // Handle general exceptions
    Console.WriteLine("Exception: " + ex.Message);
}
The RestExcepction class (note the typo in the class name) is used for all API-related errors. It provides the HTTP status code, description, and a list of error messages.

Testing

When testing transactions:
  • Ensure AkatusAmbiente is set to testes in your Web.Config
  • Use test card numbers provided by Akatus
  • Test cardholder name AUTORIZAR should approve the transaction
  • No real charges will be made in test mode

Next Steps

Now that you’ve processed your first transaction, explore more features:

Build docs developers (and LLMs) love