Tech Process Payment Gateway Implementation

  1) Payment Request Page

#region Tech Process Code
COM.TPSLUtil1 objTPSLUtil1 = new COM.TPSLUtil1();
COM.CheckSumRequestBean objCheckSumRequestBean = new COM.CheckSumRequestBean();

objCheckSumRequestBean.MerchantTranId = YOUR TRANSACTION ID;
objCheckSumRequestBean.MarketCode = CURRENCY CODE;
objCheckSumRequestBean.AccountNo = BANK ACCOUNT CODE
objCheckSumRequestBean.Amt = PAYMENT AMOUNT
objCheckSumRequestBean.BankCode = "240";
objCheckSumRequestBean.PropertyPath = "C:\\MerchantDetails.property";

string strMsg = objTPSLUtil1.transactionRequestMessage(objCheckSumRequestBean);

if (!strMsg.Equals(""))
{
    Response.Redirect("https://www.tpsl-india.in/PaymentGateway/TransactionRequest.jsp?msg=" + strMsg);
}
#endregion
2) Payment Response Page

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        if (!Page.IsPostBack)
        {

        COM.CheckSumResponseBean objCheckSumResponseBean = new COM.CheckSumResponseBean();
        TPSLUtil1 objTPSLUtil1 = new TPSLUtil1();
        String strResponseMsg = Request["msg"] == null ? "" : Request["msg"].Trim();
          
        string strResponceIP = HttpContext.Current.Request.UserHostAddress;
        string strLogDesc = string.Empty;

        String[] token = strResponseMsg.Split('|');
        string txtchecksum, txtauthstatus, txterrordesc, txtsettlementtype, txtaddtninfo1, txtaddtninfo2, txtaddtninfo3, txterrorstatus;
       
        if (token.Length == 26)
        {
            txtchecksum = token[25].ToString();
            txtauthstatus = token[14].ToString();
            txterrordesc = token[24].ToString();
            txtauthstatus = token[14].ToString();
            txtsettlementtype = token[15].ToString();
            txtaddtninfo1 = token[16].ToString();
            txtaddtninfo2 = token[17].ToString();
            txtaddtninfo3 = token[18].ToString();
            txterrorstatus = token[23].ToString();

            if (txtauthstatus == "0399")
            {
            // ERROR IN PAYMENT
            // REDIRECT TO ERROR PAGE   
            return;
            }
        }
        else
        {
            // NOT VALID RESPONSE
            // REDIRECT TO ERROR PAGE
            return;
        }

        string strRemarks = "Merchant Id:" + token[0].ToString() + ", Subscriber Id:" + token[1].ToString() + ", Ref No:" + token[2].ToString() + ", Bank Ref No:" + token[3].ToString() + ", Amount:" + token[4].ToString() + ", Bank Id:" + token[5].ToString() + ", Bank Merchant Id:" + token[6].ToString() + ", cntype:" + token[7].ToString() + ", Currency:" + token[8].ToString() + ", temCode:" + token[9].ToString() + ", Security Type:" + token[10].ToString() + ", Security ID:" + token[11].ToString() + ", Security Pass:" + token[12].ToString() + ", Date:" + token[13].ToString() + ", Status:" + token[14].ToString() + ", Settellement Type:" + token[15].ToString() + ", Add Info1:" + token[16].ToString() + ", Add Info2:" + token[17].ToString() + ", Add Info3:" + token[18].ToString() + ", Add Info4:" + token[19].ToString() + ", Add Info5:" + token[20].ToString() + ", Add Info6:" + token[21].ToString() + ", Add Info7:" + token[22].ToString() + ", Error Status:" + token[23].ToString() + ", Error Desc:" + token[24].ToString() + ", Check Sum:" + token[25].ToString();

        objCheckSumResponseBean.MSG = strResponseMsg;
        objCheckSumResponseBean.PropertyPath = "C:\\TechProcess-Interface\\NLMerchantDetails.property";
       
        string strCheckSumValue = string.Empty;
       
        strCheckSumValue = objTPSLUtil1.transactionResponseMessage(objCheckSumResponseBean);

        if (!strCheckSumValue.Equals(""))
        {
            if (!txtchecksum.Equals(strCheckSumValue))
            {
            txtauthstatus = "0399";
            // Transaction Failed due to checksum mismatch
            // REDIRECT TO ERROR PAGE

            }
            else
            {
            //0300 // SUCCESS CODE
            try
            {
                // UPDATE THE TRANSACTION STATUS IN DB
                //
                // CODE FOR UPDATE STATUS
                //
                //
       
                // REDIRECT TO OTHER PAGE OR SHOW THE PAYMENT RESPONSE ON SAME PAGE
            }
            catch (Exception ex)
            {
                // INVALID RESPONSE CODE
                // REDIRECT TO ERROR PAGE
            }
            }
        }
        else
        {
            // INVALID RESPONSE CODE
            // REDIRECT TO ERROR PAGE
        }

        }
    }
    catch (Exception ex)
    {
        // ERROR OCCURED
        // REDIRECT TO ERROR PAGE
    }

}


No comments:

Post a Comment