private OrderModel Payments(RegisterViewModel registerViewModel) { Random randomObj = new Random(); string transactionId = randomObj.Next(10000000, 100000000).ToString(); Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_E2Zmqlh9v2Dj8U", "NPTQwUFJV6R36LW2fPir43pG"); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", 249); // Amount will in paise options.Add("receipt", transactionId); options.Add("currency", "INR"); options.Add("payment_capture", "0"); // 1 - automatic , 2 - manual //options.Add("notes", "-- You can put any notes here --"); Razorpay.Api.Order orderResponse = client.Order.Create(options); string orderId = orderResponse["id"].ToString(); // Create order model for return on view OrderModel orderModel = new OrderModel { orderId = orderResponse.Attributes["id"], razorpayKey = "rzp_test_E2Zmqlh9v2Dj8U", amount = 249, currency = "INR", name = registerViewModel.Business.BusinessOwner.FirstName + registerViewModel.Business.BusinessOwner.LastName, email = registerViewModel.Business.BusinessOwner.Email, contactNumber = registerViewModel.Business.BusinessOwner.MobileNumber, address = registerViewModel.Business.Address.AddressLine1 + registerViewModel.Business.Address.City, description = "TownerTown Payments" }; // Return on PaymentPage with Order data return(orderModel); }
public ActionResult Complete() { // Payment data comes in url so we have to get it from url // This id is razorpay unique payment id which can be use to get the payment details from razorpay server string paymentId = Request.Form["rzp_paymentid"]; //string paymentId = paymentid; // This is orderId string orderId = Request.Form["rzp_orderid"]; Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_jgSfZxfkVFDQ0t", "lQz5sINmfOOXXKmM6zPT225T"); Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId); // This code is for capture the payment Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", payment.Attributes["amount"]); Razorpay.Api.Payment paymentCaptured = payment.Capture(options); string amt = paymentCaptured.Attributes["amount"]; //// Check payment made successfully if (paymentCaptured.Attributes["status"] == "captured") { // Create these action method return(RedirectToAction("Success")); } else { return(RedirectToAction("Failed")); } }
public async Task <string> CompleteOrderProcess(IHttpContextAccessor _httpContextAccessor) { try { string paymentId = _httpContextAccessor.HttpContext.Request.Form["rzp_paymentid"]; // This is orderId string orderId = _httpContextAccessor.HttpContext.Request.Form["rzp_orderid"]; Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_8P7RhnsImxd2OR", "kD8tw7ECYsTTZnx0OyrKI4kh"); Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId); // This code is for capture the payment Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", payment.Attributes["amount"]); Razorpay.Api.Payment paymentCaptured = payment.Capture(options); string amt = paymentCaptured.Attributes["amount"]; return(paymentCaptured.Attributes["status"]); } catch (Exception) { throw; } }
public ActionResult CreateOrder(PaymentInitiateModel _requestData) { // Generate random receipt number for order Random randomObj = new Random(); string transactionId = randomObj.Next(10000000, 100000000).ToString(); Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_jgSfZxfkVFDQ0t", "lQz5sINmfOOXXKmM6zPT225T"); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", _requestData.amount * 100); // Amount will in paise options.Add("receipt", transactionId); options.Add("currency", "INR"); options.Add("payment_capture", "1"); // 1 - automatic , 0 - manual //options.Add("notes", "-- You can put any notes here --"); Razorpay.Api.Order orderResponse = client.Order.Create(options); //string orderId = orderResponse["id"].ToString(); // Create order model for return on view OrderModel orderModel = new OrderModel { //orderId = orderResponse.Attributes["id"], razorpayKey = "rzp_test_jgSfZxfkVFDQ0t", amount = _requestData.amount * 100, currency = "INR", name = _requestData.name, email = _requestData.email, contactNumber = _requestData.contactNumber, address = _requestData.address, description = "Testing description" }; // Return on PaymentPage with Order data return(View("PaymentPage", orderModel)); }
public IHttpActionResult verifyOrderRazorpay(string paymentId, string orderId) { // Payment data comes in url so we have to get it from url // This id is razorpay unique payment id which can be use to get the payment details from razorpay server string _paymentId = paymentId; // This is orderId string _orderId = orderId; Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_9wK0kOoAWrR2GV", "Um9kYEyRcQy8TRKGAUwGFLny"); Razorpay.Api.Payment payment = client.Payment.Fetch(_paymentId); // This code is for capture the payment Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", payment.Attributes["amount"]); Razorpay.Api.Payment paymentCaptured = payment.Capture(options); string amt = paymentCaptured.Attributes["amount"]; //// Check payment made successfully if (paymentCaptured.Attributes["status"] == "captured") { // Create these action method return(Ok("Sucessfull")); } else { return(Ok("ERROR occured")); } }
public IHttpActionResult createOrderRazorpay(Models.orderRazorpay order) { Random randomObj = new Random(); string transactionId = randomObj.Next(10000000, 100000000).ToString(); Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_9wK0kOoAWrR2GV", "Um9kYEyRcQy8TRKGAUwGFLny"); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", order.amount); // Amount will in paise options.Add("receipt", transactionId); options.Add("currency", order.currency); // options.Add("payment_capture", "0"); // 1 - automatic , 2 - manual //options.Add("notes", "-- You can put any notes here --"); Razorpay.Api.Order orderResponse = client.Order.Create(options); string retorderId = orderResponse["id"].ToString(); Models.orderRazorpay pay = new Models.orderRazorpay { amount = order.amount, currency = order.currency, name = order.name, email = order.email, mobileNumber = order.mobileNumber, address = order.address, orderId = retorderId }; return(Ok(pay)); }
public ActionResult Now(Models.PaymentInitiateModel requestData) { string transactionId = Randoms.Pattern("trans-{HEX:15}"); Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_DmK2S2Y4ATkGZz", "glz95rTDL8OE4kV3RsUo4UAj"); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", int.Parse(requestData.amount) * 100); options.Add("receipt", transactionId); options.Add("currency", "INR"); options.Add("payment_capture", "0"); //options.Add("notes", "Good to go"); Razorpay.Api.Order orderResponse = client.Order.Create(options); string orderId = orderResponse["id"].ToString(); // Create order model for return on view OrderModel orderModel = new OrderModel { orderId = orderResponse.Attributes["id"], razorpayKey = "rzp_test_DmK2S2Y4ATkGZz", amount = int.Parse(requestData.amount) * 100, currency = "INR", name = requestData.name, email = requestData.email, contactNumber = requestData.contact, address = requestData.address, description = "Testing description" }; // Return on PaymentPage with Order data return(View("Payment", orderModel)); }
public ActionResult Complete() { // Payment data comes in url so we have to get it from url // This id is razorpay unique payment id which can be use to get the payment details from razorpay server string paymentId = Request.Form["rzp_paymentid"]; //string paymentId = paymentid; // This is orderId string orderId = Request.Form["rzp_orderid"]; Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient(_keys.SecretKey, _keys.PublishKey); Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId); // This code is for capture the payment Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", payment.Attributes["amount"]); Razorpay.Api.Payment paymentCaptured = payment.Capture(options); string amt = paymentCaptured.Attributes["amount"]; //// Check payment made successfully if (paymentCaptured.Attributes["status"] == "captured") { string id = User.FindFirst("id").Value; var dataset = _unitOfWork.StudentModel.FeeDetailFunction(id); var paymentParam = new DynamicParameters(); paymentParam.Add("inUserId", id); //var dataset = _unitOfWork.SPCall.List<FeeDetails>(SD.FeeDetails, paymentParam); foreach (var data in dataset) { string emailbody = GetBody("feepayment", data.Name, " ", " ", " ", data.Month.ToString(), data.FeeCharge.ToString()); EmailConfig.SendMail(data.Email, "Welcome", emailbody); /*payment.name = data.Name; * payment.email = data.Email; * payment.contactNumber = "9931159589"; * payment.address = "Ranchi"; * payment.amount = data.FeeCharge; * payment.UserId = Convert.ToInt32(claimvalue);*/ // payment.User = user; } // Create these action method // string emailbody = GetBody("feepayment", FirstName, Email, Password); //EmailConfig.SendMail(Email, "Welcome", emailbody); //_unitOfWork.SPCall.List<FeeDetails>(SD.UpdateFeeDate, paymentParam); _unitOfWork.StudentModel.UpdateFeeDateFunction(id); return(RedirectToAction("Success")); } else { return(RedirectToAction("Failed")); } }
public async Task <ActionResult <Order> > Post(Order order) { string eMail = string.Empty; using (Utility util = new Utility()) { eMail = util.GetEmailclaim(User.Identity as ClaimsIdentity); } if (order.Id > 0) { order.UpdatedBy = eMail; await _repository.UpdateAsync <Order>(order); } else { order.CreatedBy = eMail; order.OrderUNId = Guid.NewGuid().ToString(); await _repository.AddAsync <Order>(order); if (order.IsCreditAllowed != "true") { int totalCharges = (int)Math.Ceiling(order.TotalCharges); var options = new Dictionary <string, object> { { "amount", totalCharges *100 }, // since it is paise mode { "currency", "INR" }, { "receipt", order.OrderUNId }, { "payment_capture", true } }; _razorpayClient = new Razorpay.Api.RazorpayClient(rzrKey, rzrSecret); var rzOrder = _razorpayClient.Order.Create(options); var orderId = rzOrder["id"].ToString(); var orderJson = rzOrder.Attributes.ToString(); order.RzOrderId = orderId; order.RzrKey = rzrKey; await _repository.UpdateAsync <Order>(order); // return Ok(orderJson); } //email id //Phone no //Name //userID //bookingId } return(GetOrder(order.Id)); }
public ActionResult Complete() { // Payment data comes in url so we have to get it from url // This id is razorpay unique payment id which can be use to get the payment details from razorpay server string paymentId = Request.Form["rzp_paymentid"]; // This is orderId string orderId = Request.Form["rzp_orderid"]; Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_E2Zmqlh9v2Dj8U", "NPTQwUFJV6R36LW2fPir43pG"); Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId); // This code is for capture the payment Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", payment.Attributes["amount"]); Razorpay.Api.Payment paymentCaptured = payment.Capture(options); string amt = paymentCaptured.Attributes["amount"]; //// Check payment made successfully int userId = _session.GetInt32("UserID").Value; Business business = _businessService.GetBusinessByUserID(userId); business.Payment.TransactionNumber = paymentId; _businessService.UpdatePayment(business); //_businessService.UpdateBusiness("PaymentID", paymentId, userId); if (paymentCaptured.Attributes["status"] == "captured") { _businessService.UpdateBusiness("Payment", "SUCCESSFULL", userId); // Create these action method ViewBag.Message = "Payment Successfull.Thanks for registering with TownerTown."; return(RedirectToAction("ViewProfile")); } else { _businessService.UpdateBusiness("Payment", "FAILED", userId); ViewBag.Message = "Sorry Payment Failed.Please try again later"; return(RedirectToAction("LogIn", "Home")); } }
public Task <MerchantOrder> ProcessMerchantOrder(PaymentRequest payRequest) { try { // Generate random receipt number for order Random randomObj = new Random(); string transactionId = randomObj.Next(10000000, 100000000).ToString(); Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_8P7RhnsImxd2OR", "kD8tw7ECYsTTZnx0OyrKI4kh"); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", payRequest.Amount * 100); options.Add("receipt", transactionId); options.Add("currency", "INR"); options.Add("payment_capture", "0"); // 1 - automatic , 0 - manual //options.Add("Notes", "Test Payment of Merchant"); Razorpay.Api.Order orderResponse = client.Order.Create(options); string orderId = orderResponse["id"].ToString(); MerchantOrder order = new MerchantOrder { OrderId = orderResponse.Attributes["id"], RazorpayKey = "rzp_test_8P7RhnsImxd2OR", Amount = payRequest.Amount * 100, Currency = "INR", Name = payRequest.Name, Email = payRequest.Email, PhoneNumber = payRequest.PhoneNumber, Address = payRequest.Address, Description = "Order by Merchant" }; return(Task.FromResult(order)); } catch (Exception ex) { throw; } }
public IActionResult RegisterFormFilled(RegisterViewModel registerViewModel) { //registerViewModel.Business.Category.CategoryName = registerViewModel.SearchViewModel.selectedCategory; if (ValidateBusiness(registerViewModel.Business)) { if (registerViewModel.uploadImagesFormFile != null) { List <FilePath> imagesFilesPath = new List <FilePath>(); foreach (var imageFormFile in registerViewModel.uploadImagesFormFile) { var uniqueFileName = GetUniqueFileName(imageFormFile.FileName); var uploads = Path.Combine(hostingEnvironment.WebRootPath, "uploads"); var filePath = Path.Combine(uploads, uniqueFileName); imageFormFile.CopyTo(new FileStream(filePath, FileMode.Create)); FilePath newImageFile = new FilePath(); //newImageFile.Path = filePath; newImageFile.Path = "~/uploads/" + imageFormFile.FileName; imagesFilesPath.Add(newImageFile); } registerViewModel.Business.Images = imagesFilesPath; //to do : Save uniqueFileName to your db table } //registerViewModel.Business.Timings = new Timings { Monday = new DayToTimeMapping { StartTime = "10:23", EndTime = "9:00", Closed = false} }; //if (_businessService.AddNewBusiness(registerViewModel.Business) != null) ////if (true) //{ //return Json(new { success = true, responseText = "You have been successfully registered with Search India. Please Log_in to view your profile" }); try { Random randomObj = new Random(); string transactionId = randomObj.Next(10000000, 100000000).ToString(); Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_E2Zmqlh9v2Dj8U", "NPTQwUFJV6R36LW2fPir43pG"); Dictionary <string, object> options = new Dictionary <string, object>(); options.Add("amount", 249); // Amount will in paise options.Add("receipt", transactionId); options.Add("currency", "INR"); options.Add("payment_capture", "0"); // 1 - automatic , 2 - manual //options.Add("notes", "-- You can put any notes here --"); Razorpay.Api.Order orderResponse = client.Order.Create(options); string orderId = orderResponse["id"].ToString(); // Create order model for return on view OrderModel orderModel = new OrderModel { orderId = orderResponse.Attributes["id"], razorpayKey = "rzp_test_E2Zmqlh9v2Dj8U", amount = 249, currency = "INR", name = registerViewModel.Business.BusinessOwner.FirstName + registerViewModel.Business.BusinessOwner.LastName, email = registerViewModel.Business.BusinessOwner.Email, contactNumber = registerViewModel.Business.BusinessOwner.MobileNumber, address = registerViewModel.Business.Address.AddressLine1 + registerViewModel.Business.Address.City, description = "TownerTown Payments" }; Payment payment = new Payment(); registerViewModel.Business.Payment = payment; registerViewModel.Business.Payment.address = orderModel.name; registerViewModel.Business.Payment.orderId = orderModel.orderId; registerViewModel.Business.Payment.PayedOn = DateTime.Now; registerViewModel.Business.Payment.PaymentStatus = PaymentStatus.INPROGRESS; registerViewModel.Business.Payment.Amount = orderModel.amount; registerViewModel.Business.Payment.contactNumber = orderModel.contactNumber; registerViewModel.Business.Payment.currency = orderModel.currency; registerViewModel.Business.Payment.description = orderModel.description; registerViewModel.Business.Payment.email = orderModel.email; registerViewModel.Business.Payment.name = orderModel.name; registerViewModel.Business.Payment.razorpayKey = orderModel.razorpayKey; registerViewModel.Business.Payment.TransactionNumber = "value"; Business business = _businessService.AddNewBusiness(registerViewModel.Business); if (business != null) { _session.SetInt32("UserID", business.BusinessOwner.ID); return(View("Payments", orderModel)); } } catch (Exception ex) { //throw (e); string message = string.Format("<b>Message:</b> {0}<br /><br />", ex.Message); message += string.Format("<b>StackTrace:</b> {0}<br /><br />", ex.StackTrace.Replace(Environment.NewLine, string.Empty)); message += string.Format("<b>Source:</b> {0}<br /><br />", ex.Source.Replace(Environment.NewLine, string.Empty)); message += string.Format("<b>TargetSite:</b> {0}", ex.TargetSite.ToString().Replace(Environment.NewLine, string.Empty)); ModelState.AddModelError(string.Empty, message); ViewBag.Message = message; return(View("Register")); } //} } else { return(View("Register")); //return Json(new { success = false, responseText = "OOOpppsss....Something went wrong, the registration cannot be saved at this movement please contact customer support." }); } return(View("Register")); //return Json(new { success = false, responseText = "Validation doesn't match. Please check validation error message for more details" }); }
public async Task <ActionResult <Order> > ConfirmPayment([FromBody] ConfirmPaymentPayload confirmPayment) { var attributes = new Dictionary <string, string> { { "razorpay_order_id", confirmPayment.razorpay_order_id }, { "razorpay_payment_id", confirmPayment.razorpay_payment_id }, { "razorpay_signature", confirmPayment.razorpay_signature } }; try { // Razorpay.Api.Utils.ValidatePaymentSignature(attributes); var cobinedValues = confirmPayment.cart_order_id + "|" + confirmPayment.razorpay_payment_id; string hashHMACHex = cobinedValues.HmacSha256Digest(rzrKey); //if (hashHMACHex == confirmPayment.razorpay_signature) //{ _razorpayClient = new Razorpay.Api.RazorpayClient(rzrKey, rzrSecret); /*Later this will be on PRod*/ // utils.verifyPaymentSignature(attributes); // OR //var payload =confirmPayment.razorpay_order_id + '|' + confirmPayment.razorpay_payment_id; //Razorpay.Api.Utils.verifyWebhookSignature(payload, confirmPayment.razorpay_signature, rzrKey); var order = _razorpayClient.Order.Fetch(confirmPayment.razorpay_order_id); var payment = _razorpayClient.Payment.Fetch(confirmPayment.razorpay_payment_id); var currentOrder = _repository.FindSingle <Order>(x => x.OrderUNId == confirmPayment.cart_order_id, new string[] { "VesselCharge" }); if (payment["status"] == "captured" && order["status"] == "paid") { if (currentOrder != null) { currentOrder.RzPaymentId = confirmPayment.razorpay_payment_id; currentOrder.RzSignature = confirmPayment.razorpay_signature; currentOrder.TransactionStatus = "Sucesss"; } // return Ok("Payment Successful"); } else { if (currentOrder != null) { currentOrder.RzPaymentId = null; currentOrder.RzSignature = null; currentOrder.TransactionStatus = "Failed"; } await _repository.UpdateAsync <Order>(currentOrder); } return(GetOrder(currentOrder.Id)); //} } catch (Exception ex) { return(NotFound(new ApiResponse(500, ex.Message))); } }