Welcome to the official Asaas API SDK for .NET 8 documentation.
This guide will help you get started with integrating and using the Asaas SDK in your .NET project.
- API version:
3.0.0 - SDK version:
1.1.5 - .NET version:
8.0
API pública de integração com a plataforma Asaas.
- Setup & Configuration
- Authentication
- Environments
- Setting a Custom Timeout
- Sample Usage
- Services
- Models
- License
This SDK is compatible with: .NET 8.0 or higher
dotnet add package TorinoInfo.AsaasSdk --version 1.1.5Install-Package TorinoInfo.AsaasSdk -Version 1.1.5Add the following to your .csproj file:
<PackageReference Include="TorinoInfo.AsaasSdk" Version="1.1.5" />The Asaas SDK uses API keys as a form of authentication. An API key is a unique identifier used to authenticate a user, developer, or a program that is calling the API.
When you initialize the SDK, you can set the API key as follows:
using Asaas.Sdk;
using Asaas.Sdk.Config;
var config = new AsaasSdkConfig
{
ApiKeyAuthConfig = new ApiKeyAuthConfig
{
ApiKey = "YOUR_API_KEY",
ApiKeyHeader = "access_token"
}
};
var asaasSdk = new AsaasSdk(config);If you need to set or update the API key after initializing the SDK, you can use:
asaasSdk.SetApiKey("YOUR_API_KEY");
asaasSdk.SetApiKeyHeader("access_token");The SDK supports different environments for various stages of development and deployment.
Here are the available environments:
Environment.Default // https://api.asaas.com/
Environment.Production // https://api.asaas.com/
Environment.Sandbox // https://api-sandbox.asaas.com/To configure the SDK to use a specific environment, you can set the base URL as follows:
using Asaas.Sdk;
using Asaas.Sdk.Config;
using Asaas.Sdk.Http;
var config = new AsaasSdkConfig();
var asaasSdk = new AsaasSdk(config);
asaasSdk.SetEnvironment(Environment.Sandbox);You can set a custom timeout for the SDK's HTTP requests as follows:
using Asaas.Sdk;
using Asaas.Sdk.Config;
var config = new AsaasSdkConfig
{
Timeout = TimeSpan.FromSeconds(30)
};
var asaasSdk = new AsaasSdk(config);Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
using Asaas.Sdk;
using Asaas.Sdk.Config;
using Asaas.Sdk.Models;
using Asaas.Sdk.Exceptions;
var config = new AsaasSdkConfig
{
ApiKeyAuthConfig = new ApiKeyAuthConfig
{
ApiKey = "YOUR_API_KEY"
}
};
var asaasSdk = new AsaasSdk(config);
try
{
var parameters = new ListPaymentsParameters
{
Offset = 0,
Limit = 10
};
var response = await asaasSdk.Payment.ListPaymentsAsync(parameters);
Console.WriteLine($"Total: {response.TotalCount}");
foreach (var payment in response.Data)
{
Console.WriteLine($"Payment ID: {payment.Id}, Value: {payment.Value}");
}
}
catch (ApiException ex)
{
Console.WriteLine($"Error: {ex.Message} (Status Code: {ex.StatusCode})");
}The SDK provides comprehensive services to interact with the Asaas API:
- PaymentService - Create, update, delete, and manage payments
- PaymentLinkService - Generate and manage payment links
- PaymentDunningService - Manage payment collection processes
- PaymentRefundService - Process payment refunds
- PaymentSplitService - Manage payment splits between accounts
- PaymentDocumentService - Manage payment-related documents
- PaymentWithSummaryDataService - Get payment data with summary information
- InstallmentService - Manage installment payments
- SubscriptionService - Manage recurring subscriptions
- CheckoutService - Manage checkout sessions
- CustomerService - Create and manage customers
- PixService - Manage PIX keys and QR codes
- PixTransactionService - Process PIX transactions
- RecurringPixService - Manage recurring PIX payments
- TransferService - Manage transfers and withdrawals
- AnticipationService - Manage payment anticipations
- FinancialTransactionService - Track financial transactions
- FinanceService - Get balance and financial statistics
- BillService - Pay bills and utilities
- MobilePhoneRechargeService - Process mobile phone recharges
- EscrowAccountService - Manage escrow accounts
- AccountInfoService - Manage account information
- AccountDocumentService - Manage account documents
- FiscalInfoService - Manage fiscal information
- SubaccountService - Manage subaccounts
- WebhookService - Configure webhook endpoints
- NotificationService - Manage customer notifications
- InvoiceService - Generate and manage invoices
- ChargebackService - Handle chargeback disputes
- CreditBureauReportService - Request credit reports
- CreditCardService - Tokenize credit cards
- SandboxActionsService - Simulate events in sandbox environment
All services are accessible through the main AsaasSdk client instance.
The SDK includes comprehensive models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
This SDK is licensed under the MIT License.