Exemple #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            CheckStatusResponse objStaus = JsonConvert.DeserializeObject <CheckStatusResponse>(txtCheckStatusResponse.Text);
            var signature = AjaxCaller.VerifyReceivedCheckStatusSignature(objStaus);

            lblCheckResponseSignature.Text = signature;
        }
        public static string VerifyReceivedCheckStatusSignature(CheckStatusResponse objMaster)
        {
            try
            {
                var ShaResponseVar = "344Jy6x7XCNKxsPuFe20n/_-";
                var myArray        = new Dictionary <string, string>();
                myArray.Add("access_code", "a9U2M7lKbzlSOKzkyMli");
                myArray.Add("authorized_amount", objMaster.authorized_amount);
                myArray.Add("captured_amount", objMaster.captured_amount);
                myArray.Add("fort_id", objMaster.fort_id);
                myArray.Add("language", "en");
                myArray.Add("merchant_identifier", "957fafda");
                myArray.Add("merchant_reference", objMaster.merchant_reference);
                myArray.Add("query_command", objMaster.query_command);
                myArray.Add("refunded_amount", objMaster.refunded_amount);
                myArray.Add("response_code", objMaster.response_code);
                myArray.Add("response_message", objMaster.response_message);
                // myArray.Add("signature", objMaster.signature);
                myArray.Add("status", objMaster.status);
                myArray.Add("transaction_code", objMaster.transaction_code);
                myArray.Add("transaction_message", objMaster.transaction_message);
                myArray.Add("transaction_status", objMaster.transaction_status);

                var baseString = "";

                foreach (var item in myArray)
                {
                    baseString += item.Key + "=" + item.Value;
                }

                var shastring = ShaResponseVar + baseString + ShaResponseVar;
                var shaPhrase = SHA256Util.sha256_hash(shastring);

                if (objMaster.signature == shaPhrase)
                {
                    return("Verified");
                }
                else
                {
                    return("Signature Mismatch");
                }
            }
            catch
            {
                return("");
            }
        }