public ActionResult PaymentSuccess() { PaymentSuccessModel model = new PaymentSuccessModel(); model.amount = Request.Form.Get("amount"); model.oid = Request.Form.Get("ReturnOid"); model.TransId = Request.Form.Get("TransId"); model.AuthCode = Request.Form.Get("AuthCode"); model.mdStatus = Request.Form.Get("mdStatus"); model.Policy_Number = Request.Form.Get("PolicyNumber"); model.email = Request.Form.Get("email"); var policyNumber = Request.Form.Get("PolicyNumber"); if (model.mdStatus == "1" || model.mdStatus == "2" || model.mdStatus == "3" || model.mdStatus == "4") { string fullPath = System.Web.Hosting.HostingEnvironment.MapPath("~/PolicyPDF/" + model.TransId + model.amount + ".pdf"); PaymentModel pat = new PaymentModel(); pat.Pat = _ps.GetPolicyIdByPolicyNumber(policyNumber); _ps.UpdatePaymentStatus(policyNumber); var actionResult = new ViewAsPdf("Print", pat); var byteArray = actionResult.BuildPdf(ControllerContext); var fileStream = new FileStream(fullPath, FileMode.Create, FileAccess.Write); fileStream.Write(byteArray, 0, byteArray.Length); fileStream.Close(); // ADD MAIL ADRESS var inlineLogo = new LinkedResource(System.Web.HttpContext.Current.Server.MapPath("~/Content/img/EmailHeaderSuccess.png")); inlineLogo.ContentId = Guid.NewGuid().ToString(); string body1 = string.Format(@" <div style='margin-left:20px'> <img style='width:700px' src=""cid:{0}"" /> <p> <b>Welcome to Insured Traveling </b> - the standalone platform for online sales of insurance policies.</p> <br /> <br /> <br />" + "Успешно извршена трансакција \n Уплатена сума: " + model.amount + " ден. \n Трансакциски код: " + model.TransId + "\n Автентикациски код: " + model.AuthCode + "<br /> <br />Thank you for using our Insurence Service</div>" , inlineLogo.ContentId); var view = AlternateView.CreateAlternateViewFromString(body1, null, "text/html"); view.LinkedResources.Add(inlineLogo); var PolicyHolderEmail = _ps.GetPolicyHolderEmailByPolicyId(pat.Pat.ID); MailService mailService = new MailService(PolicyHolderEmail); mailService.setSubject("Издадена полиса број: " + model.oid); mailService.setBodyText(body1, true); mailService.AlternativeViews(view); mailService.attach(new System.Net.Mail.Attachment(fullPath)); mailService.sendMail(); } return(View(model)); }
public IActionResult Success(string provider) { UserSession session = GetUserSession(); BaseModelData modelData = GetModelData(); modelData.ReplaceCartSummary(new ShoppingCartSummary(0, 0, 0, 0, 0, GetDefaultTaxRate(), System.Threading.Thread.CurrentThread.CurrentUICulture, SharedPluginFeatures.Constants.CurrencyCodeDefault)); PaymentSuccessModel model = new PaymentSuccessModel(modelData, (int)session.Tag); // clear basket data session.Tag = null; session.UserBasketId = 0; CookieDelete(SharedPluginFeatures.Constants.ShoppingCart); return(View(model)); }
public async Task <IActionResult> ViewPaymentSlip(string id) { Payment paymentData = await _paymentService.GetPaymentMasterByOrderIdAsync(id); PaymentSuccessModel _PaymentSuccessModel = new PaymentSuccessModel(); if (paymentData != null) { _PaymentSuccessModel = new PaymentSuccessModel() { OrderId = paymentData.OrderId, ReferenceNumber = paymentData.MerchantRefNo, PaymentMethod = paymentData.PaymentMethod, TransactionId = paymentData.TransactionId, PaymentStatus = "Success", PaymentDate = paymentData.PaidOn.ToString("dd/MM/yyyy hh:mm tt"), Amount = paymentData.TotalFee.ToString(), BankName = "HDFC" }; } return(View(_PaymentSuccessModel)); }
public async Task <IActionResult> PayUPaymentResponse(IFormCollection form) { PaymentSuccessModel _PaymentSuccessModel = new PaymentSuccessModel(); 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") { string email = form["email"].ToString(); string name = form["firstname"].ToString(); string amount = form["amount"].ToString(); string txnid = form["txnid"].ToString(); string oid = Request.Form["txnid"]; order_id = Request.Form["txnid"]; string mihpayid = Request.Form["mihpayid"]; string mode = Request.Form["mode"]; string bank_ref_num = Request.Form["bank_ref_num"]; string DateCreated = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"); string PaymentID = Request.Form["mihpayid"]; ViewData["Message"] = "Status is successful. Hash value is matched"; ViewData["response"] = "success"; var userDetails = await _dapperService.CustomFindByEmailAsync(emailAddress : email); Registration registrationDetails = new Registration(); if (userDetails != null) { var allRegistrationDetails = await _dapperService.GetAllRegistrationDetailsAsync(); registrationDetails = allRegistrationDetails.FirstOrDefault(f => f.UserId == userDetails.Id); } _PaymentSuccessModel = new PaymentSuccessModel() { OrderId = order_id, ReferenceNumber = bank_ref_num, PaymentMethod = mode, TransactionId = PaymentID, PaymentStatus = "Success", PaymentDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"), Amount = amount, BankName = "HDFC", REFNO = registrationDetails.RefNo, UserId = userDetails.Id }; // Update in Payemnt Master try { Payment paymentModel = await _paymentService.UpdatePaymentMasterByOrderIdAsync(order_id, _PaymentSuccessModel); } catch (Exception ex1) { Console.WriteLine(ex1.Message); } } else { _PaymentSuccessModel = new PaymentSuccessModel() { OrderId = order_id, ReferenceNumber = "", PaymentMethod = "", TransactionId = "", PaymentStatus = "Failure", PaymentDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"), Amount = "", BankName = "HDFC" }; } } catch (Exception ex) { // Response.Write("<span style='color:red'>" + ex.Message + "</span>"); Console.WriteLine(ex.Message); } return(View(_PaymentSuccessModel)); }
public async Task <Payment> UpdatePaymentMasterByOrderIdAsync(string OrderId, PaymentSuccessModel paymentSuccessModel) { Payment paymentData = dbContext.PaymentMaster.Where(s => s.OrderId.ToUpper().Trim() == OrderId.ToUpper().Trim()).FirstOrDefault(); if (paymentData != null) { paymentData.TransactionPaymentId = paymentSuccessModel.TransactionId.ToString(); paymentData.PaymentMethod = paymentSuccessModel.PaymentMethod.ToString(); paymentData.ResponseCode = "0"; paymentData.ResponseMessage = paymentSuccessModel.PaymentStatus.ToUpper().ToString(); paymentData.TransactionId = paymentSuccessModel.TransactionId.ToString(); paymentData.MerchantRefNo = paymentSuccessModel.ReferenceNumber.ToString(); paymentData.PaidStatus = 1; paymentData.PaidBy = paymentSuccessModel.BankName; paymentData.PaidOn = DateTime.Now; try { dbContext.PaymentMaster.Attach(paymentData); dbContext.Entry(paymentData).Property(x => x.TransactionPaymentId).IsModified = true; dbContext.Entry(paymentData).Property(x => x.PaymentMethod).IsModified = true; dbContext.Entry(paymentData).Property(x => x.ResponseMessage).IsModified = true; dbContext.Entry(paymentData).Property(x => x.TransactionId).IsModified = true; dbContext.Entry(paymentData).Property(x => x.MerchantRefNo).IsModified = true; dbContext.Entry(paymentData).Property(x => x.PaidStatus).IsModified = true; dbContext.Entry(paymentData).Property(x => x.PaidBy).IsModified = true; dbContext.Entry(paymentData).Property(x => x.PaidOn).IsModified = true; var result = await dbContext.SaveChangesAsync(); try { Registration registrationMasterData = dbContext.RegistrationMaster.Where(s => s.RefNo.ToUpper().Trim() == paymentData.RefNo.ToUpper().Trim()).FirstOrDefault(); if (registrationMasterData != null) { registrationMasterData.FinalSubmitTimeStamp = paymentData.PaidOn; registrationMasterData.PaymentDoneTimeStamp = paymentData.PaidOn; registrationMasterData.IsFinalSubmit = "Yes"; registrationMasterData.IsPaymentDone = "Yes"; dbContext.RegistrationMaster.Attach(registrationMasterData); dbContext.Entry(registrationMasterData).Property(x => x.IsFinalSubmit).IsModified = true; dbContext.Entry(registrationMasterData).Property(x => x.FinalSubmitTimeStamp).IsModified = true; dbContext.Entry(registrationMasterData).Property(x => x.IsPaymentDone).IsModified = true; dbContext.Entry(registrationMasterData).Property(x => x.PaymentDoneTimeStamp).IsModified = true; var resultRegData = await dbContext.SaveChangesAsync(); string sms = "We have received Rs. " + paymentData.TotalFee.ToString() + " with Transaction Id: " + paymentSuccessModel.TransactionId + " against Refno " + paymentData.RefNo + ". Thanks KU NAINITAL"; //string answer = GenFx.gosms(registrationMasterData.MobileNo, sms); await _centerService.SendSmsAsync(registrationMasterData.MobileNo, sms); } } catch (Exception ex1) { Console.WriteLine(ex1.Message); } //dbContext.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(paymentData); }