solution is to set the LinkButton CausesValidation="false"
ASP.NET with C# and SQL SERVER , some vb.net . asp.net examples, asp.net codes, asp.net programs, c# code, sql server queries, important codes.
Friday, 10 March 2017
Thursday, 22 December 2016
Integrate Perfect Money in asp.net. , perfect money api integration in asp.net
download class file from give link
http://traininginjaipur.com/perfectmoneyclass.zip
PerfectMoney obj = new PerfectMoney();
int paymentid= any random unique no ;
Dictionary<string, string> results = obj.Transfer(PerfectMoneyAc, PerfectMoneyPwd, PerfectMoneyPayeerID,ReciverPayeerID, current_amt_in_doller, 1, paymentid);
if (results.Count > 0)
{
foreach (var i in results)
{
if (i.Key == "ERROR")
{
f = 1;
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msg", "alert('" + i.Key + "," + i.Value + "');window.location='Account.aspx';", true);
}
}
if (f == 0)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msg", "alert('Withdrawal successfull');window.location='ReturnfromPerfectMoney_Withdrawal_Yes.aspx?a=" + key + "';", true);
}
}
http://traininginjaipur.com/perfectmoneyclass.zip
PerfectMoney obj = new PerfectMoney();
int paymentid= any random unique no ;
Dictionary<string, string> results = obj.Transfer(PerfectMoneyAc, PerfectMoneyPwd, PerfectMoneyPayeerID,ReciverPayeerID, current_amt_in_doller, 1, paymentid);
if (results.Count > 0)
{
foreach (var i in results)
{
if (i.Key == "ERROR")
{
f = 1;
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msg", "alert('" + i.Key + "," + i.Value + "');window.location='Account.aspx';", true);
}
}
if (f == 0)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "msg", "alert('Withdrawal successfull');window.location='ReturnfromPerfectMoney_Withdrawal_Yes.aspx?a=" + key + "';", true);
}
}
Integrate BitCoin in asp.net, BitCoin API in ASP.NET, bitcoin wallet integration in asp.net
download .dll files from given link
http://traininginjaipur.com/bitcoindll.zip
u have to specify ont bitcoin wallet username and pwd , and then u have to provide receiver bitcoin account,
that code will transfer given bitcoin to one wallet to another wallet
using Info.Blockchain.API;
using Info.Blockchain.API.Receive;
using Info.Blockchain.API.Wallet;
Wallet w = new Wallet("SenderBitCoinAc", "SenderBitCoinAcPwd");
string reciverbitcoinadd = ".PayeerID";
decimal amt = (decimal)(YourAmount);
// this is to convert amt to bitcoin amt formate
decimal finalamt = amt * 100000000;
PaymentResponse pr = w.Send(reciverbitcoinadd , Convert.ToInt64(finalamt));
http://traininginjaipur.com/bitcoindll.zip
u have to specify ont bitcoin wallet username and pwd , and then u have to provide receiver bitcoin account,
that code will transfer given bitcoin to one wallet to another wallet
using Info.Blockchain.API;
using Info.Blockchain.API.Receive;
using Info.Blockchain.API.Wallet;
Wallet w = new Wallet("SenderBitCoinAc", "SenderBitCoinAcPwd");
string reciverbitcoinadd = ".PayeerID";
decimal amt = (decimal)(YourAmount);
// this is to convert amt to bitcoin amt formate
decimal finalamt = amt * 100000000;
PaymentResponse pr = w.Send(reciverbitcoinadd , Convert.ToInt64(finalamt));
Saturday, 17 December 2016
html code for full screen web page, show web page in full screen
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="container">
<section class="main-content">
<button id="view-fullscreen">Practice</button>
<script >
(function () {
var viewFullScreen = document.getElementById("view-fullscreen");
if (viewFullScreen) {
viewFullScreen.addEventListener("click", function () {
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
}, false);
}
})();
</script>
</section>
</div>
</body>
</html>
<html>
<head>
</head>
<body>
<div class="container">
<section class="main-content">
<button id="view-fullscreen">Practice</button>
<script >
(function () {
var viewFullScreen = document.getElementById("view-fullscreen");
if (viewFullScreen) {
viewFullScreen.addEventListener("click", function () {
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
}, false);
}
})();
</script>
</section>
</div>
</body>
</html>
Monday, 28 November 2016
Integrate PayUMoney in ASP.Net,add PayUMoney in asp.net with c# ,PayUMoney asp.net C#
http://www.c-sharpcorner.com/uploadfile/c42694/integrate-payumoney-in-asp-net/
Or
Directly get values from db and send it to payumoney
**************************
In Webconfig
*******************************
<appSettings>
<add key="MERCHANT_KEY" value="gtKFFx"/>
<add key="SALT" value="eCwWELxi"/>
<add key="PAYU_BASE_URL" value="https://test.payu.in"/>
<add key="action" value=""/>
<add key="hashSequence" value="key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"/>
</appSettings>
**************************
in C# Page
**************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Configuration;
using System.Text;
using System.Data;
using DataLogicLayer;
public partial class paymentprocess : System.Web.UI.Page
{
cls_connection con = new cls_connection();
public string action1 = string.Empty;
public string hash1 = string.Empty;
public string txnid1 = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
try
{
//set merchant key from web.config or AppSettings
key.Value = ConfigurationManager.AppSettings["MERCHANT_KEY"];
processnow();
}
catch (Exception ex)
{
Response.Write("<span style='color:red'>" + ex.Message + "</span>");
}
}
/// <summary>
/// Generate HASH for encrypt all parameter passing while transaction
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public string Generatehash512(string text)
{
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);
}
return hex;
}
private void processnow()
{
try
{
string qry;
if (Request.QueryString["chkid"] != null)
{
qry = "select a.NetAmount,b.Name,b.Email,b.MobileNo from dbo.Checkout as a inner join dbo.RegistrationCustomer as b on a.CustomerId=b.CustomerId where a.checkoutid=" + Request.QueryString["chkid"].ToString() + " and a.CustomerId=" + Session["OwnerId"].ToString() + " ";
DataSet ds = new DataSet();
ds = con.select_data_ds(qry);
string amountval = ds.Tables[0].Rows[0][0].ToString();
string nameval = "israr";// ds.Tables[0].Rows[0][1].ToString();
string emailval = ds.Tables[0].Rows[0][2].ToString();
string mobileNoval = ds.Tables[0].Rows[0][3].ToString();
string productinfo = "YourProductName";
string successurl = "http://localhost:62991/payumoneysuccess.aspx";
string failureurl = "http://localhost:62991/payumoneyfail.aspx";
string cancelurl = "http://localhost:62991/payumoneycancel.aspx";
string[] hashVarsSeq;
string hash_string = string.Empty;
if (string.IsNullOrEmpty(Request.Form["txnid"])) // generating txnid
{
Random rnd = new Random();
string strHash = Generatehash512(rnd.ToString() + DateTime.Now);
txnid1 = strHash.ToString().Substring(0, 20);
}
else
{
txnid1 = Request.Form["txnid"];
}
if (string.IsNullOrEmpty(Request.Form["hash"])) // generating hash value
{
if (
string.IsNullOrEmpty(ConfigurationManager.AppSettings["MERCHANT_KEY"]) ||
string.IsNullOrEmpty(txnid1) ||
string.IsNullOrEmpty(amountval) ||
string.IsNullOrEmpty(nameval) ||
string.IsNullOrEmpty(emailval ) ||
string.IsNullOrEmpty(mobileNoval) ||
string.IsNullOrEmpty(productinfo) ||
string.IsNullOrEmpty(successurl) ||
string.IsNullOrEmpty(failureurl)
)
{
//error
frmError.Visible = true;
return;
}
else
{
frmError.Visible = false;
hashVarsSeq = ConfigurationManager.AppSettings["hashSequence"].Split('|'); // spliting hash sequence from config
hash_string = "";
foreach (string hash_var in hashVarsSeq)
{
if (hash_var == "key")
{
hash_string = hash_string + ConfigurationManager.AppSettings["MERCHANT_KEY"];
hash_string = hash_string + '|';
}
else if (hash_var == "txnid")
{
hash_string = hash_string + txnid1;
hash_string = hash_string + '|';
}
else if (hash_var == "amount")
{
hash_string = hash_string + Convert.ToDecimal(amountval).ToString("g29");
hash_string = hash_string + '|';
}
else if (hash_var == "productinfo")
{
hash_string = hash_string + productinfo;
hash_string = hash_string + '|';
}
else if (hash_var == "firstname")
{
hash_string = hash_string + nameval;
hash_string = hash_string + '|';
}
else if (hash_var == "email")
{
hash_string = hash_string + emailval;
hash_string = hash_string + '|';
}
else
{
hash_string = hash_string + (Request.Form[hash_var] != null ? Request.Form[hash_var] : "");// isset if else
hash_string = hash_string + '|';
}
}
hash_string += ConfigurationManager.AppSettings["SALT"];// appending SALT
hash1 = Generatehash512(hash_string).ToLower(); //generating hash
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";// setting URL
}
}
else if (!string.IsNullOrEmpty(Request.Form["hash"]))
{
hash1 = Request.Form["hash"];
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";
}
if (!string.IsNullOrEmpty(hash1))
{
hash.Value = hash1;
txnid.Value = txnid1;
System.Collections.Hashtable data = new System.Collections.Hashtable(); // adding values in gash table for data post
data.Add("hash", hash.Value);
data.Add("txnid", txnid.Value);
data.Add("key", key.Value);
string AmountForm = Convert.ToDecimal(amountval).ToString("g29");// eliminating trailing zeros
amount.Text = AmountForm;
data.Add("amount", AmountForm);
data.Add("firstname", nameval );
data.Add("email", emailval);
data.Add("phone",mobileNoval);
data.Add("productinfo", productinfo );
data.Add("surl", successurl );
data.Add("furl", failureurl);
data.Add("lastname", "");
data.Add("curl", cancelurl);
data.Add("address1", "");
data.Add("address2", "");
data.Add("city", "");
data.Add("state", "");
data.Add("country","");
data.Add("zipcode", "");
data.Add("udf1", "");
data.Add("udf2", "");
data.Add("udf3", "");
data.Add("udf4", "");
data.Add("udf5", "");
data.Add("pg", pg.Text.Trim());
string strForm = PreparePOSTForm(action1, data);
Page.Controls.Add(new LiteralControl(strForm));
}
else
{
//no hash
}
}
}
catch (Exception ex)
{
Response.Write("<span style='color:red'>" + ex.Message + "</span>");
}
}
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();
}
}
*******************************
On Sucess page
******************************
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PayUDemo
{
public partial class payumoneysuccess: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string[] merc_hash_vars_seq;
string merc_hash_string = string.Empty;
string merc_hash = string.Empty;
string order_id = string.Empty;
string hash_seq = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if (Request.Form["status"] == "success")
{
merc_hash_vars_seq = hash_seq.Split('|');
Array.Reverse(merc_hash_vars_seq);
merc_hash_string = ConfigurationManager.AppSettings["SALT"] + "|" + Request.Form["status"];
foreach (string merc_hash_var in merc_hash_vars_seq)
{
merc_hash_string += "|";
merc_hash_string = merc_hash_string + (Request.Form[merc_hash_var] != null ? Request.Form[merc_hash_var] : "");
}
merc_hash = Generatehash512(merc_hash_string).ToLower();
if (merc_hash != Request.Form["hash"])
{
//Value didn't match that means some paramter value change between transaction
Response.Write("Hash value did not matched");
}
else
{
//if hash value match for before transaction data and after transaction data
//that means success full transaction , see more in response
order_id = Request.Form["txnid"];
Response.Write("value matched");
//Hash value did not matched
}
}
else
{
Response.Write("Hash value did not matched");
// osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment' , 'SSL', null, null,true));
}
}
catch (Exception ex)
{
Response.Write("<span style='color:red'>" + ex.Message + "</span>");
}
}
/// <summary>
/// Generate HASH for encrypt all parameter passing while transaction
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public string Generatehash512(string text)
{
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);
}
return hex;
}
}
}
Or
Directly get values from db and send it to payumoney
**************************
In Webconfig
*******************************
<appSettings>
<add key="MERCHANT_KEY" value="gtKFFx"/>
<add key="SALT" value="eCwWELxi"/>
<add key="PAYU_BASE_URL" value="https://test.payu.in"/>
<add key="action" value=""/>
<add key="hashSequence" value="key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"/>
</appSettings>
**************************
in C# Page
**************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Configuration;
using System.Text;
using System.Data;
using DataLogicLayer;
public partial class paymentprocess : System.Web.UI.Page
{
cls_connection con = new cls_connection();
public string action1 = string.Empty;
public string hash1 = string.Empty;
public string txnid1 = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
try
{
//set merchant key from web.config or AppSettings
key.Value = ConfigurationManager.AppSettings["MERCHANT_KEY"];
processnow();
}
catch (Exception ex)
{
Response.Write("<span style='color:red'>" + ex.Message + "</span>");
}
}
/// <summary>
/// Generate HASH for encrypt all parameter passing while transaction
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public string Generatehash512(string text)
{
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);
}
return hex;
}
private void processnow()
{
try
{
string qry;
if (Request.QueryString["chkid"] != null)
{
qry = "select a.NetAmount,b.Name,b.Email,b.MobileNo from dbo.Checkout as a inner join dbo.RegistrationCustomer as b on a.CustomerId=b.CustomerId where a.checkoutid=" + Request.QueryString["chkid"].ToString() + " and a.CustomerId=" + Session["OwnerId"].ToString() + " ";
DataSet ds = new DataSet();
ds = con.select_data_ds(qry);
string amountval = ds.Tables[0].Rows[0][0].ToString();
string nameval = "israr";// ds.Tables[0].Rows[0][1].ToString();
string emailval = ds.Tables[0].Rows[0][2].ToString();
string mobileNoval = ds.Tables[0].Rows[0][3].ToString();
string productinfo = "YourProductName";
string successurl = "http://localhost:62991/payumoneysuccess.aspx";
string failureurl = "http://localhost:62991/payumoneyfail.aspx";
string cancelurl = "http://localhost:62991/payumoneycancel.aspx";
string[] hashVarsSeq;
string hash_string = string.Empty;
if (string.IsNullOrEmpty(Request.Form["txnid"])) // generating txnid
{
Random rnd = new Random();
string strHash = Generatehash512(rnd.ToString() + DateTime.Now);
txnid1 = strHash.ToString().Substring(0, 20);
}
else
{
txnid1 = Request.Form["txnid"];
}
if (string.IsNullOrEmpty(Request.Form["hash"])) // generating hash value
{
if (
string.IsNullOrEmpty(ConfigurationManager.AppSettings["MERCHANT_KEY"]) ||
string.IsNullOrEmpty(txnid1) ||
string.IsNullOrEmpty(amountval) ||
string.IsNullOrEmpty(nameval) ||
string.IsNullOrEmpty(emailval ) ||
string.IsNullOrEmpty(mobileNoval) ||
string.IsNullOrEmpty(productinfo) ||
string.IsNullOrEmpty(successurl) ||
string.IsNullOrEmpty(failureurl)
)
{
//error
frmError.Visible = true;
return;
}
else
{
frmError.Visible = false;
hashVarsSeq = ConfigurationManager.AppSettings["hashSequence"].Split('|'); // spliting hash sequence from config
hash_string = "";
foreach (string hash_var in hashVarsSeq)
{
if (hash_var == "key")
{
hash_string = hash_string + ConfigurationManager.AppSettings["MERCHANT_KEY"];
hash_string = hash_string + '|';
}
else if (hash_var == "txnid")
{
hash_string = hash_string + txnid1;
hash_string = hash_string + '|';
}
else if (hash_var == "amount")
{
hash_string = hash_string + Convert.ToDecimal(amountval).ToString("g29");
hash_string = hash_string + '|';
}
else if (hash_var == "productinfo")
{
hash_string = hash_string + productinfo;
hash_string = hash_string + '|';
}
else if (hash_var == "firstname")
{
hash_string = hash_string + nameval;
hash_string = hash_string + '|';
}
else if (hash_var == "email")
{
hash_string = hash_string + emailval;
hash_string = hash_string + '|';
}
else
{
hash_string = hash_string + (Request.Form[hash_var] != null ? Request.Form[hash_var] : "");// isset if else
hash_string = hash_string + '|';
}
}
hash_string += ConfigurationManager.AppSettings["SALT"];// appending SALT
hash1 = Generatehash512(hash_string).ToLower(); //generating hash
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";// setting URL
}
}
else if (!string.IsNullOrEmpty(Request.Form["hash"]))
{
hash1 = Request.Form["hash"];
action1 = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment";
}
if (!string.IsNullOrEmpty(hash1))
{
hash.Value = hash1;
txnid.Value = txnid1;
System.Collections.Hashtable data = new System.Collections.Hashtable(); // adding values in gash table for data post
data.Add("hash", hash.Value);
data.Add("txnid", txnid.Value);
data.Add("key", key.Value);
string AmountForm = Convert.ToDecimal(amountval).ToString("g29");// eliminating trailing zeros
amount.Text = AmountForm;
data.Add("amount", AmountForm);
data.Add("firstname", nameval );
data.Add("email", emailval);
data.Add("phone",mobileNoval);
data.Add("productinfo", productinfo );
data.Add("surl", successurl );
data.Add("furl", failureurl);
data.Add("lastname", "");
data.Add("curl", cancelurl);
data.Add("address1", "");
data.Add("address2", "");
data.Add("city", "");
data.Add("state", "");
data.Add("country","");
data.Add("zipcode", "");
data.Add("udf1", "");
data.Add("udf2", "");
data.Add("udf3", "");
data.Add("udf4", "");
data.Add("udf5", "");
data.Add("pg", pg.Text.Trim());
string strForm = PreparePOSTForm(action1, data);
Page.Controls.Add(new LiteralControl(strForm));
}
else
{
//no hash
}
}
}
catch (Exception ex)
{
Response.Write("<span style='color:red'>" + ex.Message + "</span>");
}
}
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();
}
}
*******************************
On Sucess page
******************************
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PayUDemo
{
public partial class payumoneysuccess: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string[] merc_hash_vars_seq;
string merc_hash_string = string.Empty;
string merc_hash = string.Empty;
string order_id = string.Empty;
string hash_seq = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if (Request.Form["status"] == "success")
{
merc_hash_vars_seq = hash_seq.Split('|');
Array.Reverse(merc_hash_vars_seq);
merc_hash_string = ConfigurationManager.AppSettings["SALT"] + "|" + Request.Form["status"];
foreach (string merc_hash_var in merc_hash_vars_seq)
{
merc_hash_string += "|";
merc_hash_string = merc_hash_string + (Request.Form[merc_hash_var] != null ? Request.Form[merc_hash_var] : "");
}
merc_hash = Generatehash512(merc_hash_string).ToLower();
if (merc_hash != Request.Form["hash"])
{
//Value didn't match that means some paramter value change between transaction
Response.Write("Hash value did not matched");
}
else
{
//if hash value match for before transaction data and after transaction data
//that means success full transaction , see more in response
order_id = Request.Form["txnid"];
Response.Write("value matched");
//Hash value did not matched
}
}
else
{
Response.Write("Hash value did not matched");
// osc_redirect(osc_href_link(FILENAME_CHECKOUT, 'payment' , 'SSL', null, null,true));
}
}
catch (Exception ex)
{
Response.Write("<span style='color:red'>" + ex.Message + "</span>");
}
}
/// <summary>
/// Generate HASH for encrypt all parameter passing while transaction
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public string Generatehash512(string text)
{
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);
}
return hex;
}
}
}
change printer from c# , print via coding in asp.net , print without dialog box in asp.net c#
using System.Drawing.Printing;
using System.Drawing;
using System.Windows.Forms;
PrintDocument pdoc = null;
protected void Page_Load(object sender, EventArgs e)
{
print();
}
public void print()
{
PrintDialog pd = new PrintDialog();
pdoc = new PrintDocument();
pdoc.PrinterSettings.PrinterName = "Samsung SCX-3200 Series";
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 100, 200);
//ps.DefaultPageSettings.PaperSize = psize;
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
//pdoc.DefaultPageSettings.PaperSize.Height =320;
pdoc.DefaultPageSettings.PaperSize.Height = 400;
pdoc.DefaultPageSettings.PaperSize.Width = 314;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
// pdoc.Print();
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
result = pp.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font font = new Font("Courier New", 10);
float fontHeight = font.GetHeight();
int startX = 50;
int startY = 55;
int Offset = 40;
graphics.DrawString("Welcome to MSST", new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket No:" + your.TicketNo, new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket Date :" + your.ticketDate, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Source= this.source;
graphics.DrawString("From "+yourSource+" To "+yourDestination, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Grosstotal = "Total Amount to Pay = " + this.amount;
Offset = Offset + 20;
underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString(Grosstotal , new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String DrawnBy = this.drawnBy;
graphics.DrawString("Conductor - "+yourDrawnBy, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
}
using System.Drawing;
using System.Windows.Forms;
PrintDocument pdoc = null;
protected void Page_Load(object sender, EventArgs e)
{
print();
}
public void print()
{
PrintDialog pd = new PrintDialog();
pdoc = new PrintDocument();
pdoc.PrinterSettings.PrinterName = "Samsung SCX-3200 Series";
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 100, 200);
//ps.DefaultPageSettings.PaperSize = psize;
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
//pdoc.DefaultPageSettings.PaperSize.Height =320;
pdoc.DefaultPageSettings.PaperSize.Height = 400;
pdoc.DefaultPageSettings.PaperSize.Width = 314;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
// pdoc.Print();
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
result = pp.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font font = new Font("Courier New", 10);
float fontHeight = font.GetHeight();
int startX = 50;
int startY = 55;
int Offset = 40;
graphics.DrawString("Welcome to MSST", new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket No:" + your.TicketNo, new Font("Courier New", 14), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString("Ticket Date :" + your.ticketDate, new Font("Courier New", 12), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Source= this.source;
graphics.DrawString("From "+yourSource+" To "+yourDestination, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String Grosstotal = "Total Amount to Pay = " + this.amount;
Offset = Offset + 20;
underLine = "------------------------------------------";
graphics.DrawString(underLine, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
graphics.DrawString(Grosstotal , new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
Offset = Offset + 20;
String DrawnBy = this.drawnBy;
graphics.DrawString("Conductor - "+yourDrawnBy, new Font("Courier New", 10), new SolidBrush(Color.Black), startX, startY + Offset);
}
Tuesday, 13 September 2016
Eazypay Payment Gateway Integration in ASP.NET
This is to send request to payment gateway server
ASEKEY & merchantid will be provided by BANK after submitting return URL to bank
string redirecturl = ""; // this is to check what url is coming before encryption
string encryptredirecturl = "";
string ASEKEY = "xxxxxxxxxxxxxxxxxxxx";
string Reference_no, sub_merchant_id, pgamount, Mobile_No, city, name;
Reference_no ="your value";
sub_merchant_id ="your value";
pgamount = 000;
Mobile_No = "your value";;
city ="your value";
name = "your value";
redirecturl += "https://eazypay.icicibank.com/EazyPG?";
redirecturl += "merchantid=xxxxx";
redirecturl += "&mandatory fields=" + Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456";
redirecturl += "&optional fields=" + city + "|" + name;
redirecturl += "&returnurl=http://yourwebsite.com/eazypayreturn.aspx";
redirecturl += "&Reference No=" + Reference_no;
redirecturl += "&submerchantid=" + sub_merchant_id;
redirecturl += "&transaction amount=" + pgamount;
redirecturl += "&paymode=9";
encryptredirecturl += "https://eazypay.icicibank.com/EazyPG?";
encryptredirecturl += "merchantid=xxxxx";
encryptredirecturl += "&mandatory fields=" + encryptFile(Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456", ASEKEY);
encryptredirecturl += "&optional fields=" + encryptFile(city + "|" + name, ASEKEY);
encryptredirecturl += "&returnurl=" + encryptFile("http://yourwebsite.com/eazypayreturn.aspx", ASEKEY);
encryptredirecturl += "&Reference No=" + encryptFile(Reference_no, ASEKEY);
encryptredirecturl += "&submerchantid=" + encryptFile(sub_merchant_id, ASEKEY);
encryptredirecturl += "&transaction amount=" + encryptFile(pgamount, ASEKEY);
encryptredirecturl += "&paymode=" + encryptFile("9", ASEKEY);
Response.Redirect(encryptredirecturl);
-----------------------------------------------------------------------------------------
public static string encryptFile(string textToEncrypt, string key)
{
RijndaelManaged rijndaelCipher = new RijndaelManaged();
rijndaelCipher.Mode = CipherMode.ECB;
rijndaelCipher.Padding = PaddingMode.PKCS7;
rijndaelCipher.KeySize = 0x80;
rijndaelCipher.BlockSize = 0x80;
byte[] pwdBytes = Encoding.UTF8.GetBytes(key);
byte[] keyBytes = new byte[0x10];
int len = pwdBytes.Length;
if (len > keyBytes.Length)
{
len = keyBytes.Length;
}
Array.Copy(pwdBytes, keyBytes, len);
rijndaelCipher.Key = keyBytes;
rijndaelCipher.IV = keyBytes;
ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
return Convert.ToBase64String(transform.TransformFinalBlock(plainText,
0, plainText.Length));
}
************************************************************
ASEKEY & merchantid will be provided by BANK after submitting return URL to bank
string redirecturl = ""; // this is to check what url is coming before encryption
string encryptredirecturl = "";
string ASEKEY = "xxxxxxxxxxxxxxxxxxxx";
string Reference_no, sub_merchant_id, pgamount, Mobile_No, city, name;
Reference_no ="your value";
sub_merchant_id ="your value";
pgamount = 000;
Mobile_No = "your value";;
city ="your value";
name = "your value";
redirecturl += "https://eazypay.icicibank.com/EazyPG?";
redirecturl += "merchantid=xxxxx";
redirecturl += "&mandatory fields=" + Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456";
redirecturl += "&optional fields=" + city + "|" + name;
redirecturl += "&returnurl=http://yourwebsite.com/eazypayreturn.aspx";
redirecturl += "&Reference No=" + Reference_no;
redirecturl += "&submerchantid=" + sub_merchant_id;
redirecturl += "&transaction amount=" + pgamount;
redirecturl += "&paymode=9";
encryptredirecturl += "https://eazypay.icicibank.com/EazyPG?";
encryptredirecturl += "merchantid=xxxxx";
encryptredirecturl += "&mandatory fields=" + encryptFile(Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456", ASEKEY);
encryptredirecturl += "&optional fields=" + encryptFile(city + "|" + name, ASEKEY);
encryptredirecturl += "&returnurl=" + encryptFile("http://yourwebsite.com/eazypayreturn.aspx", ASEKEY);
encryptredirecturl += "&Reference No=" + encryptFile(Reference_no, ASEKEY);
encryptredirecturl += "&submerchantid=" + encryptFile(sub_merchant_id, ASEKEY);
encryptredirecturl += "&transaction amount=" + encryptFile(pgamount, ASEKEY);
encryptredirecturl += "&paymode=" + encryptFile("9", ASEKEY);
Response.Redirect(encryptredirecturl);
-----------------------------------------------------------------------------------------
public static string encryptFile(string textToEncrypt, string key)
{
RijndaelManaged rijndaelCipher = new RijndaelManaged();
rijndaelCipher.Mode = CipherMode.ECB;
rijndaelCipher.Padding = PaddingMode.PKCS7;
rijndaelCipher.KeySize = 0x80;
rijndaelCipher.BlockSize = 0x80;
byte[] pwdBytes = Encoding.UTF8.GetBytes(key);
byte[] keyBytes = new byte[0x10];
int len = pwdBytes.Length;
if (len > keyBytes.Length)
{
len = keyBytes.Length;
}
Array.Copy(pwdBytes, keyBytes, len);
rijndaelCipher.Key = keyBytes;
rijndaelCipher.IV = keyBytes;
ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
return Convert.ToBase64String(transform.TransformFinalBlock(plainText,
0, plainText.Length));
}
************************************************************
After coming back to return url , get response parameters and their vales
foreach (string key in HttpContext.Current.Request.Form.AllKeys)
{
string value = HttpContext.Current.Request.Form[key];
if (value == "E000")
{
//Success
}
else
{
//Error
}
}
Subscribe to:
Posts (Atom)