public IActionResult HandleResponse(IFormCollection form) { string secretKey = configuration["PaymentGatewaysecretKey"]; int orderId = Convert.ToInt32(Request.Form["orderId"]); string orderAmount = Request.Form["orderAmount"]; string referenceId = Request.Form["referenceId"]; string txStatus = Request.Form["txStatus"]; string paymentMode = Request.Form["paymentMode"]; string txMsg = Request.Form["txMsg"]; string txTime = Request.Form["txTime"]; string signature = Request.Form["signature"]; PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse() { Order = orderRepository.GetOrderDetailsById(orderId), paymentMode = paymentMode, orderAmount = orderAmount, referenceId = referenceId, txMsg = txMsg, txStatus = txStatus, txTime = txTime }; paymentGateway.AddPaymentGatewayResponse(paymentGatewayResponse); string signatureData = orderId + orderAmount + referenceId + txStatus + paymentMode + txMsg + txTime; var hmacsha256 = new HMACSHA256(StringEncode(secretKey)); byte[] gensignature = hmacsha256.ComputeHash(StringEncode(signatureData)); string computedsignature = Convert.ToBase64String(gensignature); if (signature == computedsignature && txStatus.Equals("SUCCESS")) { ViewData["panel"] = "panel panel-success"; ViewData["heading"] = "Signature Verification Successful"; orderRepository.UpdatePaymentSatus(orderId, "DoneOnlinepayment"); } else { ViewData["panel"] = "panel panel-danger"; ViewData["heading"] = "Signature Verification Failed"; orderRepository.UpdatePaymentSatus(orderId, "FailOnlinePayment"); return(RedirectToAction("Index", "OrderConformation", new { msg = "payfail", orderid = orderId })); } return(View(paymentGatewayResponse)); }