TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anay Shukla
NA
24
6.3k
Transaction failed due to incorrectly calculated hash parame
Jun 6 2019 1:11 PM
I tried below code but got error in redirection of payumoney page kindly check , my hash value is not generated properly.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Security.Cryptography;
using
System.Text;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
BuyNow : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
Label1.Text = Request.QueryString[
"Price"
].ToString();
Random random =
new
Random();
txnid.Value = (Convert.ToString(random.Next(10000, 20000)));
txnid.Value =
"AVJFINANCE"
+ txnid.Value.ToString();
Response.Write(txnid.Value.ToString());
}
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
Double amount = Convert.ToDouble(Label1.Text);
// String text = Key.Value.ToString() + "|" + txnid.Value.ToString() +"|" + amount + "|" + "Wear" + "|" + TextBox1.Text + "|" + TextBox2.Text + "|" + "1" + "|" + "1" + "|" + "1" + "|" + "1" + "|" + "1" + "||||||" + salt.Value.ToString();
String text = Key.Value.ToString() +
"|"
+ txnid.Value.ToString() +
"|"
+ amount +
"|"
+
"Wear"
+
"|"
+ TextBox1.Text +
"|"
+ TextBox2.Text +
"|"
+
"||||||"
+ salt.Value.ToString();
//byte[] message = Encoding.UTF8.GetBytes(text);
//UnicodeEncoding UE = new UnicodeEncoding();
//byte[] hashValue;
//SHA512Managed hashString = new SHA512Managed();
//string hex = "";
//hashValue = hashString.ComputeHash(message);
//foreach (byte x in hashValue)
//{
// hex += String.Format("{0:x2}", x);
//}
byte
[] message = Encoding.UTF8.GetBytes(text);
UnicodeEncoding UE =
new
UnicodeEncoding();
byte
[] hashValue;
SHA512Managed hashString =
new
SHA512Managed();
string
hex =
""
;
hashValue = hashString.ComputeHash(message);
foreach
(
byte
x
in
hashValue)
{
hex += String.Format(
"{0:x2}"
, x);
}
hash.Value = hex;
System.Collections.Hashtable data =
new
System.Collections.Hashtable();
data.Add(
"hash"
, hex.ToString());
data.Add(
"txnid"
, txnid.Value);
data.Add(
"Key"
, Key.Value);
data.Add(
"amount"
, amount);
data.Add(
"Firstname"
, TextBox1.Text.Trim());
data.Add(
"email"
, TextBox2.Text.Trim());
data.Add(
"phone"
, TextBox3.Text.Trim());
data.Add(
"productinfo"
,
"WEarnew"
);
data.Add(
"ufd1"
,
"1"
);
data.Add(
"ufd2"
,
"1"
);
data.Add(
"ufd3"
,
"1"
);
data.Add(
"ufd4"
,
"1"
);
data.Add(
"ufd5"
,
"1"
);
data.Add(
"surl"
,
"http://localhost:15073/web/Successpayment.aspx"
);
data.Add(
"furl"
,
"http://localhost:15073/web/Failar.aspx"
);
data.Add(
"service_provider"
,
""
);
string
strform = PreparePOSTForm(
"https://test.payu.in/_payment"
, data);
Page.Controls.Add(
new
LiteralControl(strform));
}
private
string
PreparePOSTForm(
string
url, System.Collections.Hashtable data)
// post form
{
//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(
"<form id=\""
+ formID +
"\" name=\""
+
formID +
"\" action=\""
+ url +
"\" method=\"POST\">"
);
foreach
(System.Collections.DictionaryEntry key
in
data)
{
strForm.Append(
"<input type=\"hidden\" name=\""
+ key.Key +
"\" value=\""
+ key.Value +
"\">"
);
}
strForm.Append(
"</form>"
);
//Build the JavaScript which will do the Posting operation.
StringBuilder strScript =
new
StringBuilder();
strScript.Append(
"<script language='javascript'>"
);
strScript.Append(
"var v"
+ formID +
" = document."
+
formID +
";"
);
strScript.Append(
"v"
+ formID +
".submit();"
);
strScript.Append(
"</script>"
);
//Return the form and the script concatenated.
//(The order is important, Form then JavaScript)
return
strForm.ToString() + strScript.ToString();
}
//private string PreparePOSTform (string url, System.Collections.Hashtable data)
//{
// string formID = "Postform";
// StringBuilder strform = new StringBuilder();
// strform.Append("<form id=\"" + formID + "\" name=\"" + formID + "\" action =\"" + url + "\" + method=\"Post\" > ");
// foreach (System.Collections.DictionaryEntry key in data)
// {
// strform.Append("< input type= \"hidden\" name=\"" + key.Key + "\" value = \"" + Key.Value + "\" > ");
// }
// strform.Append("/form");
// StringBuilder strScript = new StringBuilder();
// strScript.Append("<Script language = 'javascript'");
// strScript.Append("var v " + formID + " = documnet." + formID + ";" );
// strScript.Append("v" + formID + ".submit();");
// strScript.Append("</script>");
// return strform.ToString() + strScript.ToString();
// }
}
Reply
Answers (
1
)
auto location textbox without google maps in asp.net
Application for typing your voice