Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear Friends,
Bank provides integration code but I am unable to integrate plz help me out.
Amount Mismatch/Invalid Amount error show

What I have tried:

protected void Redirect_Click(object sender, EventArgs e)
        {

            //1. URL
            string TranUrl = "https://uat-etendering.axisbank.co.in/easypay2.0/frontend/index.php/api/payment";

            //2. method to generate Checksum value. //CID + RID + CRN  + AMT + "axis";

            String strCID = string.Empty;
            String strRID = string.Empty;
            String strCRN = string.Empty;
            String strAMT = string.Empty;
            String strName = string.Empty;
            String strClass = string.Empty;
            String strRoll = string.Empty;
            strCID = "5000"; // update the same as assigned by AxisBank
            strRID = Generatetxnid();
            strCRN = Generatetxnid();
            strAMT = TextBox4.Text;
            strName = TextBox1.Text;
            strRoll = TextBox3.Text;
            strClass = TextBox2.Text;
           
            string StrCheckSumString = strCID + strRID + strCRN  + strAMT + "axis";

            string Checksum = sha256_hash(StrCheckSumString);
            //Sample values has been passed in each parameter. Please update with your values.
            string PlainText = "CID=" + strCID + "&RID=" + strRID + "&CRN=" + strCRN + "&AMT=" + TextBox4.Text + "&VER=1.0&TYP=TEST&CNY=INR&RTU=http://localhost:50864/Default.aspx/&PPI=A01/2554-trid|A01/2554|05/21/2016 12:39:14&RE1=MN&RE2=&RE3=&RE4=&RE5=&CKS=" + Checksum;

            string encryptedstring = Encrypt(PlainText, "axisbank12345678");
            //Correct Value with checksum.
            
            NameValueCollection data = new NameValueCollection();
            data.Add("i", encryptedstring);
            
            RedirectAndPOST(this.Page, TranUrl, data);

        }
        private static String PreparePOSTForm(string url, NameValueCollection data)
        {
            try
            {
                //Set a name for the form
                string formID = "PostForm";

                //Build the form using the specified data to be posted.
                StringBuilder strForm = new StringBuilder();
                strForm.Append("");
                foreach (string key in data)
                {
                    strForm.Append("");
                }
                strForm.Append("");

                //Build the JavaScript which will do the Posting operation.
                StringBuilder strScript = new StringBuilder();
                strScript.Append("");
                strScript.Append("var v" + formID + " = document." + formID + ";");
                strScript.Append("v" + formID + ".submit();");
                strScript.Append("");

                //Return the form and the script concatenated. (The order is important, Form then JavaScript)
                return strForm.ToString() + strScript.ToString();

            }
            catch (Exception)
            {

                throw;
            }
        }
        private void RedirectAndPOST(Page page, string TranUrl, NameValueCollection data)
        {
            try
            {

                //Prepare the Posting form
                string strForm = PreparePOSTForm(TranUrl, data);
                //Add a literal control the specified page holding the Post Form, this is to submit the Posting form with the request.
                page.Controls.Add(new LiteralControl(strForm));



            }
            catch

            { }
        }

        public string Encrypt(string input, string key)
        {
            byte[] keyArray = UTF8Encoding.UTF8.GetBytes(key);
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(input);
            Aes kgen = Aes.Create("AES");
            kgen.Mode = CipherMode.ECB;
            //kgen.Padding = PaddingMode.None;
            kgen.Key = keyArray;
            ICryptoTransform cTransform = kgen.CreateEncryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }
        public static String sha256_hash(String value)
        {
            StringBuilder Sb = new StringBuilder();
            using (SHA256 hash = SHA256Managed.Create())
            {
                Encoding enc = Encoding.UTF8;
                Byte[] result = hash.ComputeHash(enc.GetBytes(value));
                foreach (Byte b in result)
                    Sb.Append(b.ToString("x2"));
            }
            return Sb.ToString();
        }
Posted
Updated 20-Jul-22 2:37am
v2

Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.

Only get such code from reputable card transaction service companies - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!

So talk to the tech support for the people you got the code from, not us ...
 
Share this answer
 
Quote:
Bank provides integration code but I am unable to integrate plz help me out.

The only place to go is at the bank, their support service. You are a paying customer. If they don't help you, think about changing of bank.
When you talk about real money, you can't ask for help in random public forum.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900