SSLCOMMERZ payment gateway(BD)

SSLCOMMERZ is the first payment gateway in Bangladesh opening doors for merchants to receive payments on the internet via their online stores.

Let’s get started: First of all we may create a database and table, copy the table script and execute it using corresponding database.

CREATE TABLE [dbo].[PaymentLog](
        [PaymentLogID] [int] IDENTITY(1,1) NOT NULL,
        [tran_id] [nvarchar](250) NULL,
        [tran_date] [datetime] NULL,
        [status] [nvarchar](50) NULL,
        [val_id] [nvarchar](50) NULL,
        [amount] [decimal](18, 2) NULL,
        [store_amount] [decimal](18, 2) NULL,
        [currency] [nvarchar](50) NULL,
        [bank_tran_id] [nvarchar](50) NULL,
        [card_type] [nvarchar](50) NULL,
        [card_no] [nvarchar](50) NULL,
        [card_issuer] [nvarchar](50) NULL,
        [card_brand] [nvarchar](50) NULL,
        [card_issuer_country] [nvarchar](50) NULL,
        [card_issuer_country_code] [nvarchar](50) NULL,
        [currency_type] [nvarchar](50) NULL,
        [currency_amount] [decimal](18, 2) NULL,
        [currency_rate] [decimal](18, 2) NULL,
        [base_fair] [decimal](18, 2) NULL,
        [value_a] [nvarchar](50) NULL,
        [value_b] [nvarchar](50) NULL,
        [value_c] [nvarchar](50) NULL,
        [risk_title] [nvarchar](50) NULL,
        [risk_level] [int] NULL,
        [APIConnect] [nvarchar](50) NULL,
        [validated_on] [nvarchar](50) NULL,
        [gw_version] [nvarchar](50) NULL,
        [PaymentLogID] ASC


In this post we have use ASP.Net MVC application to perform operations. create a new MVC application and copy the view to your Home page/billing page.


Home View

    ViewBag.Title = "Payments";


.ActionLink("Go back", "Index", "Home", new { area = "" }, new { = "navbar-brand" })
Amount to Pay: 1500

After clicking Pay now button it will redirect to sslcommerz page, select a payment method.



response message will display like below


Home Controller

private PaymentGatewayEntities _ctx = null;
// GET: Home
public ActionResult Index()
    string Status = string.Empty;
    vmPaymentPostback result = null;
        result = GetResponseData();
        if (result != null)
            Status = "Payment Done!";
            Status = "Payment Fails!";
    catch (Exception)
        Status = "";
    ViewBag.Status = Status;
    return View();

In our controller we need to reference below .dll

  1. using Newtonsoft.Json;
  2. using System.IO;
  3. using System.Net;

Response Data

public vmPaymentPostback GetResponseData()
    vmPaymentPostback objrspParam = null;
    string[] keys = Request.Form.AllKeys;
    var key = keys[1]; //1 = val_id
    var valId = Request.Form[keys[1]]; //1 = val_id
    var storeID = "test_storeID"; //Replace with LiveID
    var storePass = "test_storePass"; //Replace with LivePassword
    var validateurl = "" + valId + "&Store_Id=" + storeID + "&Store_Passwd=" + storePass + "&v=1&format=json"; //Replace with LiveValidURL
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(validateurl);
        request.Method = "GET";

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream dataStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(dataStream);
        objrspParam = JsonConvert.DeserializeObject(reader.ReadToEnd().ToString());
    catch (Exception)
    return objrspParam;

Save Transnational data to database

after successful transaction we can now save our transnational data to database.

public int SavePayment(vmPaymentPostback _Payment)
    int status = 0;
        PaymentLog objPay = new PaymentLog
            tran_id = _Payment.tran_id,
            tran_date = Convert.ToDateTime(_Payment.tran_date),
            status = _Payment.status,
            val_id = _Payment.status,
            amount = _Payment.amount,
            store_amount = _Payment.store_amount,
            currency = _Payment.currency,
            bank_tran_id = _Payment.bank_tran_id,
            card_type = _Payment.card_type,
            card_no = _Payment.card_no,
            card_issuer = _Payment.card_issuer,
            card_brand = _Payment.card_brand,
            card_issuer_country = _Payment.card_issuer_country,
            card_issuer_country_code = _Payment.card_issuer_country_code,
            currency_type = _Payment.currency_type,
            currency_amount = _Payment.currency_amount,
            currency_rate = _Payment.currency_rate,
            base_fair = _Payment.base_fair,
            value_a = _Payment.value_a,
            value_b = _Payment.value_b,
            value_c = _Payment.value_c,
            risk_title = _Payment.risk_title,
            risk_level = _Payment.risk_level,
            APIConnect = _Payment.APIConnect,
            validated_on = _Payment.validated_on,
            gw_version = _Payment.gw_version,

        using (_ctx = new PaymentGatewayEntities())
            status = 1;
        status = 0;
    return status;

Finally it will redirect to merchant application success page.

pay_4 pay_5

Source Code: I’ve uploaded the full source code to download/clone , Hope this will help 🙂



Since March 2011, have 8+ years of professional experience on software development, currently working as Senior Software Engineer at s3 Innovate Pte Ltd.

11 thoughts on “SSLCOMMERZ payment gateway(BD)”

  • Nayan Pal says:


    Is there any need of authority authentication if i just pass the amount of taka from my project in the front page of api??That means i just want to show the amount in the api front page from my project ?

  • Thanks a lot. But when I implement I get an error.That is –
    Not Found
    The requested URL /gwprocess/testbox/v3/process.php was not found on this server.

    Please let me know how can solve this error.
    Thanks in advance.

  • They do not respond to your email and closed merchant account for more than 30 days now. There were some chargeback issues which was resolved but still no update. Unprofessional. Disappointed. They do not care if you use their service or not. But i respect one staff from this team who is Nusrat Shirmin. The day she left as our account manager, a crap person took the responsibility and causing a merchant’s business interruption. I hope the owner sees this and take action. Md. Moinul Hasan is a shit. His phone never gave a clear voice. He talks so slowly and unclear voice. Never helped us with anything while i always felt fine working with Nusrat Shirmin.

    SSLcommerz admin, check your workers. Some are causing your merchant to leave SSLcommerz. That is not good for your business.

Leave a Reply