Friday, 23 January 2015

Authorize.net integration Error , The merchant login ID or password is invalid or the account is inactive.Integrate Authorize.net Payment Geteway in asp.net c# mvc4

found these two lines in their Gateway class:
 problem? The problem is that even in “test” mode, you’re supposed to use the https://secure* URL. I’m like, “whatever” and changed the code to this:
   
Authorize.net payment integration code in asp.net with c sharp(#) mvc4
-------------------Controller Code-------------------------------------- public ActionResult SendPayment(int id=0) { if (id != null && id != 0) { var advpla = db.tbl_Advertisement.Where(o => o.AdverisementId == id).SingleOrDefault(); string loginID = ConfigurationManager.AppSettings["loginID"].ToString(); string transactionKey = ConfigurationManager.AppSettings["transactionKey"].ToString(); string amount = String.Format("{0:0.00}", advpla.TotalCost); Random random = new Random(); string sequence = (random.Next(0, 1000)).ToString(); string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString(); string fingerprint = HMAC_MD5(transactionKey, loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^"); TempData["amt"] = amount; TempData["loginID"] = loginID; TempData["sequence"] = sequence; TempData["timeStamp"] = timeStamp; TempData["fingerprint"] = fingerprint; return View(advpla); } return View(); } string HMAC_MD5(string key, string value) { // The first two lines take the input values and convert them from strings to Byte arrays byte[] HMACkey = (new System.Text.ASCIIEncoding()).GetBytes(key); byte[] HMACdata = (new System.Text.ASCIIEncoding()).GetBytes(value); // create a HMACMD5 object with the key set HMACMD5 myhmacMD5 = new HMACMD5(HMACkey); //calculate the hash (returns a byte array) byte[] HMAChash = myhmacMD5.ComputeHash(HMACdata); //loop through the byte array and add append each piece to a string to obtain a hash string string fingerprint = ""; for (int i = 0; i < HMAChash.Length; i++) { fingerprint += HMAChash[i].ToString("x").PadLeft(2, '0'); } return fingerprint; } ------------------------------End------------------------------------------------ ---------------------------------------View Code--------------------------------- <body> <form id="simForm" name="simForm" method='post' action='https://secure.authorize.net/gateway/transact.dll'> @{ string itm = "" + @Model.PackageName + "<|>SeekZilla<|>Advertisement Plan<|>1<|>" + @Model.TotalCost.ToString("F") + "<|>"; } <input id="HiddenValue" type="hidden" value="Initial Value" /> <input type='hidden' name='x_line_item' id='x_line_item' value='@itm' /> <input type='hidden' name='x_login' id='x_login' value="@TempData["loginID"]" /> <input type='hidden' name='x_amount' id='x_amount' value="@Model.TotalCost.ToString("F")" /> <input type='hidden' name='x_description' id='x_description' value="Sample Transaction" /> <input type='hidden' name='x_invoice_num' id='x_invoice_num' value="@DateTime.Now.ToString(" yyyymmddhhmmss")" /> <input type='hidden' name='x_fp_sequence' id='x_fp_sequence' value="@TempData["sequence"]" /> <input type='hidden' name='x_fp_timestamp' id='x_fp_timestamp' value="@TempData["timeStamp"]" /> <input type='hidden' name='x_fp_hash' id='x_fp_hash' value="@TempData["fingerprint"]" /> <input type='hidden' name='x_test_request' id='x_test_request' value="false" /> <input type='hidden' name='x_show_form' value='PAYMENT_FORM' /> <input type=HIDDEN name="x_receipt_link_method" value="LINK"> <input type=HIDDEN name="x_receipt_link_text" value="Dont Close it, Dont go Back just Click here to confirm Payment and return to Seekzilla"> <input type=hidden name="x_receipt_link_url" value="http://seekzilla.com/Employee/Advertisement/ReturnSuccess?empid=@WebSecurity.CurrentUserId&AdverisementId=@Model.AdverisementId"> <input type='hidden' name='x_cancel_url' value='http://seekzilla.com/Employee/Advertisement/ReturnCancel?empid=@WebSecurity.CurrentUserId&AdverisementId=@Model.AdverisementId' /> </form> <h4>Redirecting to paypal... </h4> <script language="javascript"> document.simForm.submit(); </script> </body> ----------------------End View Code-------------------------------------------


No comments:

Post a Comment