Skip to main content
This SDK is coming soon. Subscribe to our changelog to be notified when it’s released.
The official .NET SDK for FYATU API v3, supporting C#, F#, and VB.NET.

Requirements

  • .NET 6.0 or higher
  • .NET Standard 2.1 (for legacy support)

Installation

dotnet add package Fyatu.SDK
Or via Package Manager:
Install-Package Fyatu.SDK

Quick Start

using Fyatu;
using Fyatu.Models;

var fyatu = new FyatuClient(new FyatuOptions
{
    AppId = "your_app_id",
    SecretKey = "your_secret_key"
});

// Create a collection
var collection = await fyatu.Collections.CreateAsync(new CreateCollectionRequest
{
    Amount = 10.00m,
    Currency = "USD",
    Reference = "order_123",
    Description = "Payment for Order #123",
    Customer = new Customer
    {
        Email = "[email protected]",
        Name = "John Doe"
    },
    RedirectUrl = "https://yoursite.com/payment/success",
    WebhookUrl = "https://yoursite.com/webhooks/fyatu"
});

Console.WriteLine(collection.CheckoutUrl);

ASP.NET Core Integration

Configuration

Add to appsettings.json:
{
  "Fyatu": {
    "AppId": "your_app_id",
    "SecretKey": "your_secret_key"
  }
}

Service Registration

// Program.cs
builder.Services.AddFyatu(builder.Configuration.GetSection("Fyatu"));

// Or with options
builder.Services.AddFyatu(options =>
{
    options.AppId = "your_app_id";
    options.SecretKey = "your_secret_key";
});

Controller Usage

[ApiController]
[Route("api/[controller]")]
public class PaymentsController : ControllerBase
{
    private readonly IFyatuClient _fyatu;

    public PaymentsController(IFyatuClient fyatu)
    {
        _fyatu = fyatu;
    }

    [HttpPost]
    public async Task<IActionResult> CreatePayment([FromBody] PaymentRequest request)
    {
        var collection = await _fyatu.Collections.CreateAsync(new CreateCollectionRequest
        {
            Amount = request.Amount,
            Currency = "USD",
            Reference = request.OrderId
        });

        return Ok(new { checkoutUrl = collection.CheckoutUrl });
    }
}

Features

  • .NET 6+ Support - Uses latest C# features and patterns
  • Dependency Injection - First-class DI support for ASP.NET Core
  • Async/Await - All methods are async by default
  • Strong Typing - Full type safety with nullable reference types
  • Automatic Token Management - Handles JWT refresh automatically
  • IHttpClientFactory - Proper HTTP connection management

Configuration Options

var fyatu = new FyatuClient(new FyatuOptions
{
    AppId = "your_app_id",
    SecretKey = "your_secret_key",

    // Optional configuration
    BaseUrl = "https://api.fyatu.com/api/v3",
    Timeout = TimeSpan.FromSeconds(30),
    MaxRetries = 3
});

Available Services

ServiceDescription
fyatu.CollectionsAccept payments via checkout
fyatu.RefundsManage refunds
fyatu.PayoutsSend money to recipients
fyatu.CardholdersManage cardholders
fyatu.CardsIssue and manage virtual cards
fyatu.EsimPurchase and manage eSIMs
fyatu.AccountAccess account information

Error Handling

using Fyatu.Exceptions;

try
{
    var payout = await fyatu.Payouts.CreateAsync(new CreatePayoutRequest
    {
        Amount = 100,
        Currency = "USD",
        RecipientId = "invalid_id"
    });
}
catch (ValidationException ex)
{
    Console.WriteLine($"Validation failed: {string.Join(", ", ex.Details)}");
}
catch (AuthenticationException ex)
{
    Console.WriteLine($"Authentication failed: {ex.Message}");
}
catch (InsufficientBalanceException ex)
{
    Console.WriteLine($"Insufficient balance: {ex.Message}");
}
catch (FyatuException ex)
{
    Console.WriteLine($"API error [{ex.Code}]: {ex.Message}");
}

Webhook Verification

using Fyatu.Webhooks;

[ApiController]
[Route("webhooks")]
public class WebhooksController : ControllerBase
{
    [HttpPost("fyatu")]
    public async Task<IActionResult> HandleFyatuWebhook()
    {
        var signature = Request.Headers["X-Fyatu-Signature"].FirstOrDefault();
        using var reader = new StreamReader(Request.Body);
        var payload = await reader.ReadToEndAsync();

        var isValid = WebhookValidator.VerifySignature(
            payload,
            signature,
            "your_webhook_secret"
        );

        if (!isValid)
        {
            return Unauthorized("Invalid signature");
        }

        var webhookEvent = WebhookEvent.Parse(payload);
        Console.WriteLine($"Received event: {webhookEvent.Type}");

        return Ok();
    }
}

Minimal API Example

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFyatu(builder.Configuration.GetSection("Fyatu"));

var app = builder.Build();

app.MapPost("/payments", async (IFyatuClient fyatu, PaymentRequest request) =>
{
    var collection = await fyatu.Collections.CreateAsync(new CreateCollectionRequest
    {
        Amount = request.Amount,
        Currency = "USD",
        Reference = Guid.NewGuid().ToString()
    });

    return Results.Ok(new { checkoutUrl = collection.CheckoutUrl });
});

app.Run();

Resources