Ejemplo n.º 1
0
 public ActionResult ConfirmTransaction()
 {
     var random = new Random();
     var model = new TransactionConfirmationModel();
     model.TransactionID = random.Next();
     return View(model);
 }
Ejemplo n.º 2
0
        public ActionResult BeginConfirm(TransactionConfirmationModel model)
        {
            if (model.Amount <= 0)
            {
                ModelState.AddModelError("Amount", "The field Amount must be greater than zero");
            }
            else
            {
                try
                {
                    var rublon = new Rublon2Factor(Globals.SystemToken, Globals.SecretKey);
                    var message = string.Format("Do you confirm transaction no. {0} with the amount of {1:C}?", model.TransactionID, model.Amount);
                    var parameters = new JObject();
                    parameters.Add("transId", model.TransactionID);
                    var url = rublon.Confirm(Globals.Host + "/Callback/TransactionConfirm",
                                             User.Identity.Name,
                                             User.Identity.Name,
                                             message,
                                             parameters);

                    if (!string.IsNullOrEmpty(url))
                    {
                        return Redirect(url);
                    }
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Transaction confirm failed");
                }
            }

            return View("ConfirmTransaction");
        }