شكرًا لك على اهتمامك بحزمة C# الخاصة بـ Chargily Pay™، وهو مشروع مفتوح المصدر من قبل Chargily، وهي شركة رائدة في مجال التكنولوجيا المالية في الجزائر متخصصة في حلول الدفع وتسهيل التجارة الإلكترونية، توفر هذه الحزمة الطريقة الأسهل والمجانية لدمج الدفع الإلكتروني API من خلال طرق الدفع المنتشرة في الجزائر مثل EDAHABIA (Algerie Post) و CIB (SATIM) في مشاريع C#/ASP.NET الخاصة بك.
تم تطوير هذه الحزمة بواسطة أحمد شخوم (rainxh11) وهي مفتوحة لمساهمات المطورين مثلك.
نوجيت باكاج | التنزيلات |
---|---|
تشارلي.الدفع: | |
Chargily.Pay.AspNet: |
يتم دعم .NET6.0
والإصدارات الأحدث فقط.
ملاحظة: القدرة على تلقي حالة الخروج باستخدام نقطة نهاية Webhook ممكنة فقط مع أنواع المشاريع التي يمكنها استضافة خادم 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 ) ;
ملحوظة: يمكن إنشاء الخروج بقائمة الأسعار أو باستخدام مبلغ + عملة.
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 ( ) ;
في المثال أعلاه، توفر Chargily.Pay.AspNet
برنامجًا وسيطًا مدمجًا للتحقق من توقيع webhook، ويمكنك تسجيله باستخدام builder.Services.AddChargilyPayWebhookValidationMiddleware()
ثم استخدامه مع app.UseChargilyPayWebhookValidation()
.
سيتم التحقق من صحة أي طلب POST
له اسم رأس: signature
. يمكنك تجاوز اسم الرأس باستخدام app.UseChargilyPayWebhookValidation("another_name")
.
تم أيضًا تضمين نقطة نهاية webapi الدنيا التي يمكن تسجيلها مع app.MapChargilyPayWebhookEndpoint()
واستخدامها للوصول إلى نص webhook دون التعامل مع التحقق يدويًا.
Chargily.Pay
و Chargily.Pay.AspNet
nuget باستخدام هذا الأمر: docker build . -- output = . / output
.nupkg
في مجلد ./output
حزم/مكونات Chargily Pay™ عبارة عن مجموعة من المشاريع مفتوحة المصدر التي تنشرها Chargily لتسهيل دمج بوابة الدفع الخاصة بنا في لغات وأطر برمجة مختلفة. هدفنا هو تمكين المطورين والشركات من خلال توفير أدوات سهلة الاستخدام لقبول المدفوعات بسلاسة.
للحصول على تعليمات مفصلة حول كيفية التكامل مع واجهة برمجة التطبيقات (API) الخاصة بنا واستخدام ™Chargily Pay في مشاريعك، يرجى الرجوع إلى وثائق واجهة برمجة التطبيقات (API) الخاصة بنا.
انضم إلى مجتمع المطورين لدينا على Telegram للتواصل مع زملائك المطورين وطرح الأسئلة والبقاء على اطلاع على آخر الأخبار والتطورات المتعلقة بـ Chargily Pay™: مجتمع Telegram
نحن نرحب بالمساهمات من جميع الأنواع، سواء كانت إصلاحات أخطاء، أو تحسينات للميزات، أو تحسينات للوثائق، أو تطويرات جديدة للمكونات الإضافية/الحزم. إليك كيف يمكنك البدء:
Fork the Repository: انقر فوق الزر "Fork" في الزاوية العلوية اليمنى من هذه الصفحة لإنشاء نسختك الخاصة من المستودع.
استنساخ المستودع: انسخ مستودعك المتشعب إلى جهازك المحلي باستخدام الأمر التالي:
git clone https://github.com/Chargily/chargily-pay-csharp.git
إجراء التغييرات: قم بإجراء التغييرات أو الإضافات المطلوبة إلى قاعدة التعليمات البرمجية. تأكد من اتباع معايير وإرشادات الترميز الخاصة بنا.
اختبر تغييراتك: اختبر تغييراتك بدقة للتأكد من أنها تعمل كما هو متوقع.
إرسال طلب سحب: بمجرد أن تصبح راضيًا عن التغييرات، أرسل طلب سحب مرة أخرى إلى المستودع الرئيسي. سيقوم فريقنا بمراجعة مساهماتك وتقديم الملاحظات إذا لزم الأمر.
هل لديك أسئلة أو بحاجة إلى المساعدة؟ انضم إلى مجتمع المطورين لدينا على Telegram وتواصل مع زملائك المطورين وفريقنا.
نحن نقدر اهتمامك بالمساهمة في Chargily Pay™! معًا، يمكننا بناء شيء مذهل.
ترميز سعيد!