Exemplo n.º 1
0
        public async Task <ActionResult> GetPrice(string paymentId, decimal priceUSD)
        {
            var data = facP.GetDetail(paymentId);

            if (data != null)
            {
                if (data.ReferenceExchange == (int)Commons.ExchangeType.None)
                {
                    var lstDataSys = facS.GetList();
                    var Priceobj   = new PriceObjects();
                    var ratePMUSD  = lstDataSys.Where(o => o.ValueType.Equals((int)Commons.ConfigType.PMUSD)).Select(o => o.Value).FirstOrDefault();
                    Priceobj.lastPrice   = priceUSD / ratePMUSD;
                    Priceobj.tempPrice   = Math.Round(Priceobj.lastPrice.Value, 2).ToString();
                    Priceobj.PaymentName = !string.IsNullOrEmpty(data.PaymentName) ? "PMUSD" : "PMUSD";
                    return(Json(Priceobj, JsonRequestBehavior.AllowGet));
                }
            }
            var URLApi = GetURLApi(paymentId);

            if (URLApi != null && !string.IsNullOrEmpty(URLApi.URLApi))
            {
                var Priceobj = new PriceObjects();
                Priceobj = await GetLastPrice(URLApi.URLApi);

                Priceobj.ScaleNumber = URLApi.ScaleNumber.HasValue ? URLApi.ScaleNumber.Value : 0;
                Priceobj.PaymentName = !string.IsNullOrEmpty(data.PaymentName) ? data.PaymentName : "";
                if (Priceobj.ScaleNumber > 0)
                {
                    if (Priceobj.last.HasValue)
                    {
                        var temp = priceUSD / Priceobj.last.Value;
                        Priceobj.last      = temp;
                        Priceobj.tempPrice = string.Format("{0:N" + Priceobj.ScaleNumber + "}", Priceobj.last.Value);
                    }
                    else
                    {
                        var temp = priceUSD / Priceobj.lastPrice.Value;
                        Priceobj.lastPrice = temp;
                        Priceobj.tempPrice = string.Format("{0:N" + Priceobj.ScaleNumber + "}", Priceobj.lastPrice.Value);
                    }
                }
                return(Json(Priceobj, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var obj = new
                {
                    Status = 0
                };
                return(Json(obj, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        // GET: DepositOrder
        public ActionResult Index()
        {
            var Customer = Session["UserC"] as UserSession;
            var Status   = new List <int>();

            Status.Add((int)Commons.DepositStatus.WaitingPay);
            //Status.Add((int)Commons.DepositStatus.Cancel);
            var model = fac.GetListDepositTransaction(Customer.UserId, Status);

            ViewBag.disabled = model != null && model.Count > 0;
            var config   = facS.GetList().Where(x => x.ValueType == (int)Commons.ConfigType.WaitingTime).FirstOrDefault();
            var IsCancel = model.Any(x => x.Status == (int)Commons.DepositStatus.Cancel);

            if (config != null && !IsCancel)
            {
                ViewBag.time = Convert.ToInt16(config.Value) * 60;
            }
            return(View(model));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> PayNow(List <CMS_DepositTransactionsModel> model)
        {
            var     Customer = Session["UserC"] as UserSession;
            var     Payment  = facP.GetDetail(model.FirstOrDefault().PaymentMethodId);
            var     Config   = facC.GetList().Where(x => x.ValueType == (int)Commons.ConfigType.USD).FirstOrDefault();
            decimal?Coin     = 0;

            if (!string.IsNullOrEmpty(Payment.URLApi))
            {
                var Priceobj = new PriceObjects();
                Priceobj = await GetLastPrice(Payment.URLApi);

                if (Priceobj.last.HasValue)
                {
                    Coin = model[0].Price / Priceobj.last.Value;
                }
                else
                {
                    Coin = model[0].Price / Priceobj.lastPrice.Value;
                }
            }
            model.ForEach(x =>
            {
                x.PaymentMethodName = Payment.PaymentName;
                x.WalletMoney       = Payment.WalletMoney;
                x.ExchangeRate      = Config != null ? Config.Value : 0;
                x.PayCoin           = Coin == 0 ? x.PayCoin : Coin.Value;
                x.CustomerId        = Customer.UserId;
                x.CustomerName      = Customer.UserName;
                x.DepositNo         = CommonHelper.RandomDepositNo();
            });
            var msg    = "";
            var result = facT.CreateDepositTransaction(model, ref msg, null);
            var obj    = new
            {
                msg    = msg,
                status = result
            };

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        // GET: PerfectMoney
        public ActionResult Index(decimal?price)
        {
            PerfectMoneyModel model = new PerfectMoneyModel();

            if (TempData["ErrorMessage"] != null)
            {
                ViewData["ErrorMessage"] = TempData["ErrorMessage"].ToString();
            }
            if (TempData["SuccessMessage"] != null)
            {
                ViewData["SuccessMessage"] = TempData["SuccessMessage"].ToString();
            }
            if (TempData["DataReturnError"] != null)
            {
                model = (PerfectMoneyModel)TempData["DataReturnError"];
                return(View(model));
            }
            try
            {
                List <CMS_DepositTransactionsModel> models = new List <CMS_DepositTransactionsModel>();
                var Config   = fac_C.GetList().Where(x => x.ValueType == (int)Commons.ConfigType.USD).FirstOrDefault();
                var customer = Session["UserC"] as UserSession;
                CMS_DepositTransactionsModel _data = new CMS_DepositTransactionsModel();
                _data.PaymentMethodName = "Perfect money";
                _data.WalletMoney       = Commons.APIType.APIPerfectMonney.ToString();
                _data.ExchangeRate      = Config != null ? Config.Value : 0;
                _data.PayCoin           = price == 0 ? price.Value : price.Value;
                _data.CustomerId        = customer.UserId;
                _data.CustomerName      = customer.UserName;
                _data.DepositNo         = CommonHelper.RandomDepositNo();
                models.Add(_data);
                //Set account information of admin to perfect payment
                var payPerfect = facP.GetList().Where(o => o.ReferenceExchange.Equals((int)Commons.ExchangeType.None)).FirstOrDefault();
                var adminInfo  = fac_Co.GetList().Select(o => o.Name).FirstOrDefault();;
                model.PAYEE_ACCOUNT  = payPerfect.WalletMoney;
                model.PAYEE_NAME     = adminInfo;
                model.PAYMENT_AMOUNT = price == 0 ? price.Value : price.Value;
                model.PAYMENT_AMOUNT = Math.Round(model.PAYMENT_AMOUNT.Value, 2);
                model.PAYMENT_UNITS  = "USD";
                var req = Request.Params.AllKeys;
                var msg = "";
                if (req != null && req.Count() > 0)
                {
                    var Paymnet_Batch_Num = Request.Params["PAYMENT_BATCH_NUM"];
                    if (Paymnet_Batch_Num == "0" && Paymnet_Batch_Num != null)
                    {
                        models[0].Status = (int)Commons.DepositStatus.Cancel;
                        var result = facT.CreateDepositTransaction(models, ref msg, null);
                        NSLog.Logger.Info("Perface_Payment", "Perfect payment Cancel");
                        // cancel
                    }
                    else if (Paymnet_Batch_Num != "0" && Paymnet_Batch_Num != null)
                    {
                        models[0].Status      = (int)Commons.DepositStatus.Completed;
                        models[0].CustomerId  = customer.UserId;
                        models[0].CreatedDate = DateTime.Now;
                        models[0].UpdatedDate = DateTime.Now;;
                        models[0].CreatedBy   = customer.UserName;
                        models[0].PackageSMS  = price.Value;
                        List <string> lstID = new List <string>();
                        lstID.Add(models[0].CustomerId);
                        var result = facT.CreateDepositTransaction(models, ref msg, lstID);
                        //Success change status
                        CMS_DepositTransactionsModel inputModel = new CMS_DepositTransactionsModel();
                        inputModel.UpdatedBy  = CurrentUser.UserId;
                        inputModel.Status     = (int)Commons.DepositStatus.Completed;
                        inputModel.Id         = lstID[0];
                        inputModel.CustomerId = customer.UserId;
                        var outPut = facT.ChangeStatus(inputModel, CurrentUser.UserId);
                    }
                }
            }
            catch (Exception ex)
            {
                NSLog.Logger.Info("Perface_Payment", "Perfect payment no successfully");
            }
            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult LoadGrid()
        {
            var model = _fac.GetList();

            return(PartialView("_ListData", model));
        }