public ActionResult PayPerPost() { OptionsModel options = new OptionsModel() { public_key = "-your public key for Bitcoin box-", private_key = "-your private key for Bitcoin box-", webdev_key = "", orderID = "post1", userID = "", userFormat = "COOKIE", amount = 0, amountUSD = (decimal)0.01, period = "NOEXPIRY", language = "en" }; using (Cryptobox cryptobox = new Cryptobox(options)) { string ftitle = Request.Form["ftitle"] ?? ""; string ftext = Request.Form["ftext"] ?? ""; ViewBag.error = ""; ViewBag.successful = false; ViewBag.ftitle = ftitle; ViewBag.ftext = ftext; if (Request.Form["ftitle"] != null && Request.Form["ftext"] != null) { if (ftitle == "") { ViewBag.error += "<li>Please enter Title</li>"; } if (ftext == "") { ViewBag.error += "<li>Please enter Text</li>"; } if (!cryptobox.is_paid()) { ViewBag.error += "<li>" + cryptobox.coin_name() + "s have not yet been received</li>"; } if (ViewBag.error != "") { ViewBag.error = "<br><ul style='color:#eb4847'>" + ViewBag.error + "</ul>"; } if (cryptobox.is_paid() && ViewBag.error == "") { ViewBag.successful = true; cryptobox.set_status_processed(); cryptobox.cryptobox_reset(); } } DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel(); return(View(model)); } }
public ActionResult PayPerRegistrationMulti() { string defPaiment = "bitcoin"; string[] available_payments = new[] { "bitcoin", "dogecoin" }; IDictionary <string, IDictionary <string, string> > all_keys = new Dictionary <string, IDictionary <string, string> >() { { "bitcoin", new Dictionary <string, string>() { { "public_key", "-your public key for Bitcoin box-" }, { "private_key", "-your private key for Bitcoin box-" } } }, { "dogecoin", new Dictionary <string, string>() { { "public_key", "-your public key for Dogecoin box-" }, { "private_key", "-your private key for Dogecoin box-" } } } }; foreach (KeyValuePair <string, IDictionary <string, string> > valuePair in all_keys) { if (valuePair.Value["public_key"] == null || valuePair.Value["private_key"] == null || valuePair.Value["public_key"] == "" || valuePair.Value["private_key"] == "") { return (new ContentResult() { Content = "Please add your public/private keys for " + valuePair.Key + " in all_keys variable" }); } else if (!valuePair.Value["public_key"].Contains("PUB")) { return (new ContentResult() { Content = "Invalid public key for " + valuePair.Key + " in all_keys variable" }); } else if (!valuePair.Value["private_key"].Contains("PRV")) { return (new ContentResult() { Content = "Invalid private key for " + valuePair.Key + " in all_keys variable" }); } else if (!ConfigurationManager.AppSettings["PrivateKeys"].Contains(valuePair.Value["private_key"])) { return (new ContentResult() { Content = "Please add your private key for " + valuePair.Key + " in Web.config." }); } } string coinName = CryptoHelper.cryptobox_selcoin(available_payments, defPaiment); OptionsModel options = new OptionsModel() { public_key = all_keys[coinName]["public_key"], private_key = all_keys[coinName]["private_key"], webdev_key = "", orderID = "signuppage", userID = "", userFormat = "COOKIE", amount = 0, amountUSD = (decimal)0.01, period = "NOEXPIRY", language = "en" }; using (Cryptobox cryptobox = new Cryptobox(options)) { ViewBag.Coins = available_payments; ViewBag.DefCoin = defPaiment; ViewBag.DefLang = options.language; string fname = Request.Form["fname"] ?? ""; string femail = Request.Form["femail"] ?? ""; string fpassword = Request.Form["fpassword"] ?? ""; ViewBag.error = ""; ViewBag.successful = false; ViewBag.fname = fname; ViewBag.femail = femail; ViewBag.fpassword = fpassword; if (Request.Form["fname"] != null && Request.Form["fname"] != "") { if (fname == "") { ViewBag.error += "<li>Please enter Your Name</li>"; } if (femail == "") { ViewBag.error += "<li>Please enter Your Email</li>"; } if (fpassword == "") { ViewBag.error += "<li>Please enter Your Password</li>"; } if (!cryptobox.is_paid()) { ViewBag.error += "<li>" + cryptobox.coin_name() + "s have not yet been received</li>"; } if (ViewBag.error != "") { ViewBag.error = "<br><ul style='color:#eb4847'>" + ViewBag.error + "</ul>"; } if (cryptobox.is_paid() && ViewBag.error == "") { ViewBag.successful = true; cryptobox.set_status_processed(); cryptobox.cryptobox_reset(); } } DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel(); return(View(model)); } }