Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void PayNow()
{
//initialize
tokenContext.setPaymentMessageSession(null);
ViewData["PaymentMessage"] = null;
EMedical.DataModel.UserLabTest labTest = tokenContext.getCurrentUserTest();
if (labTest != null)
{
string firstName = labTest.PatientName;
string amount = labTest.PayablePrice.ToString();
string productInfo = "Lab Product Purchase Online";
string email = labTest.Email;
string phone = labTest.ContactNumber;
RemotePost myremotepost = new RemotePost();
string key = ConfigurationManager.AppSettings["MERCHANT_KEY"];
string salt = ConfigurationManager.AppSettings["SALT"];
var DomainName = System.Web.HttpContext.Current.Request.Url.Host;
//posting all the parameters required for integration.
myremotepost.Url = ConfigurationManager.AppSettings["PAYU_BASE_URL"];
myremotepost.Add("key", ConfigurationManager.AppSettings["MERCHANT_KEY"]);
string txnid = Generatetxnid();
myremotepost.Add("txnid", txnid);
myremotepost.Add("amount", amount);
myremotepost.Add("productinfo", productInfo);
myremotepost.Add("firstname", firstName);
myremotepost.Add("phone", phone);
myremotepost.Add("email", email);
myremotepost.Add("surl", "http://" + DomainName + "/User/Return");//Change the success url here depending upon the port number of your local system.
myremotepost.Add("furl", "http://" + DomainName + "/User/Return");//Change the failure url here depending upon the port number of your local system.
myremotepost.Add("service_provider", "payu_paisa");
string hashString = key + "|" + txnid + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt;
string hash = Generatehash512(hashString);
myremotepost.Add("hash", hash);
myremotepost.Post();
}
}
[AllowAnonymous]
public ActionResult Return(FormCollection form=null)
{
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 (form["status"].ToString() == "success")
{
merc_hash_vars_seq = hash_seq.Split('|');
Array.Reverse(merc_hash_vars_seq);
merc_hash_string = ConfigurationManager.AppSettings["SALT"] + "|" + form["status"].ToString();
foreach (string merc_hash_var in merc_hash_vars_seq)
{
merc_hash_string += "|";
merc_hash_string = merc_hash_string + (form[merc_hash_var] != null ? form[merc_hash_var] : "");
}
Response.Write(merc_hash_string);
merc_hash = Generatehash512(merc_hash_string).ToLower();
order_id = Request.Form["txnid"];
}
else
{
tokenContext.setPaymentMessageSession("Payment Fails! Order Pending to save.");
}
}
catch (Exception ex)
{
ViewData["PaymentMessage"] = "Payment Fails! Order Pending to save.";
}
return RedirectToAction("ActionName");
}
@Dilipkumarromi

This comment has been minimized.

Copy link

@Dilipkumarromi Dilipkumarromi commented Sep 17, 2020

how to display custome invoice as only: txnid|amount|firstname|email in deferent LABEL in asp.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment