![]() |
VOOZH | about |
This package is now maintained under the Chargily Organization, Any future releases, updates & bugfixes will only be pushed to it
dotnet add package Chargily.EpayGateway.NET --version 1.0.13
NuGet\Install-Package Chargily.EpayGateway.NET -Version 1.0.13
<PackageReference Include="Chargily.EpayGateway.NET" Version="1.0.13" />
<PackageVersion Include="Chargily.EpayGateway.NET" Version="1.0.13" />Directory.Packages.props
<PackageReference Include="Chargily.EpayGateway.NET" />Project file
paket add Chargily.EpayGateway.NET --version 1.0.13
#r "nuget: Chargily.EpayGateway.NET, 1.0.13"
#:package Chargily.EpayGateway.NET@1.0.13
#addin nuget:?package=Chargily.EpayGateway.NET&version=1.0.13Install as a Cake Addin
#tool nuget:?package=Chargily.EpayGateway.NET&version=1.0.13Install as a Cake Tool
<img src="https://raw.githubusercontent.com/chargily/epay-gateway-csharp/master/assets/chargily.svg" width="300">
| 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
Integrate ePayment gateway with Chargily easily.
First, install the Chargily.EpayGateway.NET NuGet package into your app
dotnet add Chargily.EpayGateway.NET
Install-Package Chargily.EpayGateway.NET
this package provide ChargilyEpayClient client, to create payment request use:
using Chargily.EpayGateway.NET;
var client = ChagilyEpay.CreateClient("[API_KEY]");
var payment = new EpayPaymentRequest()
{
InvoiceNumber = "[INVOICE_NUMBER]",
Name = "Ahmed",
Email = "rainxh11@gmail.com",
Amount = 1500,
DiscountPercentage = 5.0,
PaymentMethod = PaymentMethod.EDAHABIA,
BackUrl = "https://yourapp.com/",
WebhookUrl = "https://api.yourbackend.com/webhook-validator",
ExtraInfo = "Product Purchase"
};
var response = await client.CreatePayment(payment);
using Chargily.EpayGateway.NET;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddChargilyEpayGateway("[API_KEY]");
var app = builder.Build();
app.MapPost("/invoice",
async ([FromBody] EpayPaymentRequest request,
[FromServices] IChargilyEpayClient<EpayPaymentResponse, EpayPaymentRequest> chargilyClient) =>
{
return await chargilyClient.CreatePayment(request);
});
app.Run();
{
"invoice_number" : "321616",
"client" : "Ahmed",
"client_email" : "rainxh11@gmail.com",
"amount" : 1500,
"discount" : 5.0,
"mode" : "EDAHABIA",
"back_url" : "https://example.com/",
"webhook_url" : "https://shop.com/purchase",
"comment" : "Product Purchase"
}
{
"httpStatusCode": 201,
"responseMessage": {
"Message": "Success"
},
"isSuccessful": true,
"isRequestValid": true,
"body": {
"checkout_url": "https://epay.chargily.com.dz/checkout/d00c1e652200798bbc35f688b2910fa9bc6c4c30d38b51e3f4142e407fa7c141"
},
"createdOn": "2022-05-06T03:55:49.6527862+01:00"
}
using Chargily.EpayGateway.NET;
using Microsoft.AspNetCore.Mvc;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddChargilyWebHookValidator("[APP_SECRET]");
var app = builder.Build();
app.MapPost("/webhook-validator", ([FromServices] IWebHookValidator validator, HttpRequest request) =>
{
var signature = request.Headers["Signature"].First();
var validation = validator.Validate(signature, request.Body);
return validation;
});
app.Run();
API_KEY & APP_SECRET can be added directly in code or from appsettings.json configuration file
builder.Services.AddChargilyWebHookValidator("[APP_SECRET]");
builder.Services.AddChargilyEpayGateway("[API_KEY]");
// OR
builder.Services.AddChargilyWebHookValidator(builder.Configuration["CHARGILY_APP_SECRET"]);
builder.Services.AddChargilyEpayGateway(builder.Configuration["CHARGILY_API_KEY"]);
// OR
// Same as previous but it will be loaded automatically from appsettings.json
builder.Services.AddChargilyWebHookValidator());
builder.Services.AddChargilyEpayGateway();
appsettings.json file:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"CHARGILY_APP_SECRET": "[APP_SECRET]", // <-- APP SECRET
"CHARGILY_API_KEY": "[API_KEY]" // <-- API KEY
}
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.EpayGateway.NET;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddChargilyEpayGateway("[API_KEY]");
builder.Services
.AddChargilyValidatorMiddleware("[APP_SECRET]"); // WebHookValidatorMiddleware have to be registered
var app = builder.Build();
app.UseChargilyValidatorMiddleware();
app.Run();
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace MyApp
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>();
builder.Services.AddChargilyEpayGateway("[API_KEY]");
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;
}
}
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
Microsoft.Extensions.DependencyInjection dependancy injection, so it can be used with application or framework using it.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.0.13 | 1,169,201 | 7/13/2022 | 1.0.13 is deprecated. |
| 1.0.12 | 777 | 7/13/2022 | |
| 1.0.11 | 638 | 7/13/2022 | |
| 1.0.10 | 75,869 | 5/31/2022 | |
| 1.0.9 | 629 | 5/31/2022 | |
| 1.0.8 | 82,998 | 5/8/2022 | |
| 1.0.7 | 628 | 5/6/2022 | |
| 1.0.6 | 631 | 5/6/2022 | |
| 1.0.5 | 625 | 5/6/2022 | |
| 1.0.4 | 636 | 5/6/2022 | |
| 1.0.3 | 716 | 5/6/2022 | 1.0.3 is deprecated because it is no longer maintained and has critical bugs. |
| 1.0.1 | 1,334 | 5/5/2022 | 1.0.1 is deprecated because it is no longer maintained. |
| 1.0.0 | 1,365 | 5/5/2022 | 1.0.0 is deprecated because it is no longer maintained. |