Ejemplo n.º 1
0
        public ActionResult WithDraw(WithdrawVm m)
        {
            if (ModelState.IsValid)
            {
                double miniAmount = 200;
                if (m.Amount < miniAmount)
                {
                    ModelState.AddModelError("", "Please Enter Amount above the minimum amount - " + miniAmount);
                }
                var acc = new CryptoAccount();
                var bal = Convert.ToDouble(acc.Get(AccountId()).CurrentCryptoBalance);
                var sym = acc.Get(AccountId()).CR_Currency.ShortCode;
                if (bal < m.Amount)
                {
                    ModelState.AddModelError("", "Sorry !, You dont Have enough balance to withdraw - Your Current Balance is " + sym + " " + bal);
                }

                if (bal >= m.Amount)
                {
                    //process the payment
                    // get maintaince fee

                    var fees = acc.GetMaintainanceFees();
                    foreach (var i in fees)
                    {
                        if (i.SmallestAmount <= (decimal?)m.Amount || i.LargestAmount <= (decimal?)m.Amount)
                        {
                            m.MaintainceFee = Convert.ToDecimal(i.Fee);
                            var w = new CryptoWithDrawRequest();
                            w.Create(new WithdrawVm()
                            {
                                AccountId           = AccountId(),
                                Amount              = m.Amount,
                                MaintainceFee       = Convert.ToDecimal(i.Fee),
                                MaintainceFeeStatus = WithDrawRequestStatus.HasNotPaidMaintainceFee.ToString(),
                                WalletId            = m.WalletId,
                            });

                            return(RedirectToAction(nameof(MaintainceSecuredPayment), new { amount = m.MaintainceFee, withdrawrequestId = w.savedId }));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Please contact customer support. ");
                        }
                    }
                }
            }

            //IEnumerable<ModelError> errors = ModelState.Values.SelectMany(v => v.Errors).ToList();
            return(View(m));
        }
Ejemplo n.º 2
0
        public ActionResult MaintainceSecuredPayment(double amount, int withdrawrequestId)
        {
            var transaction = new CryptoTransaction();
            var withdraw    = new CryptoWithDrawRequest();
            var account     = new CryptoAccount();
            var accountId   = AccountId();

            ViewBag.amount = account.Get(AccountId()).CR_Currency.ShortCode + " " + amount;

            transaction.Create(new TransactionVm()
            {
                Status             = TransactionStatus.PENDING,
                Amount             = Convert.ToDecimal(amount),
                accountId          = AccountId(),
                CurrencyDomination = "BTC",
                TransactionType    = TransactionTypeStatus.Withdraw
            });
            OptionsModel options = new OptionsModel()
            {
                public_key  = GoUrlKeys.PublicKey,
                private_key = GoUrlKeys.PrivateKey,
                webdev_key  = "",
                orderID     = transaction.savedId.ToString(),
                userID      = UserId(),
                userFormat  = "COOKIE",
                //amount = 0,
                amountUSD = Convert.ToDecimal(amount),
                period    = "2 HOUR",
                language  = "en"
            };

            ViewBag.transId = transaction.savedId.ToString();
            using (Cryptobox cryptobox = new Cryptobox(options))
            {
                ViewBag.JsonUrl = cryptobox.cryptobox_json_url();
                ViewBag.Message = "";
                DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel();
                if (HttpContext.Request.Form["cryptobox_refresh_"] != null)
                {
                    ViewBag.Message = "<div class='gourl_msg'>";
                    if (cryptobox.is_paid())
                    {
                        ViewBag.Message +=
                            "<div style=\"margin:50px\" class=\"well\"><i class=\"fa fa-info-circle fa-3x fa-pull-left fa-border\" aria-hidden=\"true\"></i> " +
                            Controls.localisation[model.language].MsgNotReceived.Replace("%coinName%", model.coinName)
                            .Replace("%coinNames%",
                                     model.coinLabel == "BCH" || model.coinLabel == "DASH"
                                        ? model.coinName
                                        : model.coinName + "s")
                            .Replace("%coinLabel%", model.coinLabel) + "</div>";
                        transaction.SetStatus(transaction.savedId, TransactionStatus.INPROGESS);
                        withdraw.SetMaintanceFeeWithDrawStatus(withdrawrequestId, WithDrawRequestStatus.Inprogress);
                    }
                    else if (cryptobox.is_processed())
                    {
                        ViewBag.Message += "<div style=\"margin:70px\" class=\"alert alert-success\" role=\"alert\"> " +
                                           (model.boxType == "paymentbox"
                                               ? Controls.localisation[model.language].MsgReceived
                                               : Controls.localisation[model.language].MsgReceived2)
                                           .Replace("%coinName%", model.coinName)
                                           .Replace("%coinLabel%", model.coinLabel)
                                           .Replace("%amountPaid%", model.amoutnPaid.ToString()) + "</div>";
                        cryptobox.set_status_processed();
                        transaction.SetStatus(transaction.savedId, TransactionStatus.SUCCESSFUL);
                        withdraw.SetMaintanceFeeWithDrawStatus(withdrawrequestId, WithDrawRequestStatus.HasPaidMaintainceFee);
                    }

                    ViewBag.Message = "</div>";
                }



                return(View(model));
            }
        }
Ejemplo n.º 3
0
        public ActionResult WithDraws()
        {
            var list = new CryptoWithDrawRequest().GetWithdeWithdrawRequests(AccountId());

            return(PartialView(list));
        }
        public ActionResult WithDrawRequest()
        {
            var withdraw = new CryptoWithDrawRequest().GetWithdeWithdrawRequests();

            return(View(withdraw));
        }