Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100);

            string key    = "rzp_test_izxMcE5W7qw3F1";
            string secret = "285uHLwwjZOIqrinhAK5P3Vn";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);
            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);

            try
            {
                Utils.verifyPaymentSignature(attributes);
                payment_res.Text = "Paid";

                Payment payment = client.Payment.Fetch(paymentId);

                Payment paymentCaptured = payment.Capture(input);
                payment_res.Text = "Payment successfully and Caputred";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public MiniDonationModel CreateOrderRazorPay(MiniDonationModel model)
        {
            try
            {
                var typeNmae = model.MType;
                Dictionary <string, object> input = new Dictionary <string, object>();
                input.Add("amount", model.Amount * 100); // this amount should be same as transaction amount
                input.Add("currency", typeNmae);
                input.Add("receipt", model.DonateId.ToString());
                input.Add("payment_capture", 1);

                Dictionary <string, string> notees = new Dictionary <string, string>();
                notees.Add("CampaignId", model.campaignId.ToString()); // this amount should be same as transaction amount

                input.Add("notes", notees);
                string key    = ConfigurationManager.AppSettings["RPapikey"];
                string secret = ConfigurationManager.AppSettings["RPSecretkey"];
                //string key = "rzp_test_5iPslGRlz5M0ss";
                //string secret = "qEsCxVcyaRoSAatpBaVZMBdp";
                ////string key = "rzp_live_S9v0s4ePfuxE1p";
                ////string secret = "KJylHsBzeIlVeF336TPxjk6w";
                System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
                RazorpayClient     client = new RazorpayClient(key, secret);
                Razorpay.Api.Order order  = client.Order.Create(input);
                var orderId = order["id"].ToString();
                model.orderId     = orderId;
                model.RazorPayKey = key;
                UpdateCampaignDonationorder(model.DonateId, orderId, "", "");
                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string key    = "rzp_test_2pjQoIV7c1RY6C";
            string secret = "nWwe91xQO3NIDzJUp1mUmr9O";


            ListDictionary trf = new ListDictionary();

            trf.Add("amount", 500);
            trf.Add("account", "acc_EDR7BXuzPGG3kQ");
            trf.Add("currency", "INR");

            ArrayList lst = new ArrayList();

            lst.Add(trf);

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 10000); // this amount should be same as transaction amount
            input.Add("currency", "INR");
            input.Add("receipt", "12121");
            input.Add("payment_capture", 1);

            input.Add("transfers", lst);
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
            RazorpayClient client = new RazorpayClient(key, secret);

            Razorpay.Api.Order order = client.Order.Create(input);
            orderId = order["id"].ToString();
            Console.WriteLine("order");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string key    = "rzp_test_xxxxxxxx";
            string secret = "xxxxxxxxxxxxxx";


            ListDictionary trf = new ListDictionary();

            trf.Add("amount", 500);
            trf.Add("account", "acc_EDR7BXuzPGG3kQ");
            trf.Add("currency", "INR");

            ArrayList lst = new ArrayList();

            lst.Add(trf);

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 10000); // this amount should be same as transaction amount
            input.Add("currency", "INR");
            input.Add("receipt", "12121");
            input.Add("payment_capture", 1);

            input.Add("transfers", lst);

            RazorpayClient client = new RazorpayClient(key, secret);

            Razorpay.Api.Order order = client.Order.Create(input);
            orderId = order["id"].ToString();
            Console.WriteLine("order");
        }
Exemplo n.º 5
0
    protected void DoCapture(object sender, EventArgs e)
    {
        try{
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 |
                                                   (SecurityProtocolType)768 | (SecurityProtocolType)3072;
            string         paymentId            = Convert.ToString(payId.Value);
            string         key                  = "rzp_live_UgPmY6nou3J6gA";
            string         secret               = "cd0UpWslSxzCmIeI1AZQl3At";
            RazorpayClient client               = new RazorpayClient(key, secret);
            Dictionary <string, object> options = new Dictionary <string, object>();
            options.Add("amount", payAmt.Value);
            Payment payment = client.Payment.Fetch(paymentId);

            Payment paymentCaptured = payment.Capture(options);
            var     values          = JObject.FromObject(paymentCaptured).ToObject <Dictionary <string, object> >();
            string  s = string.Format(@"""status"": ""captured""");
            object  zz;
            if (values.TryGetValue("Attributes", out zz))
            {
                if (zz.ToString().Contains(s))
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "ShowStatus", "javascript:alert('payment captured');", true);
                    Button1_Click(Button1, EventArgs.Empty);
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert(' capture failed');", true);
                }
            }
        }
        catch (Exception eec) { ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert(' capture failed');", true); }
    }
Exemplo n.º 6
0
        public ActionResult PayYourDonations(MiniDonationModel model)
        {
            var typeM    = (MoneyType)(Convert.ToInt32(model.MType));
            var typeNmae = typeM.DisplayName();

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", model.Amount * 100); // this amount should be same as transaction amount
            input.Add("currency", typeNmae);
            input.Add("receipt", model.DonateId.ToString());
            input.Add("payment_capture", 0);

            string key    = ConfigurationManager.AppSettings["RPapikey"];
            string secret = ConfigurationManager.AppSettings["RPSecretkey"];

            //string key = "rzp_test_5iPslGRlz5M0ss";
            //string secret = "qEsCxVcyaRoSAatpBaVZMBdp";
            ////string key = "rzp_live_S9v0s4ePfuxE1p";
            ////string secret = "KJylHsBzeIlVeF336TPxjk6w";
            ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            RazorpayClient client = new RazorpayClient(key, secret);

            Razorpay.Api.Order order = client.Order.Create(input);
            var orderId = order["id"].ToString();

            ViewBag.Order  = orderId;
            model.orderId  = orderId;
            ViewBag.Amount = model.Amount * 100;
            ViewBag.EMail  = model.Email;
            ViewBag.RPkey  = key;
            IService.UpdateCampaignDonationorder(model.DonateId, orderId, "", "");
            return(View(model));
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            if (paymentId == null)
            {
                string code        = Request.Form["error[code]"];
                string description = Request.Form["error[description]"];
            }
            Console.WriteLine("code");
            Console.WriteLine("description");


            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100);     // this amount should be same as transaction amount

            string key    = "rzp_test_2pjQoIV7c1RY6C";
            string secret = "nWwe91xQO3NIDzJUp1mUmr9O";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100); // this amount should be same as transaction amount

            string key    = "<Enter your Api Key here>";
            string secret = "<Enter your Api Secret here>";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            //   Refund refund = new Razorpay.Api.Payment((string) paymentId).Refund();

            //    Console.WriteLine(refund["id"]);

            pay = client.Order.Fetch(Request.Form["razorpay_order_id"]).Payments();
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100); // this amount should be same as transaction amount

            string key    = "rzp_test_WWMX02RJxJbpRZ";
            string secret = "9Zg6KhCALHF5fGBtmn54xo6S";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            Refund refund = new Razorpay.Api.Payment((string)paymentId).Refund();

            Console.WriteLine(refund["id"]);
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            if (paymentId == null)
            {
                // string[] errors = Request.Form.GetValues("error");

                string code        = Request.Form["error[code]"];
                string description = Request.Form["error[description]"];
            }
            else
            {
                Dictionary <string, object> input = new Dictionary <string, object>();
                input.Add("amount", 100); // this amount should be same as transaction amount

                string key    = "rzp_live_Nd4cMOpB2WTE5x";
                string secret = "wQX7T4vyT6vFRzWO9byy3kYa";

                RazorpayClient client = new RazorpayClient(key, secret);

                Dictionary <string, string> attributes = new Dictionary <string, string>();

                attributes.Add("razorpay_payment_id", paymentId);
                attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
                attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

                Utils.verifyPaymentSignature(attributes);
            }
        }
Exemplo n.º 11
0
        public ActionResult Charge()
        {
            string paymentId = Request.Form["razorpay_payment_id"];


            if (paymentId == null)
            {
                ViewData["code"]        = Request.Form["error[code]"];
                ViewData["description"] = Request.Form["error[description]"];
                return(View());
            }

            Dictionary <string, object> input = new Dictionary <string, object>();

            string key    = "rzp_test_xxxxxxxxxxx";
            string secret = "xxxxxxxxxxxxxxxxx";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);
            ViewData["msg"] = "Payment Sucessfull..!";
            ViewData["id"]  = Request.Form["razorpay_payment_id"];


            return(View());
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100); // this amount should be same as transaction amount

            string key    = "rzp_test_ATEfCSoziB6w9S";
            string secret = "sufLnnrlMaSC4pQIe0o3FZJK";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            //Refund refund = new Razorpay.Api.Payment((string) paymentId).Refund();

            //Console.WriteLine(refund["id"]);
        }
        // GET: CabsTaxis
        public ActionResult Pay(long?prime, long?vid, long?id, string userid, string amnt)
        {
            CabsTaxi forsale = db.CabsTaxis.Find(id);
            DateTime _date   = Convert.ToDateTime(DateTime.Now);

            _date = _date.AddDays(365);


            forsale.UserId = User.Identity.GetUserId();

            forsale.Status    = true;
            forsale.Date      = DateTime.Now;
            forsale.EndDate   = _date;
            forsale.StratDate = DateTime.Now;

            db.Entry(forsale).State = EntityState.Modified;
            db.SaveChanges();
            var            ids    = DateTime.Now.ToString("mmddyyyy");
            RazorpayClient client = new RazorpayClient(RazorPayConst.Api_Key, RazorPayConst.Key_Secret);
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", amnt); // amount in the smallest currency unit
            options.Add("receipt", "order_id" + ids);
            options.Add("currency", "INR");
            options.Add("payment_capture", "1");
            Order order = client.Order.Create(options);

            List <Order> payments = client.Order.All();
            string       datas    = payments[0]["id"];

            ViewBag.receipt = datas;

            return(View());
        }
        public IActionResult IntiatePayment(PaymentModel payModel)
        {
            Random         randomObj            = new Random();
            string         transactionId        = randomObj.Next(10000000, 100000000).ToString();
            RazorpayClient client               = new RazorpayClient("rzp_test_50YDal8CuXyEdq", "6DQJmgVX5EKkKsjUfZpxhtHE");
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", payModel.amount * 100);  // Amount will in paise
            options.Add("receipt", transactionId);
            options.Add("currency", "INR");
            options.Add("payment_capture", "0"); // 1 - automatic  , 0 - manual
                                                 //options.Add("notes", "-- You can put any notes here --");
            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_50YDal8CuXyEdq",
                amount        = payModel.amount * 100,
                currency      = "INR",
                name          = payModel.name,
                email         = payModel.email,
                contactNumber = payModel.contactNumber,
                address       = payModel.address,
                description   = "Testing description"
            };

            // Return on PaymentPage with Order data
            return(View("Payment", orderModel));
        }
Exemplo n.º 15
0
        //protected void Page_Load(object sender, EventArgs e)
        public void OnGet()
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100);     // this amount should be same as transaction amount

            string key    = "rzp_test_2pjQoIV7c1RY6C";
            string secret = "nWwe91xQO3NIDzJUp1mUmr9O";


            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            //Refund refund = new Razorpay.Api.Payment((string)paymentId).Refund();

            //Console.WriteLine(refund["id"]);
        }
        public ActionResult Charge()
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 3000); // this amount should be same as transaction amount

            string key    = "<Enter your Api Key here>";
            string secret = "<Enter your Api Secret here>";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            Refund refund = new Razorpay.Api.Payment((string)paymentId).Refund();

            Console.WriteLine(refund["id"]);
            return(View());
        }
Exemplo n.º 17
0
        /// <summary>
        /// get razor pay order id
        /// </summary>
        /// <param name="amount"></param>
        /// <returns></returns>
        public string GetRazorPayOrderID(double amount = 0)
        {
            try
            {
                string stringAmount = amount.ToString();
                //string stringReceipt = receipt.ToString();
                Dictionary <string, object> input = new Dictionary <string, object>();
                input.Add("amount", stringAmount); // this amount should be same as transaction amount
                input.Add("currency", "INR");
                input.Add("receipt", "Receipt");
                input.Add("payment_capture", 1);

                string key    = "rzp_live_zdMcQe4K4jLkpq";
                string secret = "AznDjQ8cnbwgz3YuaHIVru7M";

                RazorpayClient client = new RazorpayClient(key, secret);

                Razorpay.Api.Order order = client.Order.Create(input);

                var orderId = order["id"].ToString();
                return(orderId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string paymentId = Request.Form["razorpay_payment_id"];
                string orderId   = Request.Form["razorpay_order_id"];
                string signature = Request.Form["razorpay_signature"];

                string key    = "rzp_test_tyfQjoYyrPcAYz";
                string secret = "go9U0FIyUo7xiYvU9lG1Hll2";

                RazorpayClient client = new RazorpayClient(key, secret);

                Dictionary <string, string> attributes = new Dictionary <string, string>();

                attributes.Add("razorpay_payment_id", paymentId);
                attributes.Add("razorpay_order_id", orderId);
                attributes.Add("razorpay_signature", signature);

                Utils.verifyPaymentSignature(attributes);
                pTxnId.InnerText    = paymentId;
                pOrderId.InnerText  = orderId;
                h1Messege.InnerText = "Transaction Successfull";
                //Session["OrdID"].ToString()
                con.Open();
                SqlCommand cmd = new SqlCommand("sp_razorpay_success", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@order_id", Session["OrdID"]);
                cmd.Parameters.AddWithValue("@payment_id", paymentId);
                int i = cmd.ExecuteNonQuery();
                con.Close();
                if (i > 0)
                {
                    con.Open();
                    SqlCommand cmd3 = new SqlCommand("sp_tbl_cart", con);
                    cmd3.CommandType = CommandType.StoredProcedure;
                    cmd3.Parameters.AddWithValue("@action", "clearcart");
                    cmd3.Parameters.AddWithValue("@user_id", Session["userID"]);
                    cmd3.ExecuteNonQuery();
                    con.Close();
                    Session["OrdID"] = "";
                }
            }
            catch (Exception)
            {
                h1Messege.InnerText = "Transaction Falied";
                con.Open();
                SqlCommand cmd = new SqlCommand("sp_razorpay_falied", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@order_id", Session["OrdID"]);
                cmd.Parameters.AddWithValue("@user_id", Session["userID"]);
                int i = cmd.ExecuteNonQuery();
                con.Close();
                Session["OrdID"] = "";
            }
        }
Exemplo n.º 19
0
        public CheapPaymentGateway(IConfiguration configuration, ILogger logger)
        {
            _logger        = logger;
            RetryCount     = 1;
            _configuration = configuration;
            var clientId     = _configuration["ClientId"];
            var clientSecret = _configuration["ClientSecret"];

            razorpayClient = new RazorpayClient(clientId, clientSecret);
        }
Exemplo n.º 20
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string key    = TextBoxKey.Text;
            string secret = TextBoxSecret.Text;

            string         orderId        = TextBox1.Text.Trim();
            RazorpayClient razorpayClient = new RazorpayClient(key, secret);
            Order          order          = razorpayClient.Order.Fetch(orderId);

            TextBox2.Text = order.Attributes("id");
        }
        public string GenerateOrderId(decimal amount)
        {
            Dictionary <string, object> input = new Dictionary <string, object>
            {
                { "amount", amount * 100 },
                { "currency", "INR" }
            };
            RazorpayClient client = new RazorpayClient(key, secret);
            Order          order  = client.Order.Create(input);

            return(order["id"].ToString());
        }
Exemplo n.º 22
0
        public Object GetOrderId1([FromBody] RazorPaymentcs Order)
        {
            string            sJSONResponse  = "";
            DataTable         dt_AppType     = new DataTable();
            string            ServerDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
            int               a             = 0;
            string            AppType_Query = "";
            PaymentDetailsGet Pdetails      = new PaymentDetailsGet();

            string ReceiptNos = ReceiptNo();

            try
            {
                Dictionary <string, object> input = new Dictionary <string, object>();
                input.Add("amount", Order.Amount); // this amount should be same as transaction amount
                input.Add("currency", Order.Currency);
                input.Add("receipt", ReceiptNos);
                input.Add("payment_capture", 1);



                // string key = "rzp_live_1FlbqBOlw7TqHA";
                //string secret = "6UJyvn78r9xNlbckRZZDvqEZ";

                string key    = "rzp_test_51inWTBswRzU37";
                string secret = "u8dI6qRiT8bpvNIdTqvju7bQ";

                RazorpayClient client = new RazorpayClient(key, secret);

                Razorpay.Api.Order order = client.Order.Create(input);
                orderId = order["id"].ToString();

                cnn.Open();
                AppType_Query = "insert into PaymentGateway(GatewayProviderName,OrderId,BranchCode,MobileNo,ModeOfPayment,Amount,Currency,receipt,TransactionDate,CreatedOn,CreatedBy,IsDeleted,IsActive) values('GPN001','" + orderId + "','Brc1101','" + Order.MobileNo + "','OnLine','" + Order.Amount + "','INR','" + ReceiptNos + "','" + Order.TransactionDate + "','" + ServerDateTime + "','" + Order.MobileNo + "',0,1)  SELECT @@IDENTITY;";
                SqlCommand tm_cmd = new SqlCommand(AppType_Query, cnn);
                a = Convert.ToInt32(tm_cmd.ExecuteScalar());

                Pdetails.status  = "success";
                Pdetails.orderId = orderId;
            }
            catch (Exception ex)
            {
                Pdetails.status = "Fail";
            }
            finally
            {
                cnn.Close();
            }

            sJSONResponse = JsonConvert.SerializeObject(Pdetails);

            return(sJSONResponse);
        }
        public void VerifyPayment(TestProjectWebApi.Models.Payment payment)
        {
            RazorpayClient client = new RazorpayClient(key, secret);
            Dictionary <string, string> attributes = new Dictionary <string, string>
            {
                { "razorpay_payment_id", payment.Razorpay_payment_id },
                { "razorpay_order_id", payment.Razorpay_order_id },
                { "razorpay_signature", payment.Razorpay_signature }
            };

            Razorpay.Api.Utils.verifyPaymentSignature(attributes);
        }
Exemplo n.º 24
0
        public static void TestAppsDetails()
        {
            string title   = "ASP.NET";
            string version = "4.5";

            RazorpayClient.setAppsDetails(title, version);

            List <Dictionary <string, string> > appsDetails = RazorpayClient.AppsDetails;

            Assert.True(appsDetails.Count == 1);
            Assert.AreSame(title, appsDetails[0]["title"]);
            Assert.AreSame(version, appsDetails[0]["version"]);
        }
Exemplo n.º 25
0
        public List <Billing> PlaceOrder(List <Billing> obj)
        {
            List <Billing> lst      = new List <Billing>();
            long           TotalAmt = 0;
            string         OrderId  = string.Empty;
            string         Receipt  = string.Empty;

            using TransactionScope transactionScope = new TransactionScope();
            try
            {
                foreach (var item in obj)
                {
                    TotalAmt += item.TotalAmount;
                }
                Receipt = ReceiptGeneration();
                if (obj[0].PaymentType.Equals("ONLINE"))
                {
                    Dictionary <string, object> input = new Dictionary <string, object>
                    {
                        { "amount", TotalAmt },
                        { "currency", "INR" },
                        { "receipt", Receipt },
                        { "payment_capture", 1 }
                    };

                    objDAL.GetRazorPayKeys(obj[0].CompanyID, out string key, out string secret);
                    RazorpayClient client = new RazorpayClient(key, secret);

                    Order order = client.Order.Create(input);

                    OrderId = order["id"].ToString();

                    lst = objDAL.SavePlaceOrder(obj, OrderId);
                }
                else
                {
                    lst = objDAL.SavePlaceOrder(obj, Receipt);
                }
                transactionScope.Complete();
                transactionScope.Dispose();
            }
            catch (Exception ex)
            {
                transactionScope.Dispose();
                throw ex;
            }

            return(lst);
        }
Exemplo n.º 26
0
        /// <summary>
        /// payment status
        /// </summary>
        /// <param name="OrderId"></param>
        /// <returns></returns>
        public ActionResult PaymentStatus(int OrderId = 0)
        {
            try
            {
                string ROrderiD   = Request.Form["razorpay_order_id"];
                string RPaymentId = Request.Form["razorpay_payment_id"];
                string RSignature = Request.Form["razorpay_signature"];
                string Status     = Request.Form["Status"];
                string Status1    = Request.Form["razorpay_status"];
                string Status2    = Request.Form["razorpay_status"];

                //to fetch detail of payment
                RazorpayClient client  = new RazorpayClient("rzp_test_zGV3VGeqasiZZD", "3sQi6joqbhooZwHrzuIvu9qt");
                Payment        payment = client.Payment.Fetch(RPaymentId);

                //if(payment.Status)
                OrderViewModel objOrderViewModel = new OrderViewModel();
                objOrderViewModel.Order_Id           = OrderId;
                objOrderViewModel.rzp_order_id       = ROrderiD;
                objOrderViewModel.rzp_payment_id     = RPaymentId;
                objOrderViewModel.rzp_signature      = RSignature;
                objOrderViewModel.order_status       = "Submitted";
                objOrderViewModel.rzp_payment_status = Status;



                var result = ObjIUserService.UpdateOrderDeatils(objOrderViewModel, "online");

                var getUserdetail = ObjIUserService.GetOrderDetailByOrderId(OrderId);
                if (getUserdetail != null)
                {
                    var deletCart = DeleteCartAfterPayment();

                    ViewBag.TotalPrice = getUserdetail.Totalprice;

                    return(View());
                }
                else
                {
                    ViewBag.Status = "Failure";

                    return(View());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ViewResult CapturePayment(string paymentId)
        {
            RazorpayClient client = new RazorpayClient(_key, _secret);

            Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);
            var amount   = payment.Attributes["amount"];
            var currency = payment.Attributes["currency"];

            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", amount);
            options.Add("currency", currency);
            Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
            ViewBag.Message = "Payment capatured!";
            return(View("Success"));
        }
        private string CreateTransfersViaOrder(OrderModel order)
        {
            try
            {
                RazorpayClient client = new RazorpayClient(_key, _secret);
                Dictionary <string, object> options = new Dictionary <string, object>();
                options.Add("amount", order.OrderAmountInSubUnits);
                options.Add("currency", order.Currency);
                options.Add("payment_capture", order.Payment_Capture);
                options.Add("notes", order.Notes);

                List <Dictionary <string, object> > transfers = new List <Dictionary <string, object> >();

                // Tranfer to Account 1
                Dictionary <string, object> transfer = new Dictionary <string, object>();
                transfer.Add("account", "acc_FrZdKIHffMifPl");              // account 1
                transfer.Add("amount", order.OrderAmountInSubUnits / 2);    // 50% amount of the total amount
                transfer.Add("currency", "INR");
                transfer.Add("notes", order.Notes);
                List <string> linkedAccountNotes = new List <string>();
                linkedAccountNotes.Add("note for account 1");
                transfer.Add("linked_account_notes", linkedAccountNotes);
                transfers.Add(transfer);

                // Transfer to Account 2
                transfer = new Dictionary <string, object>();
                transfer.Add("account", "acc_FrZbSTT96Jfp6n");              // account 2
                transfer.Add("amount", order.OrderAmountInSubUnits / 2);    // 50% amount of the total amount
                transfer.Add("currency", "INR");
                transfer.Add("notes", order.Notes);
                linkedAccountNotes = new List <string>();
                linkedAccountNotes.Add("note 2 for second transfer");
                transfer.Add("linked_account_notes", linkedAccountNotes);
                transfers.Add(transfer);

                // Add transfers to options object
                options.Add("transfers", transfers);

                Order orderResponse = client.Order.Create(options);
                var   orderId       = orderResponse.Attributes["id"].ToString();
                return(orderId);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 29
0
        public PaymentModel CreateOrder(PaymentModel model)
        {
            RazorpayClient client = new RazorpayClient(ConfigurationManager.AppSetting.RazorPaySetting.apiKey, ConfigurationManager.AppSetting.RazorPaySetting.appSecret);

            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", model.Amount * 100);
            options.Add("currency", "INR");
            options.Add("receipt", model.ReceiptId);

            Order   order  = client.Order.Create(options);
            JObject result = JObject.Parse(order.Attributes.ToString());

            model.RazorPayOrderId = (string)result["id"];
            return(model);
        }
Exemplo n.º 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100); // this amount should be same as transaction amount
            input.Add("currency", "INR");
            input.Add("receipt", "12121");
            input.Add("payment_capture", 1);

            string key    = "<Enter your Api Key here>";
            string secret = "<Enter your Secret Key here>";

            RazorpayClient client = new RazorpayClient(key, secret);

            Razorpay.Api.Order order = client.Order.Create(input);
            orderId = order["id"].ToString();
        }