⚠ Deprecated: Other
This package is now maintained under the Chargily Organization, Any future releases, updates & bugfixes will only be pushed to it
Suggested alternative: chargily.epay.csharp
C# .NET Library to use Chargily Epay Payment Gateway
$ dotnet add package Chargily.EpayGateway.NET
Integrate ePayment gateway with Chargily easily.
First, install the Chargily.EpayGateway.NET NuGet package into your app
PM> Install-Package Chargily.EpayGateway.NET
The package needs to be configured with your account's secret key, which is available in the ePay Dashboard.
this package provide ChargilyEpayClient client, to create payment request use:
using Chargily.EpayGateway.NET;
var client = ChagilyEpay.CreateClient("[API_KEY]");
var payment = new PaymentRequest()
{
InvoiceNumber = "[SOME_INVOICE_NUMER]"
Name = "Ahmed",
Email = "rainxh11@gmail.com",
Amount = 1500,
DiscountPercentage = 5.0,
PaymentMethod = PaymentMethod.EDAHABIA,
RedirectBackTo = "https://example.com/",
CameFrom = "https://shop.com/purchase",
ExtraInfo = "Product Purchase"
};
var response = await client.CreatePayment(payment);
using Chargily.EpayGateway.NET;
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.Adapt<EpayPaymentRequest>());
});
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 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;
public MainViewModel(ChargilyEpayClient chargilyClient)
{
_chargilyClient = chargilyClient;
}
...
}
Microsoft.Extensions.DependencyInjection dependancy injection, so it can be used with application or framework using it.