Obrigado pelo seu interesse no Pacote C# do Chargily Pay™, um projeto de código aberto da Chargily, uma empresa fintech líder na Argélia, especializada em soluções de pagamento e facilitação de comércio eletrônico. Este pacote fornece a maneira mais fácil e gratuita de integrar o pagamento eletrônico API através de métodos de pagamento difundidos na Argélia, como EDAHABIA (Algerie Post) e CIB (SATIM) em seus projetos C#/ASP.NET.
Este pacote foi desenvolvido por Ahmed Chakhoum (rainxh11) e está aberto a contribuições de desenvolvedores como você.
Pacote Nuget | Transferências |
---|---|
Carregadamente.Pagar: | |
Chargily.Pay.AspNet: |
Somente .NET6.0
e versões mais recentes são suportadas.
NOTA: A capacidade de receber o status de checkout com o endpoint Webhook só é possível com tipos de projeto que podem hospedar um servidor 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 ) ;
NOTA: O checkout pode ser criado com lista de preços ou utilizando valor + moeda.
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 ( ) ;
No exemplo acima, o Chargily.Pay.AspNet
fornece middleware validador de assinatura de webhook integrado, você pode registrá-lo com builder.Services.AddChargilyPayWebhookValidationMiddleware()
e usá-lo com app.UseChargilyPayWebhookValidation()
.
Ele validará qualquer solicitação POST
que tenha um nome de cabeçalho: signature
. Você pode substituir o nome do cabeçalho por app.UseChargilyPayWebhookValidation("another_name")
.
Também integrou um endpoint mínimo de webapi que pode ser registrado com app.MapChargilyPayWebhookEndpoint()
e usá-lo para acessar o corpo do webhook sem manipular manualmente a validação.
Chargily.Pay
e Chargily.Pay.AspNet
podem ser gerados usando este comando: docker build . -- output = . / output
.nupkg
serão salvos na pasta ./output
Os pacotes/plugins Chargily Pay™ são uma coleção de projetos de código aberto publicados pela Chargily para facilitar a integração do nosso gateway de pagamento em diferentes linguagens e estruturas de programação. Nosso objetivo é capacitar desenvolvedores e empresas, fornecendo ferramentas fáceis de usar para aceitar pagamentos sem problemas.
Para obter instruções detalhadas sobre como integrar-se à nossa API e utilizar Chargily Pay™ em seus projetos, consulte nossa documentação da API.
Junte-se à nossa comunidade de desenvolvedores no Telegram para se conectar com outros desenvolvedores, fazer perguntas e ficar atualizado sobre as últimas notícias e desenvolvimentos relacionados ao Chargily Pay™: Comunidade Telegram
Aceitamos contribuições de todos os tipos, sejam correções de bugs, melhorias de recursos, melhorias de documentação ou desenvolvimento de novos plugins/pacotes. Veja como você pode começar:
Bifurque o Repositório: Clique no botão "Fork" no canto superior direito desta página para criar sua própria cópia do repositório.
Clone o repositório: Clone seu repositório bifurcado em sua máquina local usando o seguinte comando:
git clone https://github.com/Chargily/chargily-pay-csharp.git
Faça alterações: faça as alterações ou adições desejadas à base de código. Certifique-se de seguir nossos padrões e diretrizes de codificação.
Teste suas alterações: teste suas alterações minuciosamente para garantir que funcionem conforme o esperado.
Envie uma solicitação pull: quando estiver satisfeito com suas alterações, envie uma solicitação pull de volta ao repositório principal. Nossa equipe analisará suas contribuições e fornecerá feedback, se necessário.
Tem dúvidas ou precisa de ajuda? Junte-se à nossa comunidade de desenvolvedores no Telegram e conecte-se com outros desenvolvedores e nossa equipe.
Agradecemos seu interesse em contribuir para Chargily Pay™! Juntos, podemos construir algo incrível.
Boa codificação!