chargily.epay.csharp 2.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package chargily.epay.csharp --version 2.0.0                
NuGet\Install-Package chargily.epay.csharp -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="chargily.epay.csharp" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add chargily.epay.csharp --version 2.0.0                
#r "nuget: chargily.epay.csharp, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install chargily.epay.csharp as a Cake Addin
#addin nuget:?package=chargily.epay.csharp&version=2.0.0

// Install chargily.epay.csharp as a Cake Tool
#tool nuget:?package=chargily.epay.csharp&version=2.0.0                

<img src="" width="300">

Nuget Pacakge Downloads
Latest version Downloads

Chargily ePay Gateway C# Package

This package supports the following frameowrks and platforms:

Framework Support Platform
Console Windows, Linux, macOS
ASP.NET Core Windows, Linux, macOS
Blazor WASM Windows, Linux, macOS
Blazor Server Windows, Linux, macOS
.NET MAUI Windows, Linux, macOS, Android, iOS, Tizen
Xamarin Android, iOS
ASP.NET Windows
WPF Windows
AvaloniaUI Windows, Linux, macOS
UWP Windows, Xbox OS
WinForms Windows

Any C# application that uses Microsoft.Extensions.DependencyInjection can use this package

Chargily ePay Gateway

Integrate ePayment gateway with Chargily easily.

  • Currently support payment by CIB / EDAHABIA cards and soon by Visa / Mastercard
  • This is a C#.NET Nuget Package, If you are using another programing language Browse here or look to API documentation


First, install the chargily.epay.csharp NuGet package into your app

Using DotNet CLI :
dotnet add chargily.epay.csharp
Using Visual Studio Dev Console:
Install-Package chargily.epay.csharp
Using Visual Studio IDE:


  1. Get your API Key/Secret from ePay by Chargily dashboard for free

How to use

Installation & Project Creation Video Guide

Implemention of the code below:

Usage with any generic C# Project:

this package provide ChargilyEpayClient client, to create payment request use:

using Chargily.Epay;

var client = ChargilyEpay.CreateClient("[API_KEY]");

var payment = new EpayPaymentRequest()
    InvoiceNumber = "[INVOICE_NUMBER]",
    Name = "Ahmed",
    Email = "",
    Amount = 1500,
    DiscountPercentage = 5.0,
    PaymentMethod = PaymentMethod.EDAHABIA,
    BackUrl = "",
    WebhookUrl = "",
    ExtraInfo = "Product Purchase"

var response = await client.CreatePayment(payment);

Usage with ASP.NET Core

Video Guide how to use with Minimal API


Video Guide how to use with ASP.NET Core WebAPI


this applies to:

  • ASP.NET Core WebAPI
  • ASP.NET Core Minimal WebAPI
  • Blazor Server
  • Blazor WASM
  • ASP.NET Core MVC
using Chargily.Epay;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);


var app = builder.Build();

    async ([FromBody] EpayPaymentRequest request,
        [FromServices] IChargilyEpayClient<EpayPaymentResponse, EpayPaymentRequest> chargilyClient) =>
        return await chargilyClient.CreatePayment(request);



    "invoice_number" : "321616",
    "client" : "Ahmed",
    "client_email" : "",
    "amount" : 1500,
    "discount" : 5.0,
    "mode" : "EDAHABIA",
    "back_url" : "",
    "webhook_url" : "",
    "comment" : "Product Purchase"


    "httpStatusCode": 201,
    "responseMessage": {
        "Message": "Success"
    "isSuccessful": true,
    "isRequestValid": true,
    "body": {
        "checkout_url": ""
    "createdOn": "2022-05-06T03:55:49.6527862+01:00"

WebHook Validation:

using Chargily.Epay;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);


var app = builder.Build();
            ([FromServices] IWebHookValidator validator, HttpRequest request, [FromBody] ChargilyWebhookRequest body) =>
                var signature = request.Headers["Signature"].First();
                var isValid   = validator.Validate(signature, request.Body);
                if (isValid) return Results.Ok(body.Invoice);
                return Results.Unauthorized();



API_KEY & APP_SECRET can be added directly in code or from appsettings.json configuration file


// OR


// OR
// Same as previous but it will be loaded automatically from appsettings.json

appsettings.json file:

  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
  "AllowedHosts": "*",

ASP.NET Core Middleware

This package provide WebHookValidatorMiddleware ASP.NET Core Middleware, when registered every POST request that have a Signature Http Header will be validated automatically. How to register the Middleware:

using Chargily.Epay;

var builder = WebApplication.CreateBuilder(args);


    .AddChargilyValidatorMiddleware("[APP_SECRET]"); // WebHookValidatorMiddleware have to be registered

var app = builder.Build();



Usage with .NET MAUI

using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Chargily.Epay;

namespace MyApp
  public static class MauiProgram
    public static MauiApp CreateMauiApp()
      var builder = MauiApp.CreateBuilder();
      return builder.Build();

then you can add in ViewModels:

public class MainViewModel : ViewModelBase  
    private ChargilyEpayClient _chargilyClient;  
    private IWebHookValidator _webhookValidator;

    public MainViewModel(ChargilyEpayClient chargilyClient)  
        _chargilyClient = chargilyClient;  
    // With Validator
    public MainViewModel(ChargilyEpayClient chargilyClient, IWebHookValidator webhookValidator)  
        _chargilyClient = chargilyClient;  
        _webhookValidator = webhookValidator;

Note when using .NET MAUI / Xamarin:

storing sensitive APP_SECRET in a frontend app is not a recommended approach, you'd be better off calling a backend api to handle payment, but it's doable. if you decide to use it in the frontend, consider storing APP_SECRET with Akavache BlobCache.Secure

This package is using Microsoft.Extensions.DependencyInjection dependancy injection, so it can be used with application or framework using it.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated