AsthaIT.SSLCommerz 1.0.0

dotnet add package AsthaIT.SSLCommerz --version 1.0.0
                    
NuGet\Install-Package AsthaIT.SSLCommerz -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AsthaIT.SSLCommerz" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsthaIT.SSLCommerz" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AsthaIT.SSLCommerz" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AsthaIT.SSLCommerz --version 1.0.0
                    
#r "nuget: AsthaIT.SSLCommerz, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AsthaIT.SSLCommerz@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AsthaIT.SSLCommerz&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AsthaIT.SSLCommerz&version=1.0.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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