Merci de votre intérêt pour le package C# de Chargily Pay™, un projet open source de Chargily, une société fintech leader en Algérie spécialisée dans les solutions de paiement et la facilitation du commerce électronique, ce package fournit le moyen le plus simple et gratuit d'intégrer le paiement électronique. API via les moyens de paiement répandus en Algérie tels que EDAHABIA (La Poste Algérie) et CIB (SATIM) dans vos projets C#/ASP.NET.
Ce package est développé par Ahmed Chakhoum (rainxh11) et est ouvert aux contributions de développeurs comme vous.
Paquet de nugets | Téléchargements |
---|---|
Chargily.Payer : | |
Chargily.Pay.AspNet : |
Seuls .NET6.0
et les versions plus récentes sont pris en charge.
REMARQUE : La possibilité de recevoir l'état de paiement avec le point de terminaison Webhook n'est possible qu'avec les types de projets pouvant héberger un serveur HTTP.
dotnet add Chargily.Pay
using Chargily . Pay ;
var chargilyClient = ChargilyPay . CreateResilientClient ( config =>
{
// toggle live mode
config . IsLiveMode = false ;
// your chargily dev account api-secret key
config . ApiSecretKey = "YOUR API SECRET" ;
} ) ;
var createProduct = new CreateProduct ( )
{
Name = "Product Name" ,
ImagesUrls = new List < Uri > ( )
{
new Uri ( "https://domain.com/image.png" )
} ,
Description = "Product Description" ,
} ;
var product = await _chargilyPayClient . AddProduct ( createProduct ) ;
var createPrice = new CreatePrice ( )
{
Amount = 3000 ,
Currency = Currency . DZD ,
ProductId = product . Value . Id ,
} ;
var productPrice = await chargilyClient . AddPrice ( createPrice ) ;
var checkoutItems = new List < CheckoutPriceItem > ( )
{
new CheckoutPriceItem ( )
{
Quantity = 1 ,
PriceId = productPrice . Value . Id
}
} ;
var createCheckout = new Checkout ( checkoutItems )
{
Description = "Checkout Description" ,
Language = LocaleType . Arabic ,
PaymentMethod = PaymentMethod . EDAHABIA ,
PassFeesToCustomer = true ,
WebhookEndpointUrl = new Uri ( "https://domain.com/webhook/endpoint" ) ,
OnFailureRedirectUrl = new Uri ( "https://webapp.com/checkout/fail" ) ,
OnSuccessRedirectUrl = new Uri ( "https://webapp.com/checkout/success" ) ,
CollectShippingAddress = false ,
} ;
var checkout = await chargilyClient . CreateCheckout ( createCheckout ) ;
var createCheckout = new Checkout ( amount : 3000 , Currency . DZD )
{
Description = "Checkout Description" ,
Language = LocaleType . Arabic ,
PaymentMethod = PaymentMethod . EDAHABIA ,
PassFeesToCustomer = true ,
WebhookEndpointUrl = new Uri ( "https://domain.com/webhook/endpoint" ) ,
OnFailureRedirectUrl = new Uri ( "https://webapp.com/checkout/fail" ) ,
OnSuccessRedirectUrl = new Uri ( "https://webapp.com/checkout/success" ) ,
CollectShippingAddress = false ,
} ;
var fastCheckout = await chargilyClient . CreateCheckout ( createCheckout ) ;
REMARQUE : Le paiement peut être créé avec une liste de prix ou en utilisant un montant + une devise.
var createProduct = new CreateProduct ( )
{
/* ... */
} ;
var product = await _chargilyPayClient . AddProduct ( createProduct ) ;
var createPrice = new CreatePrice ( )
{
/* ... */
} ;
var productPrice = await chargilyClient . AddPrice ( createPrice ) ;
// above steps are similar to how to create a checkout
var paymentLinkItems = new List < PaymentLinkPriceItem > ( )
{
new PaymentLinkPriceItem ( )
{
AdjustableQuantity = true ,
PriceId = productPrice . Value . Id ,
Quantity = 2
}
} ;
var createPaymentLink = new CreatePaymentLink ( paymentLinkItems )
{
Language = LocaleType . Arabic ,
PassFeesToCustomer = true ,
CollectShippingAddress = false ,
Name = "Name" ,
CompletionMessage = "completion message" ,
IsActive = true
} ;
var createCustomer = new CreateCustomer ( )
{
Name = "Customer Name" ,
Address = new CustomerAddress ( )
{
Address = "Address" ,
Country = Country . Algeria ,
State = "Alger"
} ,
Email = "[email protected]" ,
Phone = "+2130601010101"
} ;
var customer = await chargilyClient . AddCustomer ( createCustomer ) ;
var createCheckout = new Checkout ( amount : 3000 , Currency . DZD )
{
CustomerId = customer . Value . Id ,
/* .... */
} ;
var fastCheckout = await chargilyClient . CreateCheckout ( createCheckout ) ;
foreach ( var wallet in chargilyClient . Balance )
{
/* ... */
}
using Chargily . Pay ;
var chargilyClient = ChargilyPay . CreateResilientClient ( config =>
{
/* ... */
// refresh balance every 30 seconds
config . BalanceRefreshInterval = TimeSpan . FromSeconds ( 30 ) ;
} ) ;
var balance = await chargilyClient . GetBalance ( ) ;
// by id
var byId = await chargilyClient . GetProduct ( "id" ) ;
// by page number & page size
var products = await chargilyClient . GetProducts ( page : 1 , pageSize : 50 ) ;
// or iterate through all items using `Async Enumerable async foreach`
await foreach ( var product in chargilyClient . Products ( ) )
{
/* ... */
}
await chargilyClient . DeleteProduct ( "01hrtc39vq463jhnemv0q33mcq" ) ;
// by id
var byId = await chargilyClient . GetPrice ( "id" ) ;
// by page number & page size
var prices = await chargilyClient . GetPrices ( page : 1 , pageSize : 50 ) ;
// or iterate through all items using `IAsyncEnumerable async foreach`
await foreach ( var price in chargilyClient . Prices ( ) )
{
/* ... */
}
// by id
var byId = await chargilyClient . GetCustomer ( "id" ) ;
// by page number & page size
var customers = await chargilyClient . GetCustomers ( page : 1 , pageSize : 50 ) ;
// or iterate through all items using `IAsyncEnumerable async foreach`
await foreach ( var customer in chargilyClient . Customers ( ) )
{
/* ... */
}
await chargilyClient . DeleteCustomer ( "01hrsfjgvfvv1007y54y8fph1v" ) ;
// by id
var byId = await chargilyClient . GetCheckout ( "id" ) ;
// by page number & page size
var checkouts = await chargilyClient . GetCheckouts ( page : 1 , pageSize : 50 ) ;
// or iterate through all items using `IAsyncEnumerable async foreach`
await foreach ( var checkout in chargilyClient . Checkouts ( ) )
{
/* ... */
}
var checkoutItems = await chargilyClient . GetCheckoutItems ( "checkoutId" ) ;
// by id
var byId = await chargilyClient . GetPaymentLink ( "id" ) ;
// by page number & page size
var paymentLinks = await chargilyClient . GetPaymentLinks ( page : 1 , pageSize : 50 ) ;
// or iterate through all items using `IAsyncEnumerable async foreach`
await foreach ( var paymentLink in chargilyClient . PaymentLinks ( ) )
{
/* ... */
}
var paymentLinksItems = await chargilyClient . GetPaymentLinkItems ( "paymentLinkId" ) ;
Chargily.Pay.AspNet
Nuget : dotnet add Chargily.Pay.AspNet
using Chargily . Pay ;
using Chargily . Pay . AspNet ;
var builder = WebApplication . CreateBuilder ( args ) ;
builder . Services
// Register Chargily Pay Client
. AddGlobalChargilyPayClient ( config =>
{
// toggle live mode
config . IsLiveMode = false ;
// your chargily dev account api-secret key
config . ApiSecretKey = "YOUR API SECRET" ;
} )
// Register Chargily Pay Webhook Signature Validator
. AddChargilyPayWebhookValidationMiddleware ( ) ;
var app = builder . Build ( ) ;
// User Chargily Pay Webhook Signature Validator Middleware
app . UseChargilyPayWebhookValidation ( ) ;
// Map Webhook Endpoint to `both POST & GET /api/checkout-webhook`
app . MapChargilyPayWebhookEndpoint ( "/chargily/webhook" , async ( webhookContext ) =>
{
// you can access the webhook body, http context, validation result
if ( webhookContext . SignatureIsValid )
{
var body = webhookContext . Request ;
/* do something with the webhook request body */
}
} ) ;
app . Run ( ) ;
Dans l'exemple ci-dessus, Chargily.Pay.AspNet
fournit un middleware de validation de signature webhook intégré, vous pouvez l'enregistrer avec builder.Services.AddChargilyPayWebhookValidationMiddleware()
puis l'utiliser avec app.UseChargilyPayWebhookValidation()
.
Il validera toute requête POST
ayant un nom d'en-tête : signature
. Vous pouvez remplacer le nom de l'en-tête par app.UseChargilyPayWebhookValidation("another_name")
.
Également intégré un point de terminaison minimal-webapi qui peut être enregistré avec app.MapChargilyPayWebhookEndpoint()
et l'utiliser pour accéder au corps du webhook sans gérer manuellement la validation.
Chargily.Pay
et Chargily.Pay.AspNet
peuvent être générés à l'aide de cette commande : docker build . -- output = . / output
.nupkg
seront enregistrés dans le dossier ./output
Les packages/plugins Chargily Pay™ sont une collection de projets open source publiés par Chargily pour faciliter l'intégration de notre passerelle de paiement dans différents langages et frameworks de programmation. Notre objectif est de responsabiliser les développeurs et les entreprises en fournissant des outils faciles à utiliser pour accepter les paiements en toute transparence.
Pour des instructions détaillées sur la façon d'intégrer notre API et d'utiliser Chargily Pay™ dans vos projets, veuillez vous référer à notre documentation API.
Rejoignez notre communauté de développeurs sur Telegram pour vous connecter avec d'autres développeurs, poser des questions et rester informé des dernières nouvelles et développements liés à Chargily Pay™ : Communauté Telegram
Nous acceptons les contributions de toutes sortes, qu'il s'agisse de corrections de bugs, d'améliorations de fonctionnalités, d'améliorations de la documentation ou de développements de nouveaux plugins/packages. Voici comment commencer :
Fork the Repository : cliquez sur le bouton "Fork" dans le coin supérieur droit de cette page pour créer votre propre copie du référentiel.
Cloner le référentiel : clonez votre référentiel forké sur votre machine locale à l'aide de la commande suivante :
git clone https://github.com/Chargily/chargily-pay-csharp.git
Apporter des modifications : apportez les modifications ou ajouts souhaités à la base de code. Assurez-vous de suivre nos normes et directives de codage.
Testez vos modifications : testez minutieusement vos modifications pour vous assurer qu’elles fonctionnent comme prévu.
Soumettre une pull request : une fois que vous êtes satisfait de vos modifications, soumettez une pull request au référentiel principal. Notre équipe examinera vos contributions et vous fournira des commentaires si nécessaire.
Vous avez des questions ou besoin d'aide ? Rejoignez notre communauté de développeurs sur Telegram et connectez-vous avec d'autres développeurs et notre équipe.
Nous apprécions votre intérêt à contribuer à Chargily Pay™ ! Ensemble, nous pouvons construire quelque chose d'incroyable.
Bon codage !