Last active
September 17, 2020 07:41
-
-
Save razarahil/85b1d58cb321b8b1ae2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to display custome invoice as only: txnid|amount|firstname|email in deferent LABEL in asp.net