Ejemplo n.º 1
0
        public ActionResult SecuredPayment(double cryptoamount)
        {
            var transaction = new CryptoTransaction();
            var account     = new CryptoAccount();
            var accountId   = AccountId();

            transaction.Create(new TransactionVm()
            {
                Status             = TransactionStatus.PENDING,
                Amount             = Convert.ToDecimal(cryptoamount),
                accountId          = AccountId(),
                CurrencyDomination = "BTC",
                TransactionType    = TransactionTypeStatus.Credit
            });
            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(cryptoamount),
                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);
                    }
                    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);
                    }

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



                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult MakePayment(double cryptoamount)
        {
            var transaction = new CryptoTransaction();
            var account     = new CryptoAccount();
            var accountId   = AccountId();

            transaction.Create(new TransactionVm()
            {
                Status             = TransactionStatus.PENDING,
                Amount             = Convert.ToDecimal(cryptoamount),
                accountId          = accountId,
                CurrencyDomination = "BTC",
                TransactionType    = TransactionTypeStatus.Credit
            });
            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(cryptoamount),
                period    = "2 HOUR",
                language  = "en"
            };

            using (Cryptobox cryptobox = new Cryptobox(options))
            {
                if (cryptobox.is_paid())
                {
                    //initiate a pendint transaction

                    if (!cryptobox.is_confirmed())
                    {
                        ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() +
                                          "). Awaiting transaction/payment confirmation";
                    }
                    else
                    {
                        if (!cryptobox.is_processed())
                        {
                            ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message one time after payment has been made)";
                            cryptobox.set_status_processed();
                            transaction.SetStatus(transaction.savedId, TransactionStatus.SUCCESSFUL);
                        }
                        else
                        {
                            ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message during " + options.period + " period after payment has been made)";
                            transaction.SetStatus(transaction.savedId, TransactionStatus.INPROGESS);
                        }
                    }
                }
                else
                {
                    ViewBag.message = "This invoice has not been paid yet";
                    transaction.SetStatus(transaction.savedId, TransactionStatus.PENDING);
                }

                DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel();

                return(View(model));
            }
        }