결제 솔루션 및 전자상거래 촉진을 전문으로 하는 알제리의 선도적인 핀테크 기업인 Chargily의 오픈 소스 프로젝트인 Chargily Pay™의 C# 패키지에 관심을 가져주셔서 감사합니다. 이 패키지는 전자 결제를 통합하는 가장 쉽고 무료인 방법을 제공합니다. EDAHABIA(Algerie Post) 및 CIB(SATIM)과 같은 알제리의 광범위한 결제 방법을 통해 C#/ASP.NET 프로젝트에 API를 사용하세요.
이 패키지는 Ahmed Chakhoum(rainxh11) 이 개발했으며 여러분과 같은 개발자의 기여에 열려 있습니다.
너겟 패키지 | 다운로드 |
---|---|
Chargily.지불: | |
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
내장된 웹훅 서명 유효성 검사기 미들웨어를 제공합니다. 이를 builder.Services.AddChargilyPayWebhookValidationMiddleware()
에 등록한 다음 app.UseChargilyPayWebhookValidation()
과 함께 사용할 수 있습니다.
헤더 이름이 signature
인 모든 POST
요청의 유효성을 검사합니다. app.UseChargilyPayWebhookValidation("another_name")
사용하여 헤더 이름을 재정의할 수 있습니다.
또한 app.MapChargilyPayWebhookEndpoint()
로 등록할 수 있는 최소 webapi 엔드포인트가 내장되어 있으며 이를 사용하여 유효성 검사를 수동으로 처리하지 않고도 웹훅 본문에 액세스할 수 있습니다.
Chargily.Pay
및 Chargily.Pay.AspNet
너겟 패키지는 모두 다음 명령을 사용하여 생성할 수 있습니다. docker build . -- output = . / output
.nupkg
아티팩트는 ./output
폴더에 저장됩니다. Chargily Pay™ 패키지/플러그인은 결제 게이트웨이를 다양한 프로그래밍 언어 및 프레임워크에 쉽게 통합할 수 있도록 Chargily가 게시한 오픈 소스 프로젝트 모음입니다. 우리의 목표는 원활하게 결제를 수락할 수 있는 사용하기 쉬운 도구를 제공하여 개발자와 기업에 힘을 실어주는 것입니다.
API와 통합하고 프로젝트에서 Chargily Pay™를 활용하는 방법에 대한 자세한 지침은 API 설명서를 참조하세요.
Telegram의 개발자 커뮤니티에 가입하여 동료 개발자들과 소통하고, 질문하고, Chargily Pay™와 관련된 최신 뉴스 및 개발 소식을 받아보세요: Telegram Community
버그 수정, 기능 개선, 문서 개선, 새로운 플러그인/패키지 개발 등 모든 종류의 기여를 환영합니다. 시작하는 방법은 다음과 같습니다.
저장소 포크: 이 페이지의 오른쪽 상단에 있는 "포크" 버튼을 클릭하여 자신만의 저장소 복사본을 만드세요.
리포지토리 복제: 다음 명령을 사용하여 포크된 리포지토리를 로컬 머신에 복제합니다.
git clone https://github.com/Chargily/chargily-pay-csharp.git
변경: 코드베이스를 원하는 대로 변경하거나 추가합니다. 당사의 코딩 표준 및 지침을 반드시 따르십시오.
변경 사항 테스트: 변경 사항이 예상대로 작동하는지 철저하게 테스트합니다.
끌어오기 요청 제출: 변경 사항에 만족하면 기본 저장소에 다시 끌어오기 요청을 제출하세요. 우리 팀은 귀하의 기여를 검토하고 필요한 경우 피드백을 제공할 것입니다.
질문이 있거나 도움이 필요하신가요? Telegram의 개발자 커뮤니티에 가입하고 동료 개발자 및 팀과 소통하세요.
Chargily Pay™에 기여하는 데 관심을 가져주셔서 감사합니다! 함께라면 우리는 놀라운 것을 만들 수 있습니다.
즐거운 코딩하세요!