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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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 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" });
        }