AsthaIT.SSLCommerz
1.0.0
dotnet add package AsthaIT.SSLCommerz --version 1.0.0
NuGet\Install-Package AsthaIT.SSLCommerz -Version 1.0.0
<PackageReference Include="AsthaIT.SSLCommerz" Version="1.0.0" />
<PackageVersion Include="AsthaIT.SSLCommerz" Version="1.0.0" />
<PackageReference Include="AsthaIT.SSLCommerz" />
paket add AsthaIT.SSLCommerz --version 1.0.0
#r "nuget: AsthaIT.SSLCommerz, 1.0.0"
#:package AsthaIT.SSLCommerz@1.0.0
#addin nuget:?package=AsthaIT.SSLCommerz&version=1.0.0
#tool nuget:?package=AsthaIT.SSLCommerz&version=1.0.0
AIT.Packages.PaymentGateway
A lightweight .NET library for integrating SSLCommerz payment gateway functionality into your applications. This package provides a simple and secure way to process payments, get transactions, and Validate transactions.
Installation
dotnet add package AsthaIT.SSLCommerz
Usage
AITSSLCommerzClient
The AITSSLCommerzClient
class provides static methods to interact with the SSLCommerz payment gateway.
1. Create a Payment Request
Initiate a payment and get the payment URL to redirect your customer.
using AIT.Packages.SSLCommerz;
using AIT.Packages.SSLCommerz.Payload;
var payload = new SSLCommerzCreatePaymentPayload
{
StoreId = "your-store-id", //Provided by SSLCommerz
StorePassword = "your-store-password",
Amount = 1500.75,
Currency = "BDT",
TransactionId = Guid.NewGuid().ToString(),
SuccessUrl = "https://example.com/success",
FailedUrl = "https://example.com/fail",
CancelUrl = "https://example.com/cancel",
IpnCallbackUrl = "https://example.com/ipn",
CustomerName = "John Doe",
CustomerEmail = "john.doe@example.com",
CustomerPhone = "01700000000",
CustomerAddress = "123 Demo Street",
//CustomerCity = "Dhaka",
//CustomerPostCode = "1207",
//CustomerCountry = "Bangladesh",
//ProductName = "Demo Product",
//ProductCategory = "general",
MetaDataA = "custom_value_a"
};
var response = await AITSSLCommerzClient.CreatePaymentRequestAsync(
payload,
SSLCommerzPaymentEnvironment.Sandbox // or Live
);
if (response.IsSuccess)
{
var paymentUrl = response.Data.PaymentUrl; // Redirect user to paymentUrl
}
2. Get Payment Validation Status
Validate a payment using the validation ID received from SSLCommerz.
var validationResponse = await AITSSLCommerzClient.GetPaymentValidationStatusAsync(
validationId: "your-validation-id",
storeId: "your-store-id", //Provided by SSLCommerz
storePassword: "your-store-password", //Provided by SSLCommerz
environment: SSLCommerzPaymentEnvironment.Sandbox // or Live
);
if (validationResponse.IsSuccess)
{
// Access transaction details from validationResponse.Data
}
3. Get Payment Transactions by Transaction ID
Retrieve a list of transactions for a specific transaction ID.
var transactionListResponse = await AITSSLCommerzClient.GetPaymentTransactionsByTransactionIdAsync(
transactionId: "your-transaction-id", // This is the tran_id that you provide when creating the payment request.
storeId: "your-store-id", // Provided by SSLCommerz
storePassword: "your-store-password", // Provided by SSLCommerz
environment: SSLCommerzPaymentEnvironment.Sandbox // or Live
);
if (transactionListResponse.IsSuccess)
{
// Access transactions from transactionListResponse.Data
}
4. Get Payment Transaction by Session Key
Retrieve transaction details using a session key.
var transactionResponse = await AITSSLCommerzClient.GetPaymentTransactionBySessionKeyAsync(
sessionKey: "your-session-key", //The sessionKey returned by the CreatePaymentRequestAsync response.
storeId: "your-store-id", // Provided by SSLCommerz
storePassword: "your-store-password", // Provided by SSLCommerz
environment: SSLCommerzPaymentEnvironment.Sandbox // or Live
);
if (transactionResponse.IsSuccess)
{
// Access transaction details from transactionResponse.Data
}
IPN Callback endpoint (Same for Success And Failed Callback
)
[HttpPost]
[Route("sslcommerz/ipn/callback")] // Make sure same as create payment request IpnCallbackUrl
[AllowAnonymous]
public async Task<IActionResult> SSLCommerzIpnCallbackAsync([FromForm] SSLCommerzPaymentCallbackResponse response)
{
// Here validate payment transaction
return Ok();
}
SSLCommerz Official Documentation
Dependencies
- AsthaIT.RestClient
- Microsoft.AspNetCore.Mvc.Core
License
MIT License
Author
Developed and maintained by AIT.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AsthaIT.RestClient (>= 1.0.1)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
-
net9.0
- AsthaIT.RestClient (>= 1.0.1)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 140 | 7/2/2025 |