//Khi thanh toán Ngan Luong XOng
        public ActionResult confirm_orderPaymentOnline()
        {
            String            Token = Request["token"];
            RequestCheckOrder info  = new RequestCheckOrder();

            info.Merchant_id       = nganluongInfo.Merchant_id;
            info.Merchant_password = nganluongInfo.Merchant_password;
            info.Token             = Token;
            APICheckoutV3      objNLChecout = new APICheckoutV3();
            ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);

            if (result.errorCode == "00")
            {
                String codeOrder = Session["OrderId"].ToString();
                var    OrderInfo = db.Orders.OrderByDescending(m => m.code == codeOrder).FirstOrDefault();
                OrderInfo.StatusPayment   = 1;
                db.Entry(OrderInfo).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.paymentStatus = OrderInfo.StatusPayment;
                ViewBag.Methodpayment = OrderInfo.deliveryPaymentMethod;
                return(View("oderComplete", OrderInfo));
            }
            else
            {
                ViewBag.status = false;
            }

            return(View("confirm_orderPaymentOnline"));
        }
        public ActionResult ConfirmOrder()
        {
            string            token = Request["token"];
            RequestCheckOrder info  = new RequestCheckOrder();

            info.Merchant_id       = _merchantId;
            info.Merchant_password = _merchantPassword;
            info.Token             = token;
            APICheckoutV3      objNLChecout = new APICheckoutV3();
            ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);

            if (result.errorCode == "00")
            {
                //update status order
                _orderService.UpdateStatus(int.Parse(result.order_code));
                _orderService.Save();
                ViewBag.IsSuccess = true;
                ViewBag.Result    = "Thanh toán thành công. Chúng tôi sẽ liên hệ lại sớm nhất.";
            }
            else
            {
                ViewBag.IsSuccess = true;
                ViewBag.Result    = "Có lỗi xảy ra. Vui lòng liên hệ admin.";
            }
            return(View());
        }
        public ActionResult PaymentReturn(string token, string key, int type = 0)
        {
            string result;

            //DEBUG
            //Logger.GetInstance().Write("Payment Return URL:");
            //Logger.GetInstance().Write(Request.Url.AbsoluteUri.ToString());

            if (type == ReturnType.Cancel.GetHashCode() || type == ReturnType.Timeout.GetHashCode() ||
                string.IsNullOrEmpty(key) || string.IsNullOrEmpty(token))
            {
                result = DbContext.CancelUrl(key);
                return(Redirect(result));
            }

            var db      = new DbContext();
            var details = db.GetDetails(key);

            if (details != null && details.ProviderTransRefId == token)
            {
                var info = new RequestCheckOrder();
                info.Merchant_id       = ConfigCode.GetInstance().MerchantID;
                info.Merchant_password = ConfigCode.GetInstance().MerchantPassword;
                info.Token             = token;
                var objApiCheckout = new APICheckoutV3();
                ResponseCheckOrder checkOrderRs = objApiCheckout.GetTransactionDetail(info);

                //DEBUG
                //Logger.GetInstance().Write("Transaction details:");
                // Logger.GetInstance().Write(JsonConvert.SerializeObject(checkOrderRs));

                switch (checkOrderRs.transactionStatus)
                {
                case "00":
                    details.PaymentStatus = EnumPaymentStatus.Paid.GetHashCode();
                    break;

                case "01":
                    details.PaymentStatus = EnumPaymentStatus.Pending.GetHashCode();
                    break;

                case "02":
                    details.PaymentStatus = EnumPaymentStatus.Unpaid.GetHashCode();
                    break;
                }

                var updateRs = db.SetDetails(key, details);

                // Build the success url and redirect back to Arcadier
                result = DbContext.SuccessUrl(key, "");
                return(Redirect(result));
            }
            else
            {
                // Build the failure url and redirect back to Arcadier
                result = DbContext.CancelUrl(key);
                return(Redirect(result));
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String            Token = Request["token"];
            RequestCheckOrder info  = new RequestCheckOrder();

            info.Merchant_id       = "24338";
            info.Merchant_password = "******";
            info.Token             = Token;
            APICheckoutV3      objNLChecout = new APICheckoutV3();
            ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);

            result_NL.Text = result.errorCode + result.payerName;
        }
Example #5
0
        public CheckPackageModel CheckPackageOrder(string barcode)
        {
            CheckPackageModel retVal = null;

            using (var client = new WebClient())
            {
                try
                {
                    client.Headers.Add("Token", Utils.TOKEN);
                    string             URL      = string.Format("{0}{1}?OrderNumber={2}", Utils.BASE_PATH, Utils.POST_ORDERS, barcode);
                    var                response = client.DownloadString(URL);
                    ResponseCheckOrder order    = JsonConvert.DeserializeObject <ResponseCheckOrder>(response);
                    retVal = order.Data;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            return(retVal);
        }
Example #6
0
        public ActionResult NLCallback(String Token)
        {
            AnperoService ws = new AnperoService();

            PaymentConfig[] pc = ws.GetPaymentAPIConfig(StoreID, TokenKey);
            if (pc != null && pc.Length > 0)
            {
                for (int i = 0; i < pc.Length; i++)
                {
                    if (pc[i].Name.ToUpper() == "NL")
                    {
                        RequestCheckOrder info = new RequestCheckOrder();
                        //for test
                        //info.Merchant_id = "24338";
                        //info.Merchant_password = "******";
                        info.Merchant_id       = pc[i].MerchantId;
                        info.Merchant_password = pc[i].MerchantPassword;
                        info.Token             = Token;
                        APICheckoutV3      objNLChecout = new APICheckoutV3();
                        ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);
                        string             rs           = "Giao dịch Thành công, đơn hàng của quý khách đang được xử lý nhanh chóng";
                        rs += result.description;
                        rs += "<br>";
                        rs += "Số tiền thanh toán: " + result.paymentAmount;
                        rs += "<br>";
                        rs += "Mã giao dịch Ngân Lượng: " + result.transactionId;
                        rs += "<br>";
                        rs += "Mã đơn hàng: " + result.order_code;
                        rs += "<br>";
                        rs += "Tên người thanh toán: " + result.payerName;
                        //update and add cash book
                        ws.UpdateOrderStatus(StoreID, TokenKey, Convert.ToInt32(result.order_code), Convert.ToInt32(result.paymentAmount), "Ngân Lượng (Mã giao dịch Ngân Lượng " + result.transactionId + ")<br />" + rs);
                        ViewBag.Msg = rs;
                    }
                }
            }

            return(View("Index"));
        }
        public ActionResult Success()
        {
            var    order = new tbl_HoaDon();
            String Token = Request["token"];

            if (Token != null)
            {
                long orderID           = long.Parse(Request["Order_code"]);
                RequestCheckOrder info = new RequestCheckOrder();
                info.Merchant_id       = MerchantID;
                info.Merchant_password = MerchantPassword;
                info.Token             = Token;
                APICheckoutV3      objNLChecout = new APICheckoutV3();
                ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);
                ViewBag.Message    = result.errorCode + result.payerName;
                order.ID           = orderID;
                order.iStatus      = 1;
                order.iMaTrangThai = 1;
                new HoaDonDAO().Update(order);
            }

            return(View());
        }
Example #8
0
        //Khi thanh toán Ngan Luong XOng
        public ActionResult confirm_orderPaymentOnline()
        {
            String            Token = Request["token"];
            RequestCheckOrder info  = new RequestCheckOrder();

            info.Merchant_id       = nganluongInfo.Merchant_id;
            info.Merchant_password = nganluongInfo.Merchant_password;
            info.Token             = Token;
            APICheckoutV3      objNLChecout = new APICheckoutV3();
            ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);

            if (result.errorCode == "00")
            {
                var cart = Session[SessionCart];
                var list = new List <Cart_item>();
                ViewBag.cart           = (List <Cart_item>)cart;
                Session["SessionCart"] = null;
                var OrderInfo = db.Orders.OrderByDescending(m => m.ID).FirstOrDefault();
                ViewBag.name              = OrderInfo.deliveryname;
                ViewBag.email             = OrderInfo.deliveryemail;
                ViewBag.address           = OrderInfo.deliveryaddress;
                ViewBag.code              = OrderInfo.code;
                ViewBag.phone             = OrderInfo.deliveryphone;
                OrderInfo.StatusPayment   = 1;
                db.Entry(OrderInfo).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.paymentStatus = OrderInfo.StatusPayment;
                ViewBag.Methodpayment = OrderInfo.deliveryPaymentMethod;
                return(View("payment"));
            }
            else
            {
                ViewBag.status = false;
            }

            return(View("confirm_orderPaymentOnline"));
        }
Example #9
0
 public ActionResult DonationComplete()
 {
     try
     {
         //check exist DonatedInfo Session
         if (Session["DonatedInfo"] == null)
         {
             return(null);
         }
         else
         {
             //Get data in session and transactiondetail and return to view
             var newDonate = (DonationDTO)Session["DonatedInfo"];
             newDonate.DonatedDate = DateTime.Now.ToString("hh:mm dd/MM/yy");
             RequestCheckOrder info = new RequestCheckOrder();
             info.Merchant_id       = "48283";
             info.Merchant_password = "******";
             info.Token             = newDonate.TradeCode;
             APICheckoutV3      objNLChecout = new APICheckoutV3();
             ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);
             using (var db = new DonationDAL())
             {
                 db.AddNewDonation(newDonate);
             }
             using (var db = new EventDAL())
             {
                 newDonate.EventName = db.GetEventNameById(newDonate.EventId);
             }
             Session.Remove("DonatedInfo");
             return(PartialView("~/Views/Donation/_DonationDone.cshtml", newDonate));
         }
     }
     catch (Exception)
     {
         return(PartialView("~/Views/Error/_Error.cshtml"));
     }
 }
Example #10
0
        public ActionResult ThanhToanThanhCong()
        {
            int orderId = 0;
            var model   = new ThanhToanVeXeModel();
            var _token  = Request["token"];

            if (!string.IsNullOrWhiteSpace(_token))
            {
                RequestCheckOrder info = new RequestCheckOrder();
                info.Merchant_id       = CommonHelper.Merchant_Id;
                info.Merchant_password = CommonHelper.Merchant_Password;
                info.Token             = _token;
                APICheckoutV3      objNLChecout = new APICheckoutV3();
                ResponseCheckOrder result       = objNLChecout.GetTransactionDetail(info);
                if (result.errorCode == "00")
                {
                    orderId = Convert.ToInt32(result.order_code);
                    model.HinhThucThanhToan = result.paymentMethod;
                    if (result.paymentMethod != "CHONVE")
                    {
                        var _order = _orderService.GetOrderById(orderId);
                        if (result.transactionStatus == "00")
                        {
                            _order.PaymentStatusId = (int)PaymentStatus.Paid;
                        }
                        else
                        {
                            _order.PaymentStatusId = (int)PaymentStatus.Authorized;
                        }
                        _orderService.UpdateOrder(_order);
                        var phoives = _phoiveService.GetPhoiVeByOrderId(orderId);
                        foreach (var item in phoives)
                        {
                            item.TrangThaiId = (int)ENTrangThaiPhoiVe.DaThanhToan;
                            _phoiveService.UpdatePhoiVe(item);
                        }
                    }
                    else
                    {
                        //update trang thai phoi vé về chưa thanh toán
                    }
                }
            }

            //thiet dat thong tin noi nhan
            var countries = new List <Nop.Core.Domain.Directory.Country>();

            countries.Add(_countryService.GetCountryById(NhaXesController.CountryID));

            var diachigiaohang = _workContext.CurrentCustomer.ShippingAddress;

            if (_workContext.CurrentCustomer.Addresses.Count > 0)
            {
                diachigiaohang = _workContext.CurrentCustomer.Addresses.First();
            }

            model.diachigiaohang.PrepareModel(
                address: diachigiaohang,
                excludeProperties: false,
                addressSettings: _addressSettings,
                localizationService: _localizationService,
                stateProvinceService: _stateProvinceService,
                diachiService: _diachiService,
                addressAttributeFormatter: _addressAttributeFormatter,
                loadCountries: () => countries);
            //lay thong tin ve xe
            var phoive = _phoiveService.GetPhoiVeByCustomer(_workContext.CurrentCustomer.Id);

            for (int i = 0; i < phoive.Count(); i++)
            {
                orderId = phoive[i].OrderId;
            }

            model.phoiveinfos = _phoiveService.GetPhoiVeByOrderId(orderId);
            //cho thanh toan qua lau, nen het han giu cho ve
            if (model.phoiveinfos.Count == 0)
            {
                return(RedirectToRoute("HomePage"));
            }
            model.nguonvexeinfo = _vexeService.GetNguonVeXeById(model.phoiveinfos[0].NguonVeXeId.GetValueOrDefault(0));
            model.nhaxeinfo     = _nhaxeService.GetNhaXeById(model.nguonvexeinfo.NhaXeId);
            model.NgayDi        = model.phoiveinfos[0].NgayDi;
            model.NgayDi        = model.NgayDi.AddHours(model.nguonvexeinfo.ThoiGianDi.Hour).AddMinutes(model.nguonvexeinfo.ThoiGianDi.Minute);
            model.NgayVe        = model.NgayDi.AddHours(Convert.ToDouble(model.nguonvexeinfo.LichTrinhInfo.SoGioChay));
            model.TongTien      = decimal.Zero;
            model.KyHieuGhe     = "";
            foreach (var pv in model.phoiveinfos)
            {
                if (string.IsNullOrEmpty(model.KyHieuGhe))
                {
                    model.KyHieuGhe = pv.sodoghexequytac.Val;
                }
                else
                {
                    model.KyHieuGhe += "," + pv.sodoghexequytac.Val;
                }
                model.TongTien += pv.GiaVeHienTai;
            }
            ViewBag.OrderId = orderId;
            return(View(model));
        }