protected void btthanhtoan_Click(object sender, EventArgs e) { NL_Checkout nlcheckout = new NL_Checkout(); nlcheckout.merchant_site_code = this.merchant_site_code; nlcheckout.secure_pass = this.merchant_pass; string rs = nlcheckout.buildCheckoutUrlNew("http://hoannet.vn/success.aspx", this.receiver, "", txtOrderID.Text, txtPriceOrder.Text, "vnd", 1, 0, 0, 0, 0, "", "Truong Xuan Hoan*|*[email protected]*|*0986588099*|*18 Tam Trinh", ""); Response.Write(rs); Response.Redirect(rs); }
protected void bt_naptien_Click(object sender, EventArgs e) { NL_Checkout nlcheckout = new NL_Checkout(); nlcheckout.merchant_site_code = this.merchant_site_code; nlcheckout.secure_pass = this.merchant_pass; var rnd = new Random(DateTime.Now.Millisecond); int oderID = rnd.Next(0, 3000); DateTime dtNow = DateTime.Now; string strOrderID = dtNow.Year.ToString() + dtNow.Month.ToString() + dtNow.Day.ToString() + dtNow.Hour.ToString() + dtNow.Minute.ToString() + dtNow.Second.ToString(); string rs = nlcheckout.buildCheckoutUrlNew("http://localhost/success.aspx", this.receiver, "", strOrderID, txtPriceOrder.Text, "vnd", 1, 0, 0, 0, 0, "", "", ""); Response.Write(rs); Response.Redirect(rs); }
private void PaymentOnline() { string HoTen = txtFullname.Value; //StaticData.ValidParameter(Request.QueryString["HoTen"].Trim()); string DienThoai = txtPhone.Value; //StaticData.ValidParameter(Request.QueryString["DienThoai"].Trim()); string DiaChi = txtNo.Text + "," + slProvince.SelectedItem.Text + "," + slCity.SelectedItem.Text; string GhiChu = txtDesc.Value; //StaticData.ValidParameter(Request.QueryString["GhiChu"].Trim()); //string ID = Session["CurrentUser"] == null ? "" : Session["CurrentUser"].ToString();//StaticData.ValidParameter(Request.QueryString["ID"].Trim()); //string tenMuaHang = txtHoTen.Value; //string sdtMuaHang = txtSoDienThoai.Value; double total = 0; cart = Session["CartSession"] as DataTable; foreach (DataRow dr in cart.Rows) { string idProduct = dr["idSanPham"].ToString(); string sqlProduct = "select * from tb_SanPham where idSanPham = '" + idProduct + "'"; DataTable dataUser = Connect.GetTable(sqlProduct); string str_price = dataUser.Rows[0]["GiaMoi"].ToString(); double product_price = 0; if (!string.IsNullOrEmpty(str_price)) { product_price = double.Parse(str_price); } total += product_price; } NL_Checkout nlcheckout = new NL_Checkout(); nlcheckout.merchant_site_code = this.merchant_site_code; nlcheckout.secure_pass = this.merchant_pass; var rnd = new Random(DateTime.Now.Millisecond); int oderID = rnd.Next(0, 3000); DateTime dtNow = DateTime.Now; //string strOrderID = dtNow.Year.ToString() + dtNow.Month.ToString() + dtNow.Day.ToString() + dtNow.Hour.ToString() + dtNow.Minute.ToString() + dtNow.Second.ToString(); //string return_url, string receiver, string transaction_info, string order_code, string price, string currency, float quantity, float tax, float discount, float fee_cal, float fee_shipping, string order_description, string buyer_info, string affiliate_code string return_url, transaction_info, order_code, price, currency, order_description, buyer_info, affiliate_code; float quantity, tax, discount, fee_cal, fee_shipping; //return_url = HttpContext.Current.Request.Url.Authority.ToString() + GetRouteUrl("finishCheckOut", new { }); return_url = "http://" + HttpContext.Current.Request.Url.Authority.ToString() + "/finishcheckout"; transaction_info = ""; order_code = MyStaticData.TaoMaDonDatHang(); price = total.ToString(); currency = "vnd"; quantity = cart.Rows.Count; tax = 0; discount = 0; fee_cal = 0; fee_shipping = 0; order_description = ""; buyer_info = ""; affiliate_code = ""; string rs = nlcheckout.buildCheckoutUrlNew(return_url, this.receiver, transaction_info, order_code, price, currency, quantity, tax, discount, fee_cal, fee_shipping, order_description, buyer_info, affiliate_code); Response.Redirect(rs); }
public ActionResult Payment(string CustName, string CustPhone, string CustAdd, string CustEmail, bool?thanhtoantructuyenNL, bool?thanhtoantructuyenPP) { if (Session["userName"] == null) { return(RedirectToAction("LoginUsernormal", "LoginUser")); } var orderBook = new OrdersBook(); int userID = Convert.ToInt32(Session["userID"]); //Lưu vào trong db OrderBook orderBook.FoundedDate = DateTime.Now; orderBook.UserID = userID; orderBook.Status = 0; orderBook.Address = CustAdd; orderBook.Phone = CustPhone; orderBook.Email = CustEmail; orderBook.FullName = CustName; orderBook.Paid = false; // Mặc định là chưa thanh toán bool result = new OrderBookDAO().Insert(orderBook); try { if (result) { int tempID = orderBook.OrderID; var cart = (List <CartItem>)Session[CommonConstant.cartSession]; var detailDAO = new OrdersDetailsDAO(); double sum = 0; foreach (var item in cart) { var orderDetail = new OrdersDetail(); orderDetail.OrderID = tempID; orderDetail.BookID = item.Books.BookID; orderDetail.Total = (item.Quantity * item.Books.Price); orderDetail.Quantity = item.Quantity; orderDetail.Status = 0; detailDAO.Insert(orderDetail); sum += (item.Books.Price.GetValueOrDefault(0) * item.Quantity); } //Gửi mail thông báo đơn hàng cho Khách hàng string content = System.IO.File.ReadAllText(Server.MapPath("~/Areas/Store/Views/template/newOrder.cshtml")); content = content.Replace("{{CustomerName}}", CustName); content = content.Replace("{{Phone}}", CustPhone); content = content.Replace("{{Email}}", CustEmail); content = content.Replace("{{Address}}", CustAdd); content = content.Replace("{{Total}}", sum.ToString("N0")); new MailHelper().SendMail(CustEmail, "Đơn hàng mới từ QT BookStore", content, "Thông báo Đơn Đặt hàng từ QT BookStore"); if ((thanhtoantructuyenNL == null || thanhtoantructuyenNL == false) && (thanhtoantructuyenPP == null || thanhtoantructuyenPP == false)) { Session[CommonConstant.cartSession] = null; return(Redirect("/hoan-thanh")); } else if (thanhtoantructuyenPP != null || thanhtoantructuyenPP == true) { var model = new CommonConstant.InforPaypal { OrderId = tempID, Total = cart.Sum(m => m.Quantity * m.Books.Price) ?? 0 }; TempData["InforPaypal"] = model; return(RedirectToAction("PaymentWithPaypal", "Paypal")); } else { NL_Checkout nganluong = new NL_Checkout(); double total = cart.Sum(m => m.Quantity * m.Books.Price) ?? 0; string urlThanhToan = nganluong.buildCheckoutUrlNew(Url.Action("PaymentConfirmed", "OrderBook", null, Request.Url.Scheme), ConfigurationManager.AppSettings["email_nganluong"].ToString(), "Thanh toán " + total.ToString("#,##0").Replace(',', '.') + " đồng", tempID.ToString(), total.ToString(), "vnd", 1, 0, 0, 0, 0, "Thanh toán " + total.ToString("#,##0").Replace(',', '.') + " đồng", "Thanh toán " + total.ToString("#,##0").Replace(',', '.') + " đồng", ""); return(Redirect(urlThanhToan)); } } else { ModelState.AddModelError("", "Không thể thêm đơn hàng vì xảy ra lỗi ở server!"); return(View("ThongBaoLoi")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(View("ThongBaoLoi")); } }